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(otel): Overwrite "trace" context in Sentry error #580

Merged
merged 9 commits into from Feb 17, 2023

Conversation

tonyo
Copy link
Member

@tonyo tonyo commented Feb 15, 2023

This patches the following issue: when creating a transaction in the span processor, we later overwrite its SpanID/TraceID. The problem is, the trace context is also set on the scope when the span is started:

hubFromContext(ctx).Scope().SetContext("trace", span.traceContext().Map())

...which leads to broken error-transaction linking.

So ultimately we need to either/or:

  1. Pass additional SpanOptions to StartTransaction that set the right SpanID/TraceID right away
  2. Overwrite the trace context later.

Here I'm taking approach 2 because it's easier, but generally speaking I believe we should review setting trace context (and a few other tracing related things) on the scope.

@tonyo tonyo requested a review from cleptric February 15, 2023 15:24
@tonyo tonyo self-assigned this Feb 15, 2023
@tonyo tonyo added Topic: OpenTelemetry Issue/PR related to OpenTelemetry integration Status: In Progress labels Feb 15, 2023
@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Base: 79.08% // Head: 78.98% // Decreases project coverage by -0.10% ⚠️

Coverage data is based on head (975424e) compared to base (7de80f2).
Patch coverage: 40.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #580      +/-   ##
==========================================
- Coverage   79.08%   78.98%   -0.10%     
==========================================
  Files          38       38              
  Lines        3859     3860       +1     
==========================================
- Hits         3052     3049       -3     
- Misses        705      708       +3     
- Partials      102      103       +1     
Impacted Files Coverage Δ
otel/event_processor.go 58.33% <40.00%> (-28.63%) ⬇️
stacktrace.go 83.65% <0.00%> (+1.44%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

https://github.com/getsentry/sentry-go/blob/master/scope.go#L359-L374

Let's remove the logic in StartSpan and set the trace context in scope.ApplyToEvent() instead.

@tonyo
Copy link
Member Author

tonyo commented Feb 16, 2023

@cleptric Not entirely sure what you're suggesting, but it sounds larger/riskier than what was initially planned for this PR. Can you open an issue and explain your idea there please?
And this PR will at least fix things for specific OTel use case.

@tonyo tonyo merged commit 297d2c2 into master Feb 17, 2023
@tonyo tonyo deleted the tonyo-fix-overwrite-trace-otel-error branch February 17, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Topic: OpenTelemetry Issue/PR related to OpenTelemetry integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants