-
-
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
feat(core): Ensure startSpan
& startSpanManual
fork scope
#9955
Conversation
size-limit report 📦
|
} | ||
|
||
if (isThenable(maybePromiseResult)) { | ||
Promise.resolve(maybePromiseResult).then( |
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.
If it's thenable, why do we have Promise.resolve in here?
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.
@Lms24 is fixing this right now.
|
||
return maybePromiseResult; | ||
if (isThenable(maybePromiseResult)) { | ||
Promise.resolve(maybePromiseResult).then(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.
Promise.resolve(maybePromiseResult).then(undefined, () => { | |
Promise.resolve(maybePromiseResult).catch(() => { |
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.
Let's not change things unrelated to this PR.
}); | ||
|
||
expect(_span).toBeDefined(); | ||
expect(_span?.endTimestamp).toBeDefined(); |
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.
expect(_span?.endTimestamp).toBeDefined(); | |
expect(_span.endTimestamp).toBeDefined(); |
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.
sadly, TS still complains about this even if I check for defined-ness above 😬
expect(span).toBeDefined(); | ||
expect(span?.endTimestamp).toBeUndefined(); | ||
|
||
span?.finish(); |
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.
span?.finish(); | |
span.finish(); |
|
||
span?.finish(); | ||
|
||
expect(span?.endTimestamp).toBeDefined(); |
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.
expect(span?.endTimestamp).toBeDefined(); | |
expect(span.endTimestamp).toBeDefined(); |
|
||
expect(initialScope.getSpan()).toBeUndefined(); | ||
|
||
span?.finish(); |
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.
span?.finish(); | |
span.finish(); |
@lforst noticed that currently
startSpan()
andstartSpanManual
do not fork the scope, which is also a slightly different behavior than it is in OTEL.This adjusts this to better align, so that we always fork a scope. We also always leave the span on the forked scope, even after it was finished.
In a follow up, we can thus also get rid of the
finish
callback arg forstartSpanManual
, as users can/should simply callspan.end()
themselves then.