@@ -15,6 +15,7 @@ import {
15
15
logger ,
16
16
nodeStackLineParser ,
17
17
stackParserFromStackParserOptions ,
18
+ tracingContextFromHeaders ,
18
19
uuid4 ,
19
20
} from '@sentry/utils' ;
20
21
@@ -301,21 +302,9 @@ function startSessionTracking(): void {
301
302
function updateScopeFromEnvVariables ( ) : void {
302
303
const sentryUseEnvironment = ( process . env . SENTRY_USE_ENVIRONMENT || '' ) . toLowerCase ( ) ;
303
304
if ( ! [ 'false' , 'n' , 'no' , 'off' , '0' ] . includes ( sentryUseEnvironment ) ) {
304
- const sentryTraceEnv = process . env . SENTRY_TRACE || '' ;
305
+ const sentryTraceEnv = process . env . SENTRY_TRACE ;
305
306
const baggageEnv = process . env . SENTRY_BAGGAGE ;
306
-
307
- const traceparentData = extractTraceparentData ( sentryTraceEnv ) || { } ;
308
- const { traceId, parentSpanId, parentSampled } = traceparentData ;
309
- const propagationContext : PropagationContext = {
310
- traceId : traceId || uuid4 ( ) ,
311
- spanId : uuid4 ( ) . substring ( 16 ) ,
312
- parentSpanId,
313
- sampled : parentSampled === undefined ? false : parentSampled ,
314
- } ;
315
- const dynamicSamplingContext = baggageHeaderToDynamicSamplingContext ( baggageEnv ) ;
316
- if ( dynamicSamplingContext ) {
317
- propagationContext . dsc = dynamicSamplingContext as DynamicSamplingContext ;
318
- }
307
+ const { propagationContext } = tracingContextFromHeaders ( sentryTraceEnv , baggageEnv ) ;
319
308
getCurrentHub ( ) . getScope ( ) . setPropagationContext ( propagationContext ) ;
320
309
}
321
310
}
0 commit comments