Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: processing spans after SDK is closed (OTel and ASP.NET Core) #3726

Merged
merged 2 commits into from
Nov 4, 2024

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

@jamescrosswell jamescrosswell merged commit 3bcab16 into main Nov 4, 2024
23 checks passed
@jamescrosswell jamescrosswell deleted the otel-shutdown branch November 4, 2024 20:50
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
2 participants