grafana/pkg/services/pluginsintegration/pluginconfig/tracing.go
Marcus Efraimsson 6c1de260a2
API Server: Standalone observability (#84789)
Adds support for logs (specify level), metrics (enable metrics and Prometheus /metrics endpoint 
and traces (jaeger or otlp) for standalone API server. This will allow any grafana core service 
part of standalone apiserver to use logging, metrics and traces as normal.
2024-03-21 17:06:32 +01:00

31 lines
954 B
Go

package pluginconfig
import (
"fmt"
"github.com/grafana/grafana/pkg/infra/tracing"
pCfg "github.com/grafana/grafana/pkg/plugins/config"
"github.com/grafana/grafana/pkg/setting"
)
// newTracingCfg creates a plugins tracing configuration based on the provided Grafana tracing config.
// If OpenTelemetry (OTLP) is disabled, a zero-value OpenTelemetryCfg is returned.
func newTracingCfg(grafanaCfg *setting.Cfg) (pCfg.Tracing, error) {
tracingCfg, err := tracing.ParseTracingConfig(grafanaCfg)
if err != nil {
return pCfg.Tracing{}, fmt.Errorf("parse settings: %w", err)
}
if !tracingCfg.OTelExporterEnabled() {
return pCfg.Tracing{}, nil
}
return pCfg.Tracing{
OpenTelemetry: pCfg.OpenTelemetryCfg{
Address: tracingCfg.Address,
Propagation: tracingCfg.Propagation,
Sampler: tracingCfg.Sampler,
SamplerParam: tracingCfg.SamplerParam,
SamplerRemoteURL: tracingCfg.SamplerRemoteURL,
},
}, nil
}