Plugins: Add enablePluginsTracingByDefault feature flag (#80195)
* Add enablePluginsTracingByDefault feature flag
* Enable tracing for all plugins if enablePluginsTracingByDefault is set
* fix docstrings for IsEnabled and IsEnabledGlobally
* fix tests
* do not use separate feature manager
* add test case
* Revert "fix tests"
This reverts commit 46a2420ed1.
* cleanup
* fix plugin tracing disabled if wrong plugin setting is present
* add test case for enabled on plugin with wrong plugin setting but with enablePluginsTracingByDefault feature flag
* Add RequiresRestart = true to enablePluginsTracingByDefault
* re-generate feature flags
* pr review feedback
This commit is contained in:
@@ -14,10 +14,10 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/proxy"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/experimental/featuretoggles"
|
||||
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/plugins/auth"
|
||||
"github.com/grafana/grafana/pkg/plugins/config"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -207,8 +207,8 @@ func (s *Service) GetConfigMap(ctx context.Context, pluginID string, _ *auth.Ext
|
||||
}
|
||||
|
||||
func (s *Service) tracingEnvVars(plugin *plugins.Plugin) []string {
|
||||
var pluginTracingEnabled bool
|
||||
if v, exists := s.cfg.PluginSettings[plugin.ID]["tracing"]; exists {
|
||||
pluginTracingEnabled := s.cfg.Features != nil && s.cfg.Features.IsEnabledGlobally(featuremgmt.FlagEnablePluginsTracingByDefault)
|
||||
if v, exists := s.cfg.PluginSettings[plugin.ID]["tracing"]; exists && !pluginTracingEnabled {
|
||||
pluginTracingEnabled = v == "true"
|
||||
}
|
||||
if !s.cfg.Tracing.IsEnabled() || !pluginTracingEnabled {
|
||||
|
||||
@@ -354,6 +354,30 @@ func TestInitializer_tracingEnvironmentVariables(t *testing.T) {
|
||||
plugin: defaultPlugin,
|
||||
exp: expDefaultOtlp,
|
||||
},
|
||||
{
|
||||
name: `enabled on plugin with no "tracing" plugin setting but with enablePluginsTracingByDefault feature flag`,
|
||||
cfg: &config.Cfg{
|
||||
Tracing: config.Tracing{
|
||||
OpenTelemetry: defaultOTelCfg,
|
||||
},
|
||||
PluginSettings: map[string]map[string]string{pluginID: {}},
|
||||
Features: featuremgmt.WithFeatures(featuremgmt.FlagEnablePluginsTracingByDefault),
|
||||
},
|
||||
plugin: defaultPlugin,
|
||||
exp: expDefaultOtlp,
|
||||
},
|
||||
{
|
||||
name: `enabled on plugin with plugin setting "tracing=false" but with enablePluginsTracingByDefault feature flag`,
|
||||
cfg: &config.Cfg{
|
||||
Tracing: config.Tracing{
|
||||
OpenTelemetry: defaultOTelCfg,
|
||||
},
|
||||
PluginSettings: map[string]map[string]string{pluginID: {"tracing": "false"}},
|
||||
Features: featuremgmt.WithFeatures(featuremgmt.FlagEnablePluginsTracingByDefault),
|
||||
},
|
||||
plugin: defaultPlugin,
|
||||
exp: expDefaultOtlp,
|
||||
},
|
||||
{
|
||||
name: "GF_PLUGIN_VERSION is not present if tracing is disabled",
|
||||
cfg: &config.Cfg{
|
||||
|
||||
Reference in New Issue
Block a user