@@ -8,27 +8,18 @@ import {
8
8
baggageHeaderToDynamicSamplingContext ,
9
9
dynamicSamplingContextToSentryBaggageHeader ,
10
10
} from '../utils-hoist/baggage' ;
11
- import { addNonEnumerableProperty , dropUndefinedKeys } from '../utils-hoist/object' ;
11
+ import { dropUndefinedKeys } from '../utils-hoist/object' ;
12
12
import { hasSpansEnabled } from '../utils/hasSpansEnabled' ;
13
13
import { getRootSpan , spanIsSampled , spanToJSON } from '../utils/spanUtils' ;
14
14
import { getCapturedScopesOnSpan } from './utils' ;
15
15
16
- /**
17
- * If you change this value, also update the terser plugin config to
18
- * avoid minification of the object property!
19
- */
20
- const FROZEN_DSC_FIELD = '_frozenDsc' ;
21
-
22
- type SpanWithMaybeDsc = Span & {
23
- [ FROZEN_DSC_FIELD ] ?: Partial < DynamicSamplingContext > | undefined ;
24
- } ;
16
+ const SPAN_TO_DSC_MAP = new WeakMap < Span , Partial < DynamicSamplingContext > > ( ) ;
25
17
26
18
/**
27
19
* Freeze the given DSC on the given span.
28
20
*/
29
21
export function freezeDscOnSpan ( span : Span , dsc : Partial < DynamicSamplingContext > ) : void {
30
- const spanWithMaybeDsc = span as SpanWithMaybeDsc ;
31
- addNonEnumerableProperty ( spanWithMaybeDsc , FROZEN_DSC_FIELD , dsc ) ;
22
+ SPAN_TO_DSC_MAP . set ( span , dsc ) ;
32
23
}
33
24
34
25
/**
@@ -91,7 +82,7 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<
91
82
}
92
83
93
84
// For core implementation, we freeze the DSC onto the span as a non-enumerable property
94
- const frozenDsc = ( rootSpan as SpanWithMaybeDsc ) [ FROZEN_DSC_FIELD ] ;
85
+ const frozenDsc = SPAN_TO_DSC_MAP . get ( rootSpan ) ;
95
86
if ( frozenDsc ) {
96
87
return applyLocalSampleRateToDsc ( frozenDsc ) ;
97
88
}
0 commit comments