@@ -2,6 +2,7 @@ import { context, trace, TraceFlags, type Context } from '@opentelemetry/api';
22import type { BasicTracerProvider } from '@opentelemetry/sdk-trace-base' ;
33import type { Scope } from '@sentry/core' ;
44import {
5+ addChildSpanToSpan ,
56 getAsyncContextStrategy ,
67 getCurrentScope ,
78 getIsolationScope ,
@@ -118,6 +119,7 @@ describe('asyncContextStrategy', () => {
118119 dropReason : 'ignored' ,
119120 traceId : parentSpan . spanContext ( ) . traceId ,
120121 } ) ;
122+ addChildSpanToSpan ( parentSpan , ignoredSpan ) ;
121123
122124 context . with ( trace . setSpan ( context . active ( ) , parentSpan ) , ( ) => {
123125 const binding = getAsyncContextStrategy ( getMainCarrier ( ) ) . getTracingChannelBinding ?.( ) ;
@@ -130,18 +132,28 @@ describe('asyncContextStrategy', () => {
130132 parentSpan . end ( ) ;
131133 } ) ;
132134
133- test ( 'tracing channel binding activates a native ignored root span' , ( ) => {
135+ test ( 'tracing channel binding activates a native ignored root span with a remote parent ' , ( ) => {
134136 setNodeOpenTelemetryContextAsyncContextStrategy ( ) ;
135137
138+ const traceId = '12345678901234567890123456789012' ;
139+ const remoteParent = trace . wrapSpanContext ( {
140+ traceId,
141+ spanId : '1234567890123456' ,
142+ traceFlags : TraceFlags . SAMPLED ,
143+ isRemote : true ,
144+ } ) ;
136145 const ignoredSpan = new SentryNonRecordingSpan ( {
137146 dropReason : 'ignored' ,
138- traceId : '12345678901234567890123456789012' ,
147+ traceId,
139148 } ) ;
140- const binding = getAsyncContextStrategy ( getMainCarrier ( ) ) . getTracingChannelBinding ?.( ) ;
141- const store = binding ?. getStoreWithActiveSpan ( ignoredSpan ) ;
142149
143- expect ( store ) . toBeDefined ( ) ;
144- expect ( trace . getSpan ( store as Context ) ) . toBe ( ignoredSpan ) ;
150+ context . with ( trace . setSpan ( context . active ( ) , remoteParent ) , ( ) => {
151+ const binding = getAsyncContextStrategy ( getMainCarrier ( ) ) . getTracingChannelBinding ?.( ) ;
152+ const store = binding ?. getStoreWithActiveSpan ( ignoredSpan ) ;
153+
154+ expect ( store ) . toBeDefined ( ) ;
155+ expect ( trace . getSpan ( store as Context ) ) . toBe ( ignoredSpan ) ;
156+ } ) ;
145157 } ) ;
146158
147159 test ( 'async scope inheritance' , async ( ) => {
0 commit comments