-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[v8] Browser & active spans #10944
Comments
s1gr1d
added a commit
that referenced
this issue
Mar 19, 2024
mydea
added a commit
that referenced
this issue
Apr 10, 2024
You can opt out of this by setting `parentSpanIsAlwaysRootSpan=false` in your client options. This means that in browser, any span will always be added to the active root span, not the active span. This way, we should be able to avoid problems with execution contexts etc. Closes #10944
cadesalaberry
pushed a commit
to cadesalaberry/sentry-javascript
that referenced
this issue
Apr 19, 2024
For showing current behavior with using differently timed async spans in browser ref getsentry#10986 ref getsentry#10944
cadesalaberry
pushed a commit
to cadesalaberry/sentry-javascript
that referenced
this issue
Apr 19, 2024
…entry#10986) You can opt out of this by setting `parentSpanIsAlwaysRootSpan=false` in your client options. This means that in browser, any span will always be added to the active root span, not the active span. This way, we should be able to avoid problems with execution contexts etc. Closes getsentry#10944
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Node & edge environments, we use async local storage to ensure we have actual isolation for active spans. So the following code:
Will actually work and log
outer 1
andouter 2
correctly.However, in browser (and theoretically any other environment where we don't have a custom Async Context Strategy (ACS)), this will not necessarily work as expected, because we cannot isolate the execution contexts, thus they may leak out into other parts of the code - so the above code may print out different spans, depending on what is globally active at the time.
This was always the case - also with the old performance APIs - but with the new APIs it is much easier to accidentally do this.
Previously, if you just did
getActiveTransaction().startChild()
or similar, stuff would work just fine - you had to actually go and dogetCurrentScope().setSpan(span)
to get potentially inconsistent behavior.Since now
startSpan
(andstartSpanManual
) are the "default" APIs proposed for these things, I feel like maybe this will become a bigger problem in v8, and we should address this somehow.Some options I see:
startSpan
andstartSpanManual
not actually update the active span. This would mean that the only active spans would ever be ones that we create (? or we provide a separate API/option for that...?), so pageload/navigation spans... we'd need some story for manual page load etc. instrumentation though as well 🤔Basically, I think it would be safer to say that in browser we don't have a nested span structure, but we only have a single active span (pageload, navigation, ...) and all other spans are children of that. That of course also has downsides, but to me less severe ones. But 🤷 there is no ideal solution here 😬
The text was updated successfully, but these errors were encountered: