Skip to content

Conversation

@jamescrosswell
Copy link
Collaborator

@jamescrosswell jamescrosswell commented Nov 4, 2024

Resolves #3724

Fixes and issue when using ASP.NET Core and OpenTelemetry instrumentation, where the SDK might be closed before the last OpenTelemetry spans get fully processed by the SentrySpanProcessor.

Problem

When the AppBuilderExtensions initialise the SDK a lifetime callback is also registered to close the SDK when the app shuts down:

lifetime?.ApplicationStopped.Register(SentrySdk.Close);

However this can be called before all telemetry events are received/processed by the SentrySpanProcessor, which was then trying to create new spans for that telemetry using a disabled hub.

Solution

The OnEnd and OnStart events for the SentrySpanProcessor now check to see whether the hub is still active before doing any work.

@jamescrosswell jamescrosswell marked this pull request as ready for review November 4, 2024 10:15
Copy link
Contributor

@bricefriha bricefriha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception on shutdown when using Sentry & OpenTelemetry

3 participants