Skip to content

Commit 86ab776

Browse files
committed
migration node, formatting
1 parent 52b10a8 commit 86ab776

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

docs/migration/v8-to-v9.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ In v9, an `undefined` value will be treated the same as if the value is not defi
8282

8383
- The `getCurrentHub().getIntegration(IntegrationClass)` method will always return `null` in v9. This has already stopped working mostly in v8, because we stopped exposing integration classes. In v9, the fallback behavior has been removed. Note that this does not change the type signature and is thus not technically breaking, but still worth pointing out.
8484

85+
- The `startSpan` behavior was slightly changed if you pass a custom `scope` to the span start options: While in v8, the passed scope was set active directly on the passed scope, in v9, the scope is cloned. This behavior change does not apply to `@sentry/node` where the scope was already cloned. This change was made to ensure that the span only remains active within the callback and to align behavior between `@sentry/node` and all other SDKs. As a result of the change, your span hierarchy should be more accurate. However, be aware that modifying the scope (e.g. set tags) within the `startSpan` callback behaves a bit differently now.
86+
87+
```js
88+
startSpan({ name: 'example', scope: customScope }, () => {
89+
getCurrentScope().setTag('tag-a', 'a'); // this tag will only remain within the callback
90+
// set the tag directly on customScope in addition, if you want to to persist the tag outside of the callback
91+
customScope.setTag('tag-a', 'a');
92+
});
93+
```
94+
8595
### `@sentry/node`
8696

8797
- When `skipOpenTelemetrySetup: true` is configured, `httpIntegration({ spans: false })` will be configured by default. This means that you no longer have to specify this yourself in this scenario. With this change, no spans are emitted once `skipOpenTelemetrySetup: true` is configured, without any further configuration being needed.

packages/core/src/types-hoist/startSpanOptions.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ export interface StartSpanOptions {
99
* If set, start the span on a fork of this scope instead of on the current scope.
1010
* To ensure proper span cleanup, the passed scope is cloned for the duration of the span.
1111
*
12-
* If you want to modify the passed scope inside the callback, be aware that:
13-
* - calling `getCurrentScope()` will return the cloned scope, meaning all modifications
14-
* will be reset once the callback finishes
15-
* - if you want to modify the passed scope and have the changes persist after the callback
16-
* ends, modify the scope directly and don't use `getCurrentScope()`
12+
* If you want to modify the passed scope inside the callback, calling `getCurrentScope()`
13+
* will return the cloned scope, meaning all scope modifications will be reset once the
14+
* callback finishes
15+
*
16+
* If you want to modify the passed scope and have the changes persist after the callback ends,
17+
* modify the scope directly instead of using `getCurrentScope()`
1718
*/
1819
scope?: Scope;
1920

packages/core/test/lib/tracing/trace.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
import { SentryNonRecordingSpan } from '../../../src/tracing/sentryNonRecordingSpan';
2626
import { startNewTrace } from '../../../src/tracing/trace';
2727
import type { Event, Span, StartSpanOptions } from '../../../src/types-hoist';
28-
import { _getSpanForScope, _setSpanForScope } from '../../../src/utils/spanOnScope';
28+
import { _setSpanForScope } from '../../../src/utils/spanOnScope';
2929
import { getActiveSpan, getRootSpan, getSpanDescendants, spanIsSampled } from '../../../src/utils/spanUtils';
3030
import { TestClient, getDefaultTestClientOptions } from '../../mocks/client';
3131

0 commit comments

Comments
 (0)