Plugins: Support for distributed tracing in backend plugins SDK (#63714)
* Tracing: Pass OTLP address and propagation format to plugins * Fix unit tests * Fix indentation * Fix plugin manager integration tests * Goimports * Pass plugin version to plugins * Do not add GF_PLUGIN_VERSION if plugin version is not set, add tests * Allow disabling plugins distributed tracing on a per-plugin basis * Moved disabled plugins to tracing.opentelemetry config section * Pre-allocate DisabledPlugins map to the correct size * Moved disable tracing setting flags in plugin settings * Renamed plugin env vars for tracing endpoint and propagation * Fix plugin initializer tests * Refactoring: Moved OpentelemetryCfg from pkg/infra to pkg/plugins * Changed GetSection to Section in parseSettingsOpentelemetry * Add tests for NewOpentelemetryCfg * Fix test case names in TestNewOpentelemetryCfg * OpenTelemetry: Remove redundant error checks
This commit is contained in:
@@ -51,6 +51,9 @@ func (i *Initializer) envVars(plugin *plugins.Plugin) []string {
|
||||
hostEnv := []string{
|
||||
fmt.Sprintf("GF_VERSION=%s", i.cfg.BuildVersion),
|
||||
}
|
||||
if plugin.Info.Version != "" {
|
||||
hostEnv = append(hostEnv, fmt.Sprintf("GF_PLUGIN_VERSION=%s", plugin.Info.Version))
|
||||
}
|
||||
|
||||
if i.license != nil {
|
||||
hostEnv = append(
|
||||
@@ -64,7 +67,22 @@ func (i *Initializer) envVars(plugin *plugins.Plugin) []string {
|
||||
|
||||
hostEnv = append(hostEnv, i.awsEnvVars()...)
|
||||
hostEnv = append(hostEnv, azsettings.WriteToEnvStr(i.cfg.Azure)...)
|
||||
return getPluginSettings(plugin.ID, i.cfg).asEnvVar("GF_PLUGIN", hostEnv)
|
||||
|
||||
// Tracing
|
||||
pluginTracingEnabled := true
|
||||
if v, exists := i.cfg.PluginSettings[plugin.ID]["tracing"]; exists {
|
||||
pluginTracingEnabled = v != "false"
|
||||
}
|
||||
if i.cfg.Opentelemetry.IsEnabled() && pluginTracingEnabled {
|
||||
hostEnv = append(
|
||||
hostEnv,
|
||||
fmt.Sprintf("GF_INSTANCE_OTLP_ADDRESS=%s", i.cfg.Opentelemetry.Address),
|
||||
fmt.Sprintf("GF_INSTANCE_OTLP_PROPAGATION=%s", i.cfg.Opentelemetry.Propagation),
|
||||
)
|
||||
}
|
||||
|
||||
ev := getPluginSettings(plugin.ID, i.cfg).asEnvVar("GF_PLUGIN", hostEnv)
|
||||
return ev
|
||||
}
|
||||
|
||||
func (i *Initializer) awsEnvVars() []string {
|
||||
|
||||
Reference in New Issue
Block a user