Description
NewSimpleSpanProcessor(nil) returns a non-nil processor, but calling Shutdown on that processor panics.
The constructor stores the supplied exporter directly, and the existing TestNewSimpleSpanProcessorWithNilExporter explicitly verifies that a processor can be constructed with a nil exporter. In Shutdown, the exporter is captured and cleared under the mutex, then exp.Shutdown(ctx) is called in a goroutine without checking whether exp is nil.
The resulting panic terminates the host process during telemetry shutdown.
Environment
- OS: Linux
- Architecture: amd64
- Go Version:
go1.26.4
- opentelemetry-go version:
0de413a318cb52629baefb89a1554a905e105aa3
Steps To Reproduce
Add this regression test to sdk/trace/simple_span_processor_test.go:
func TestSimpleSpanProcessorShutdownWithNilExporter(t *testing.T) {
ssp := NewSimpleSpanProcessor(nil)
require.NoError(t, ssp.Shutdown(t.Context()))
}
Then run:
cd sdk
go test ./trace -run '^TestSimpleSpanProcessorShutdownWithNilExporter$' -count=1
On current main, this panics in the shutdown goroutine at simple_span_processor.go:92 with a nil pointer dereference.
Expected behavior
Shutting down a SimpleSpanProcessor constructed with a nil exporter should not panic. Given the constructor's existing tested behavior, Shutdown should treat the absent exporter as a no-op and return nil.
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Description
NewSimpleSpanProcessor(nil)returns a non-nil processor, but callingShutdownon that processor panics.The constructor stores the supplied exporter directly, and the existing
TestNewSimpleSpanProcessorWithNilExporterexplicitly verifies that a processor can be constructed with a nil exporter. InShutdown, the exporter is captured and cleared under the mutex, thenexp.Shutdown(ctx)is called in a goroutine without checking whetherexpis nil.The resulting panic terminates the host process during telemetry shutdown.
Environment
go1.26.40de413a318cb52629baefb89a1554a905e105aa3Steps To Reproduce
Add this regression test to
sdk/trace/simple_span_processor_test.go:Then run:
On current
main, this panics in the shutdown goroutine atsimple_span_processor.go:92with a nil pointer dereference.Expected behavior
Shutting down a
SimpleSpanProcessorconstructed with a nil exporter should not panic. Given the constructor's existing tested behavior,Shutdownshould treat the absent exporter as a no-op and return nil.Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it. Learn more here.