diff --git a/otel/span_processor.go b/otel/span_processor.go index 8b64d9dd0..d32e2b55b 100644 --- a/otel/span_processor.go +++ b/otel/span_processor.go @@ -103,6 +103,10 @@ func (ssp *sentrySpanProcessor) ForceFlush(ctx context.Context) error { func flushSpanProcessor(ctx context.Context) error { hub := sentry.GetHubFromContext(ctx) + if hub == nil { + hub = sentry.CurrentHub() + } + // TODO(michi) should we make this configurable? defer hub.Flush(2 * time.Second) return nil diff --git a/otel/span_processor_test.go b/otel/span_processor_test.go index 4361442c0..3154b4e54 100644 --- a/otel/span_processor_test.go +++ b/otel/span_processor_test.go @@ -72,7 +72,7 @@ func TestNewSentrySpanProcessor(t *testing.T) { func TestSpanProcessorShutdown(t *testing.T) { spanProcessor, _, tracer := setupSpanProcessorTest() - ctx := emptyContextWithSentry() + ctx := context.Background() tracer.Start(emptyContextWithSentry(), "spanName") assertEqual(t, sentrySpanMap.Len(), 1)