feat(core): Ensure startSpan & startSpanManual fork scope#9955
Merged
feat(core): Ensure startSpan & startSpanManual fork scope#9955
startSpan & startSpanManual fork scope#9955Conversation
Contributor
size-limit report 📦
|
anonrig
reviewed
Dec 21, 2023
| } | ||
|
|
||
| if (isThenable(maybePromiseResult)) { | ||
| Promise.resolve(maybePromiseResult).then( |
Contributor
There was a problem hiding this comment.
If it's thenable, why do we have Promise.resolve in here?
|
|
||
| return maybePromiseResult; | ||
| if (isThenable(maybePromiseResult)) { | ||
| Promise.resolve(maybePromiseResult).then(undefined, () => { |
Contributor
There was a problem hiding this comment.
Suggested change
| Promise.resolve(maybePromiseResult).then(undefined, () => { | |
| Promise.resolve(maybePromiseResult).catch(() => { |
Contributor
There was a problem hiding this comment.
Let's not change things unrelated to this PR.
| }); | ||
|
|
||
| expect(_span).toBeDefined(); | ||
| expect(_span?.endTimestamp).toBeDefined(); |
Contributor
There was a problem hiding this comment.
Suggested change
| expect(_span?.endTimestamp).toBeDefined(); | |
| expect(_span.endTimestamp).toBeDefined(); |
Member
Author
There was a problem hiding this comment.
sadly, TS still complains about this even if I check for defined-ness above 😬
| expect(span).toBeDefined(); | ||
| expect(span?.endTimestamp).toBeUndefined(); | ||
|
|
||
| span?.finish(); |
Contributor
There was a problem hiding this comment.
Suggested change
| span?.finish(); | |
| span.finish(); |
|
|
||
| span?.finish(); | ||
|
|
||
| expect(span?.endTimestamp).toBeDefined(); |
Contributor
There was a problem hiding this comment.
Suggested change
| expect(span?.endTimestamp).toBeDefined(); | |
| expect(span.endTimestamp).toBeDefined(); |
|
|
||
| expect(initialScope.getSpan()).toBeUndefined(); | ||
|
|
||
| span?.finish(); |
Contributor
There was a problem hiding this comment.
Suggested change
| span?.finish(); | |
| span.finish(); |
lforst
approved these changes
Dec 21, 2023
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@lforst noticed that currently
startSpan()andstartSpanManualdo 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
finishcallback arg forstartSpanManual, as users can/should simply callspan.end()themselves then.