@@ -11,14 +11,15 @@ import type { DynamicSamplingContext } from '../types-hoist/envelope';
1111import type { ClientOptions } from '../types-hoist/options' ;
1212import type { SentrySpanArguments , Span , SpanTimeInput } from '../types-hoist/span' ;
1313import type { StartSpanOptions } from '../types-hoist/startSpanOptions' ;
14+ import { baggageHeaderToDynamicSamplingContext } from '../utils/baggage' ;
1415import { debug } from '../utils/debug-logger' ;
1516import { handleCallbackErrors } from '../utils/handleCallbackErrors' ;
1617import { hasSpansEnabled } from '../utils/hasSpansEnabled' ;
1718import { parseSampleRate } from '../utils/parseSampleRate' ;
1819import { generateTraceId } from '../utils/propagationContext' ;
1920import { _getSpanForScope , _setSpanForScope } from '../utils/spanOnScope' ;
2021import { addChildSpanToSpan , getRootSpan , spanIsSampled , spanTimeInputToSeconds , spanToJSON } from '../utils/spanUtils' ;
21- import { propagationContextFromHeaders } from '../utils/tracing' ;
22+ import { propagationContextFromHeaders , shouldContinueTrace } from '../utils/tracing' ;
2223import { freezeDscOnSpan , getDynamicSamplingContextFromSpan } from './dynamicSamplingContext' ;
2324import { logSpanStart } from './logSpans' ;
2425import { sampleSpan } from './sampling' ;
@@ -216,6 +217,12 @@ export const continueTrace = <V>(
216217
217218 const { sentryTrace, baggage } = options ;
218219
220+ const client = getClient ( ) ;
221+ const incomingDsc = baggageHeaderToDynamicSamplingContext ( baggage ) ;
222+ if ( client && ! shouldContinueTrace ( client , incomingDsc ?. org_id ) ) {
223+ return startNewTrace ( callback ) ;
224+ }
225+
219226 return withScope ( scope => {
220227 const propagationContext = propagationContextFromHeaders ( sentryTrace , baggage ) ;
221228 scope . setPropagationContext ( propagationContext ) ;
0 commit comments