Description
SpiceDB never calls Shutdown() or ForceFlush() on the OpenTelemetry TracerProvider during process termination. As a result, spans buffered in the BatchSpanProcessor at the moment of SIGTERM/SIGINT are dropped. This is visible on slow traces, where the root span arrives at the collector but many of its inner spans are missing.
Likely root cause
The TracerProvider is constructed inside cobraotel.RunE() (cobraotel.go#L202-L206):
otel.SetTracerProvider(trace.NewTracerProvider(
trace.WithSampler(trace.ParentBased(trace.TraceIDRatioBased(sampleRatio))),
trace.WithBatcher(exporter),
trace.WithResource(res),
))
The provider is registered globally and the reference is discarded, therefore SpiceDB has no handle to it. When main returns, the BatchSpanProcessor goroutine is likely being abruptly killed and any unexported spans are lost.
Proposed fix
Drop the cobraotel dependency; have SpiceDB build, own and terminate the TracerProvider object.
Description
SpiceDB never calls
Shutdown()orForceFlush()on the OpenTelemetryTracerProviderduring process termination. As a result, spans buffered in theBatchSpanProcessorat the moment of SIGTERM/SIGINT are dropped. This is visible on slow traces, where the root span arrives at the collector but many of its inner spans are missing.Likely root cause
The
TracerProvideris constructed insidecobraotel.RunE()(cobraotel.go#L202-L206):The provider is registered globally and the reference is discarded, therefore SpiceDB has no handle to it. When
mainreturns, theBatchSpanProcessorgoroutine is likely being abruptly killed and any unexported spans are lost.Proposed fix
Drop the
cobraoteldependency; have SpiceDB build, own and terminate theTracerProviderobject.