-
Notifications
You must be signed in to change notification settings - Fork 215
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
Fix applying the trace
context on events
#888
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #888 +/- ##
==========================================
- Coverage 82.85% 82.82% -0.03%
==========================================
Files 55 55
Lines 4619 4623 +4
==========================================
+ Hits 3827 3829 +2
- Misses 636 637 +1
- Partials 156 157 +1 ☔ View full report in Codecov by Sentry. |
@cleptric This fix is a partially functional solution that fixes the trace context only for transactions. It does not resolve the tracing information for events such as messages, exceptions, or any other attributes related to scope behavior (like breadcrumbs, etc.) based on the starting span setting here https://github.com/getsentry/sentry-go/blob/master/tracing.go#L197-L198. Here is an example of how the following code behaves: // Start the parent transaction
ctx := context.Background()
parentTransaction := sentry.StartTransaction(ctx, "parent-transaction")
// Start the parent transaction span
parentSpan := sentry.StartSpan(parentTransaction.Context(), "parent-span")
parentChildSpan := sentry.StartSpan(parentSpan.Context(), "parent-child-span")
// Capture message that should be attached to "parent-child-span"
sentry.CaptureMessage("Parent child span")
// Finish the "parent-child-span"
parentChildSpan.Finish()
// Capture message that should be attached to "parent-span", but will be attached to the "parent-child-span"
sentry.CaptureMessage("Parent span")
// Finish the "parent span"
parentSpan.Finish()
// Capture message that should be attached to "parent-transaction", but will be attached to the "parent-child-span"
sentry.CaptureMessage("Parent transaction completed")
parentTransaction.Finish() On the right side is the code running with PR #886, and on the left side is the code running with the current PR #888. 2024-10-08.09.41.04.mov |
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.
stamp
Fixes #884
We mistakenly used the scope's span
trace
context as thetrace
context for the transaction. Instead, we now set thetrace
context on the event when the transaction finishes and only use the scope's spantrace
context in case there is notrace
context on the event already.