Skip to content

Commit 75134c4

Browse files
committed
fix v7 frozenDSC obtain mechanism
1 parent e0a8e88 commit 75134c4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/core/src/tracing/dynamicSamplingContext.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@ type TransactionWithV7FrozenDsc = Span & { _frozenDynamicSamplingContext?: Dynam
4848
* @returns a dynamic sampling context
4949
*/
5050
export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<DynamicSamplingContext>> {
51+
// As long as we use `Transaction`s internally, this should be fine.
52+
// TODO: We need to replace this with a `getRootSpan(span)` function though
53+
const txn = span.transaction;
54+
5155
// TODO (v8): Remove v7FrozenDsc as a Transaction will no longer have _frozenDynamicSamplingContext
5256
// For now we need to avoid breaking users who directly created a txn with a DSC, where this field is still set.
5357
// @see Transaction class constructor
54-
const v7FrozenDsc = (span as TransactionWithV7FrozenDsc)._frozenDynamicSamplingContext;
58+
const v7FrozenDsc = (txn as TransactionWithV7FrozenDsc)._frozenDynamicSamplingContext;
5559
if (v7FrozenDsc) {
5660
return v7FrozenDsc;
5761
}
@@ -63,7 +67,6 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<
6367

6468
// passing emit=false here to only emit later once the DSC is actually populated
6569
const dsc = getDynamicSamplingContextFromClient(span.traceId, client, getCurrentScope(), false);
66-
const txn = span.transaction;
6770
if (!txn) {
6871
return dsc;
6972
}

0 commit comments

Comments
 (0)