@@ -15,6 +15,7 @@ import {
1515 logger ,
1616 nodeStackLineParser ,
1717 stackParserFromStackParserOptions ,
18+ tracingContextFromHeaders ,
1819 uuid4 ,
1920} from '@sentry/utils' ;
2021
@@ -301,21 +302,9 @@ function startSessionTracking(): void {
301302function updateScopeFromEnvVariables ( ) : void {
302303 const sentryUseEnvironment = ( process . env . SENTRY_USE_ENVIRONMENT || '' ) . toLowerCase ( ) ;
303304 if ( ! [ 'false' , 'n' , 'no' , 'off' , '0' ] . includes ( sentryUseEnvironment ) ) {
304- const sentryTraceEnv = process . env . SENTRY_TRACE || '' ;
305+ const sentryTraceEnv = process . env . SENTRY_TRACE ;
305306 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 ) ;
319308 getCurrentHub ( ) . getScope ( ) . setPropagationContext ( propagationContext ) ;
320309 }
321310}
0 commit comments