Skip to content

Commit a07377e

Browse files
authored
fix(node): Ensure DSC on envelope header uses root span (#11683)
Fixes an oversight from #11628, which was found in the example app.
1 parent c45f82a commit a07377e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span/scenario.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ Sentry.init({
1111
});
1212

1313
Sentry.startSpan({ name: 'test span' }, () => {
14-
Sentry.captureException(new Error('foo'));
14+
Sentry.startSpan({ name: 'test inner span' }, () => {
15+
Sentry.captureException(new Error('foo'));
16+
});
1517
});

packages/opentelemetry/src/setupEventContextTrace.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ export function setupEventContextTrace(client: Client): void {
2828
...event.contexts,
2929
};
3030

31+
const rootSpan = getRootSpan(span);
32+
3133
event.sdkProcessingMetadata = {
32-
dynamicSamplingContext: getDynamicSamplingContextFromSpan(span),
34+
dynamicSamplingContext: getDynamicSamplingContextFromSpan(rootSpan),
3335
...event.sdkProcessingMetadata,
3436
};
3537

36-
const rootSpan = getRootSpan(span);
3738
const transactionName = spanHasName(rootSpan) ? rootSpan.name : undefined;
3839
if (transactionName && !event.transaction) {
3940
event.transaction = transactionName;

0 commit comments

Comments
 (0)