-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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(tracing): Ensure you can pass null
as parentSpan
in startSpan*
#12928
Conversation
size-limit report 📦
|
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.
Looking good to me generally, just had a question
@@ -157,7 +157,7 @@ export function startInactiveSpan(options: StartSpanOptions): Span { | |||
// If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan` | |||
const wrapper = options.scope | |||
? (callback: () => Span) => withScope(options.scope, callback) | |||
: customParentSpan | |||
: customParentSpan !== undefined |
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.
hmm I'm not sure I understand the PR description correctly but to me it looks like we're changing 2 things in this PR:
- make
options.parentSpan
acceptnull
. This sounds fine to me, given we're aligning our public API better - call
withActiveSpan(null,...)
in caseparentSpan
isnull
. Is this necessary? Shouldn't the behaviour be identical to simply invoking thecallback
?
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.
no, it is important to call withActiveSpan
in this case - if you pass null
, the meaning is start this span as a root span without a parent
, while undefined
means the default behavior (the parent is the current active span). Does that make sense?
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.
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.
missed this, thx for explaining!
Noticed this while writing docs, this makes this a bit harder to understand. With this change you can say that
parentSpan
behaves the same and accepts the same aswithActiveSpan
.See getsentry/sentry-docs#10729