@@ -370,9 +370,13 @@ function getAcs(): AsyncContextStrategy {
370
370
return getAsyncContextStrategy ( carrier ) ;
371
371
}
372
372
373
- function _startRootSpan ( spanArguments : SentrySpanArguments , scope : Scope , parentSampled ?: boolean ) : SentrySpan {
373
+ function _startRootSpan (
374
+ spanArguments : SentrySpanArguments ,
375
+ scope : Scope ,
376
+ parentSampled ?: boolean ,
377
+ ) : SentrySpan | SentryNonRecordingSpan {
374
378
const client = getClient ( ) ;
375
- const options : Partial < ClientOptions > = ( client && client . getOptions ( ) ) || { } ;
379
+ const options : Partial < ClientOptions > = client ? .getOptions ( ) || { } ;
376
380
377
381
const { name = '' , attributes } = spanArguments ;
378
382
const [ sampled , sampleRate ] = scope . getScopeData ( ) . sdkProcessingMetadata [ SUPPRESS_TRACING_KEY ]
@@ -387,14 +391,16 @@ function _startRootSpan(spanArguments: SentrySpanArguments, scope: Scope, parent
387
391
} ,
388
392
} ) ;
389
393
390
- const rootSpan = new SentrySpan ( {
391
- ...spanArguments ,
392
- attributes : {
393
- [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'custom' ,
394
- ...spanArguments . attributes ,
395
- } ,
396
- sampled,
397
- } ) ;
394
+ const rootSpan = sampled
395
+ ? new SentrySpan ( {
396
+ ...spanArguments ,
397
+ attributes : {
398
+ [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'custom' ,
399
+ ...spanArguments . attributes ,
400
+ } ,
401
+ sampled,
402
+ } )
403
+ : new SentryNonRecordingSpan ( { traceId : spanArguments . traceId } ) ;
398
404
399
405
if ( ! sampled && client ) {
400
406
DEBUG_BUILD && logger . log ( '[Tracing] Discarding root span because its trace was not chosen to be sampled.' ) ;
0 commit comments