-
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.
Don't restore the root span for withContext
The ScopeManager.withContext only temporary sets the current active span. It then restores the active span afterwards. But it also restores the root span, even though that should not have changed. At least not by anything we've done in this withContext function. If the user has set another rootSpan, that is their decision, but it's not up to us to restore it.
- Loading branch information
Showing
3 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
....changesets/do-not-restore-root-span-after-withcontext-callback-has-finished.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,16 @@ | ||
--- | ||
bump: "patch" | ||
type: "change" | ||
--- | ||
|
||
Do not restore root span after `withSpan` callback has finished. Previously the root span was restored to the original root span before the `withSpan` helper was called. This has been changed, because the `withSpan` helper is only about changing the active span, not the root span. If a new root span has been set within a `withSpan` helper callback, the root span will no longer be restored. We recommend setting a new root span before calling `withSpan` instead. | ||
|
||
```js | ||
const rootSpan = tracer.rootSpan() | ||
const span = tracer.createSpan(...) | ||
tracer.withSpan(span, function(span) { | ||
tracer.createRootSpan(...) | ||
}); | ||
// No longer match | ||
rootSpan != tracer.rootSpan() | ||
``` |
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