@@ -3,7 +3,7 @@ import { dropUndefinedKeys } from '@sentry/utils';
3
3
4
4
import { DEFAULT_ENVIRONMENT } from '../constants' ;
5
5
import { 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' ;
7
7
import { spanIsSampled , spanToJSON } from '../utils/spanUtils' ;
8
8
9
9
/**
@@ -15,7 +15,6 @@ export function getDynamicSamplingContextFromClient(
15
15
trace_id : string ,
16
16
client : Client ,
17
17
scope ?: Scope ,
18
- emitHook : boolean = true ,
19
18
) : DynamicSamplingContext {
20
19
const options = client . getOptions ( ) ;
21
20
@@ -30,9 +29,7 @@ export function getDynamicSamplingContextFromClient(
30
29
trace_id,
31
30
} ) as DynamicSamplingContext ;
32
31
33
- if ( emitHook ) {
34
- client . emit && client . emit ( 'createDsc' , dsc ) ;
35
- }
32
+ client . emit && client . emit ( 'createDsc' , dsc ) ;
36
33
37
34
return dsc ;
38
35
}
@@ -56,7 +53,7 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<
56
53
}
57
54
58
55
// 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 ( ) ) ;
60
57
61
58
// As long as we use `Transaction`s internally, this should be fine.
62
59
// TODO: We need to replace this with a `getRootSpan(span)` function though
@@ -73,8 +70,8 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<
73
70
return v7FrozenDsc ;
74
71
}
75
72
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 ) {
78
75
dsc . sample_rate = `${ maybeSampleRate } ` ;
79
76
}
80
77
0 commit comments