Skip to content

SimpleSpanProcessor.Shutdown panics when constructed with a nil exporter #8788

Description

@pellared

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:tracePart of OpenTelemetry tracingbugSomething isn't workingpkg:SDKRelated to an SDK package

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions