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

Fix applying the trace context on events #888

Merged
merged 3 commits into from
Oct 14, 2024
Merged

Fix applying the trace context on events #888

merged 3 commits into from
Oct 14, 2024

Conversation

cleptric
Copy link
Member

@cleptric cleptric commented Oct 7, 2024

Fixes #884

We mistakenly used the scope's span trace context as the trace context for the transaction. Instead, we now set the trace context on the event when the transaction finishes and only use the scope's span trace context in case there is no trace context on the event already.

@cleptric cleptric self-assigned this Oct 7, 2024
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.82%. Comparing base (951e363) to head (60da897).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
scope.go 50.00% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

@Darevski
Copy link
Contributor

Darevski commented Oct 8, 2024

@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.
In #888 all sentry events are related to the parent-child-span, but its wrong.

2024-10-08.09.41.04.mov

Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

stamp

@cleptric cleptric merged commit 2935366 into master Oct 14, 2024
24 of 25 checks passed
@cleptric cleptric deleted the fix-twp branch October 14, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Missing Trace Root" on v0.29
4 participants