mirror of
https://github.com/grafana/grafana.git
synced 2025-01-16 11:42:35 -06:00
6c1de260a2
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.
31 lines
954 B
Go
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
|
|
}
|