-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(core): Fork scope if custom scope is passed to startSpan
#14900
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
Conversation
size-limit report 📦
|
c864c76
to
52b10a8
Compare
startSpan
startSpan
86ab776
to
162e105
Compare
cc @nicholas-codecov nothing for you to worry about (i.e. your implementation telemetry implementation will work fine with this change) but this is the fix I mentioned that would fix the missing spans in your traces without wrapping them in a |
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.
LGTM! Will you handle startSpanManual
in a separate PR?
Yes! |
This PR fixes unexpected behaviour that would emerge when starting multiple spans in sequence with
startSpan
when passing on the same scope. Prior to this change, the second span would be started as the child span of the first one, because the span set active on the custom scope was not re-set to the parent span of the first span. The reason is that we didn't clean up or restore the previously active span because the custom scope is not forked in contrast to the current scope.In very niche scenarios, this could furthermore lead to only the first span being sent and subsequent spans being discarded because they were being incorrectly considered a child span. Examples for this are the Sentry and CodeCov bundler plugins where we solely rely on
@sentry/core
and a custom client setup. In more conventional setups, using the Node (POTEL) or browser SDKs this probably would have gone unnoticed.This PR fixes this edge case by also forking the custom scope if it is passed into
startSpan
. Since this has implications on the lifetime of other span modifications like setting tags, we consider this a behaviourally breaking change and will not backport it to v8. I adjusted tests to reflect the scope data lifetime. It's worth noting though, that in POTEL SDKs we already forked custom scope, so this PR further aligns behaviour.This came up while reviewing codecov/codecov-javascript-bundler-plugins#224