@@ -3,7 +3,7 @@ import { dropUndefinedKeys } from '@sentry/utils';
33
44import { DEFAULT_ENVIRONMENT } from '../constants' ;
55import { getClient , getCurrentScope } from '../exports' ;
6- import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes' ;
6+ import { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE , SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes' ;
77import { spanIsSampled , spanToJSON } from '../utils/spanUtils' ;
88
99/**
@@ -15,7 +15,6 @@ export function getDynamicSamplingContextFromClient(
1515 trace_id : string ,
1616 client : Client ,
1717 scope ?: Scope ,
18- emitHook : boolean = true ,
1918) : DynamicSamplingContext {
2019 const options = client . getOptions ( ) ;
2120
@@ -30,9 +29,7 @@ export function getDynamicSamplingContextFromClient(
3029 trace_id,
3130 } ) as DynamicSamplingContext ;
3231
33- if ( emitHook ) {
34- client . emit && client . emit ( 'createDsc' , dsc ) ;
35- }
32+ client . emit && client . emit ( 'createDsc' , dsc ) ;
3633
3734 return dsc ;
3835}
@@ -56,7 +53,7 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<
5653 }
5754
5855 // passing emit=false here to only emit later once the DSC is actually populated
59- const dsc = getDynamicSamplingContextFromClient ( spanToJSON ( span ) . trace_id || '' , client , getCurrentScope ( ) , false ) ;
56+ const dsc = getDynamicSamplingContextFromClient ( spanToJSON ( span ) . trace_id || '' , client , getCurrentScope ( ) ) ;
6057
6158 // As long as we use `Transaction`s internally, this should be fine.
6259 // TODO: We need to replace this with a `getRootSpan(span)` function though
@@ -73,8 +70,8 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<
7370 return v7FrozenDsc ;
7471 }
7572
76- const maybeSampleRate = txn . metadata . sampleRate ;
77- if ( maybeSampleRate !== undefined ) {
73+ const maybeSampleRate = txn . attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE ] as number | undefined ;
74+ if ( maybeSampleRate != null ) {
7875 dsc . sample_rate = `${ maybeSampleRate } ` ;
7976 }
8077
0 commit comments