-
-
Notifications
You must be signed in to change notification settings - Fork 237
fix: OpenTelemetry transactions for failed requests keep their route name and otel context #5310
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -667,8 +667,17 @@ private SentryId CaptureEvent(SentryEvent evt, SentryHint? hint, Scope scope) | |
| { | ||
| // Event contains a terminal exception -> finish any current transaction as aborted | ||
| // Do this *after* the event was captured, so that the event is still linked to the transaction. | ||
| _options.LogDebug("Ending transaction as Aborted, due to unhandled exception."); | ||
| transaction.Finish(SpanStatus.Aborted); | ||
| // Skip for OpenTelemetry transactions - these get handled by the SpanProcessor instead. See https://github.com/getsentry/sentry-dotnet/pull/5310 | ||
| if (transaction is IBaseTracer { IsOtelInstrumenter: true }) | ||
| { | ||
| _options.LogDebug( | ||
| "Not ending OpenTelemetry transaction as Aborted; it is finished by the SentrySpanProcessor."); | ||
| } | ||
| else | ||
| { | ||
|
Comment on lines
+673
to
+677
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: If Suggested FixImplement a fallback mechanism, such as a timeout, to ensure transactions are eventually finished and reported even if Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OnEnd is already the only path that finishes OTel transactions — every successful request relies on it, not just failed ones, so this doesn't add a new dependency. The cases where it wouldn't fire are (1) the Activity being sampled out, where we deliberately don't send a transaction, and (2) a process-terminating crash, where the flush is unreliable regardless and the only thing we'd have sent is the malformed transaction this PR removes. For the ASP.NET Core path in the issue, the host always stops the activity, so OnEnd runs. A timeout fallback would just resurrect the early-finish bug. |
||
| _options.LogDebug("Ending transaction as Aborted, due to unhandled exception."); | ||
| transaction.Finish(SpanStatus.Aborted); | ||
| } | ||
| } | ||
|
|
||
| return id; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: SpanProcessor vs OTLP Exporter
Does this only apply to
Sentry.OpenTelemetry, and not toSentry.OpenTelemetry.Exporter?Doesn't the OTLP Exporter also set
SentryOptions.InstrumentertoInstrumenter.OpenTelemetry?Or am I confusing something here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh ... wait ... I do misunderstand
Sentry.OpenTelemetry.Exporterdoesn't start/finish Transactions/Spans, but "only" extracts/injects Sentry's Trace- and Baggage-Headers in order to propagate context ... due to also settingSentryOptions.DisableSentryTracing = true, and theNoOpTransactionclass does not implement theIBaseTracerinterface.