Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pkg/telemetry/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func NewServeProvider(ctx context.Context) (provider *Provider, otelEnabled bool

otelCfg := appConfig.OTEL
hasRegisteredProcessors := HasRegisteredSpanProcessors()

handleUnusedEndpoint(&otelCfg)

if otelCfg.Endpoint == "" && !otelCfg.EnablePrometheusMetricsPath && !hasRegisteredProcessors {
return nil, false, nil
}
Expand Down Expand Up @@ -74,3 +77,20 @@ func NewServeProvider(ctx context.Context) (provider *Provider, otelEnabled bool

return p, true, nil
}

// handleUnusedEndpoint enables tracing by default when an OTLP endpoint is
// configured but both tracing and metrics are disabled, so the server can start
// normally instead of crashing with a fatal validation error.
func handleUnusedEndpoint(otelCfg *config.OpenTelemetryConfig) {
if otelCfg.Endpoint == "" {
return
}
tracingOff := otelCfg.TracingEnabled == nil || !*otelCfg.TracingEnabled
metricsOff := otelCfg.MetricsEnabled == nil || !*otelCfg.MetricsEnabled
if tracingOff && metricsOff {
slog.Warn("OTLP endpoint is configured but tracing and metrics are both disabled; enabling tracing by default",
"endpoint", otelCfg.Endpoint)
enabled := true
otelCfg.TracingEnabled = &enabled
}
}
Loading