File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
packages/opentelemetry/src/utils Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -24,18 +24,18 @@ export function getDynamicSamplingContextFromSpan(span: AbstractSpan): Readonly<
24
24
return { } ;
25
25
}
26
26
27
- const dsc = getDynamicSamplingContextFromClient ( span . spanContext ( ) . traceId , client ) ;
28
-
29
27
const traceState = span . spanContext ( ) . traceState ;
30
28
const traceStateDsc = traceState ?. get ( SENTRY_TRACE_STATE_DSC ) ;
31
29
32
- if ( traceStateDsc ) {
33
- const dsc = baggageHeaderToDynamicSamplingContext ( traceStateDsc ) ;
34
- if ( dsc ) {
35
- return dsc ;
36
- }
30
+ // If the span has a DSC, we want it to take precedence
31
+ const dscOnSpan = traceStateDsc ? baggageHeaderToDynamicSamplingContext ( traceStateDsc ) : undefined ;
32
+
33
+ if ( dscOnSpan ) {
34
+ return dscOnSpan ;
37
35
}
38
36
37
+ const dsc = getDynamicSamplingContextFromClient ( span . spanContext ( ) . traceId , client ) ;
38
+
39
39
const attributes = spanHasAttributes ( span ) ? span . attributes : { } ;
40
40
41
41
const sampleRate = attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE ] ;
@@ -51,6 +51,7 @@ export function getDynamicSamplingContextFromSpan(span: AbstractSpan): Readonly<
51
51
dsc . transaction = name ;
52
52
}
53
53
54
+ // TODO: Once we aligned span types, use spanIsSampled() from core instead
54
55
// eslint-disable-next-line no-bitwise
55
56
const sampled = Boolean ( span . spanContext ( ) . traceFlags & TraceFlags . SAMPLED ) ;
56
57
dsc . sampled = String ( sampled ) ;
You can’t perform that action at this time.
0 commit comments