You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(core): Fork scope if custom scope is passed to startSpan (#14900)
Fix unexpected behaviour that would emerge when starting
multiple spans in sequence with `startSpan` when passing on the same
scope. Prior to this change, the second span would be started as the
child span of the first one, because the span set active on the custom
scope was not re-set to the parent span of the first span.
This patch fixes this edge case by also forking the custom scope if it is
passed into `startSpan`.
Copy file name to clipboardExpand all lines: docs/migration/v8-to-v9.md
+10
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,16 @@ In v9, an `undefined` value will be treated the same as if the value is not defi
82
82
83
83
- 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.
84
84
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.
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
+
85
95
### `@sentry/node`
86
96
87
97
- 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.
0 commit comments