-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if span is still open in ScopeManager.active
The ScopeManager.active and ScopeManager.root function returned spans as active or as a valid root span when they were closed. This is a different state from a NoopSpan where no span has been active. When a span closes it doesn't necessary reset the scope (remove the executionAsyncId) from the scopes and roots maps on the ScopeManager. Keep track if a span is open or not by keeping an `open` attribute on the Span that is set to `false` whenever `Span.close()` is called. We should not rely on the `isObject() => { closed: true }`, because that's a more intensive operation (creating and parsing a JSON object) and we should only use it for testing. With the new `Span.isOpen()` function we can check if the Span is stil open and only return it if that's the case. If it's not, also immediately remove it from the ScopeManager's maps. I've updated the `createRootSpan` test to close the span after the assertions, otherwise it will now fail because of returning undefined. We ran into this issue occurring in PR #669. It will not necessarily fix the issue we ran into there, but it's an issue nonetheless.
- Loading branch information
Showing
8 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
packages/nodejs/.changesets/fix-active-span-returning-a-closed-span.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
bump: "patch" | ||
type: "fix" | ||
--- | ||
|
||
Fix the `ScopeManager.active()` function returning closed spans. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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