FeatureToggles: Add context and and an explicit global check (#78081)
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/tracing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/tsdb/intervalv2"
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/client"
|
||||
@@ -73,7 +74,7 @@ func New(
|
||||
// standard deviation sampler is the default for backwards compatibility
|
||||
exemplarSampler := exemplar.NewStandardDeviationSampler
|
||||
|
||||
if features.IsEnabled(featuremgmt.FlagDisablePrometheusExemplarSampling) {
|
||||
if features.IsEnabledGlobally(featuremgmt.FlagDisablePrometheusExemplarSampling) {
|
||||
exemplarSampler = exemplar.NewNoOpSampler
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ func New(
|
||||
TimeInterval: timeInterval,
|
||||
ID: settings.ID,
|
||||
URL: settings.URL,
|
||||
enableDataplane: features.IsEnabled(featuremgmt.FlagPrometheusDataplane),
|
||||
enableDataplane: features.IsEnabledGlobally(featuremgmt.FlagPrometheusDataplane),
|
||||
exemplarSampler: exemplarSampler,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
p "github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/kinds/dataquery"
|
||||
|
||||
"github.com/grafana/kindsys"
|
||||
@@ -23,6 +24,7 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/client"
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/models"
|
||||
@@ -440,8 +442,7 @@ func setup() (*testContext, error) {
|
||||
JSONData: json.RawMessage(`{"timeInterval": "15s"}`),
|
||||
}
|
||||
|
||||
features := &fakeFeatureToggles{flags: map[string]bool{"prometheusBufferedClient": false}}
|
||||
|
||||
features := featuremgmt.WithFeatures()
|
||||
opts, err := client.CreateTransportOptions(context.Background(), settings, &setting.Cfg{}, log.New())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -460,14 +461,6 @@ func setup() (*testContext, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
type fakeFeatureToggles struct {
|
||||
flags map[string]bool
|
||||
}
|
||||
|
||||
func (f *fakeFeatureToggles) IsEnabled(feature string) bool {
|
||||
return f.flags[feature]
|
||||
}
|
||||
|
||||
type fakeHttpClientProvider struct {
|
||||
httpclient.Provider
|
||||
opts httpclient.Options
|
||||
|
||||
Reference in New Issue
Block a user