Skip to content

Commit 62f5e22

Browse files
committed
clean up DSC and sampled value logic
fix incorrect `baggage` header in <meta> integration test
1 parent 7197b8c commit 62f5e22

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload-meta/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8" />
55
<meta name="sentry-trace" content="12345678901234567890123456789012-1234567890123456-1" />
66
<meta name="baggage"
7-
content="sentry-trace_id=12345678901234567890123456789012,sentry-sample_rate=0.2,sentry-transaction=my-transaction,sentry-public_key=public,sentry-release=1.0.0,sentry-environment=prod"/>
7+
content="sentry-trace_id=12345678901234567890123456789012,sentry-sample_rate=0.2,sentry-sampled=true,sentry-transaction=my-transaction,sentry-public_key=public,sentry-release=1.0.0,sentry-environment=prod"/>
88
</head>
99
<body>
1010
<button id="errorBtn">Throw Error</button>

dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload-meta/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
const META_TAG_TRACE_ID = '12345678901234567890123456789012';
1111
const META_TAG_PARENT_SPAN_ID = '1234567890123456';
1212
const META_TAG_BAGGAGE =
13-
'sentry-trace_id=12345678901234567890123456789012,sentry-sample_rate=0.2,sentry-transaction=my-transaction,sentry-public_key=public,sentry-release=1.0.0,sentry-environment=prod';
13+
'sentry-trace_id=12345678901234567890123456789012,sentry-sample_rate=0.2,sentry-sampled=true,sentry-transaction=my-transaction,sentry-public_key=public,sentry-release=1.0.0,sentry-environment=prod';
1414

1515
sentryTest(
1616
'create a new trace for a navigation after the <meta> tag pageload trace',

packages/browser/src/tracing/browserTracingIntegration.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
getIsolationScope,
1919
getRootSpan,
2020
registerSpanErrorInstrumentation,
21-
spanIsSampled,
2221
spanToJSON,
2322
startIdleSpan,
2423
withScope,
@@ -298,10 +297,13 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
298297
const scope = getCurrentScope();
299298
const oldPropagationContext = scope.getPropagationContext();
300299

300+
const newDsc = oldPropagationContext.dsc || getDynamicSamplingContextFromSpan(span);
301+
const newDscSampled = newDsc.sampled === 'true' ? true : newDsc.sampled === 'false' ? false : undefined;
302+
301303
const newPropagationContext = {
302304
...oldPropagationContext,
303-
sampled: oldPropagationContext.sampled !== undefined ? oldPropagationContext.sampled : spanIsSampled(span),
304-
dsc: oldPropagationContext.dsc || getDynamicSamplingContextFromSpan(span),
305+
sampled: newDscSampled,
306+
dsc: newDsc,
305307
};
306308

307309
scope.setPropagationContext(newPropagationContext);

0 commit comments

Comments
 (0)