Fixed: processing spans after SDK is closed (OTel and ASP.NET Core) #3726
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
sentry-dotnet/src/Sentry.AspNetCore/ApplicationBuilderExtensions.cs
Line 45 in e382fb0
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.