You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there's no great way in browser SDKs to start a (root) span that's
long-running, in the sense of not bound to a callback.
active on the scope, in so far that child spans can be attached to the span.
Of course there are workarounds for this problem (i.e. an async long-running callback that in conjunction with an outside of closure variable to access a span outside the callback) but they're far from intuitive and discoverable for users.
The only way to start a callback-less span at the moment is via Sentry.startInactiveSpan. The consequence of this behaviour is that you can't add child spans to this span, meaning the resulting root span/txn won't have any child spans:
constspan1=Sentry.startInactiveSpan(...);Sentry.startSpan({name: "childOfSpan1",()=>{....}};span1.end();// Result:// span1 is its a root span w/o child span// childOfSpan1 is a root span
Solution Brainstorm
We should export an API from browser SDKs that allows users to set a span active on the current scope. Naming and API details are subject of discussion but a workflow could look something like this:
constspan1=Sentry.startInactiveSpan(...);Sentry.setSpanActiveOnCurrentScope(rootSpan);Sentry.startSpan({name: "childOfSpan1",()=>{....}};span1.end();// Result: // span1 is a root span// childOfSpan1 is a child of span 1 (lol)
Out of scope for this issue
Nested child span hierarchy (currently not reliably possible in browser)
Exporting startIdleSpan
Making a startInactiveSpan- created span become active is the more versatile approach as opposed to idleSpans. We can think about exporting startIdleSpan additionally.
Exporting a shim for this API in Node: We can do this on request but for now let's hold off from it and keep it browser-only. This API should and will never work in Node environments, so the only thing we can do is log a warning and no-op other than that.
The text was updated successfully, but these errors were encountered:
Problem Statement
Currently there's no great way in browser SDKs to start a (root) span that's
Of course there are workarounds for this problem (i.e. an async long-running callback that in conjunction with an outside of closure variable to access a span outside the callback) but they're far from intuitive and discoverable for users.
The only way to start a callback-less span at the moment is via
Sentry.startInactiveSpan
. The consequence of this behaviour is that you can't add child spans to this span, meaning the resulting root span/txn won't have any child spans:Solution Brainstorm
We should export an API from browser SDKs that allows users to set a span active on the current scope. Naming and API details are subject of discussion but a workflow could look something like this:
Out of scope for this issue
startIdleSpan
startInactiveSpan
- created span become active is the more versatile approach as opposed to idleSpans. We can think about exportingstartIdleSpan
additionally.The text was updated successfully, but these errors were encountered: