@@ -348,5 +348,35 @@ describe('SentrySampler', () => {
348348 expect ( spyOnDroppedEvent ) . toHaveBeenCalledTimes ( 1 ) ;
349349 expect ( spyOnDroppedEvent ) . toHaveBeenCalledWith ( 'sample_rate' , 'span' ) ;
350350 } ) ;
351+
352+ it ( 'propagates inferred sentry.op onto streamed span attributes' , ( ) => {
353+ const client = new TestClient ( getDefaultTestClientOptions ( { tracesSampleRate : 1 , traceLifecycle : 'stream' } ) ) ;
354+ const sampler = new SentrySampler ( client ) ;
355+
356+ const ctx = context . active ( ) ;
357+ const traceId = generateTraceId ( ) ;
358+ const spanName = 'GET /users' ;
359+ const spanKind = SpanKind . SERVER ;
360+ const spanAttributes = { [ ATTR_HTTP_REQUEST_METHOD ] : 'GET' } ;
361+
362+ const actual = sampler . shouldSample ( ctx , traceId , spanName , spanKind , spanAttributes , undefined ) ;
363+ expect ( actual . decision ) . toBe ( SamplingDecision . RECORD_AND_SAMPLED ) ;
364+ expect ( actual . attributes ?. [ 'sentry.op' ] ) . toBe ( 'http.server' ) ;
365+ } ) ;
366+
367+ it ( 'does not propagate sentry.op for non-streamed spans' , ( ) => {
368+ const client = new TestClient ( getDefaultTestClientOptions ( { tracesSampleRate : 1 } ) ) ;
369+ const sampler = new SentrySampler ( client ) ;
370+
371+ const ctx = context . active ( ) ;
372+ const traceId = generateTraceId ( ) ;
373+ const spanName = 'GET /users' ;
374+ const spanKind = SpanKind . SERVER ;
375+ const spanAttributes = { [ ATTR_HTTP_REQUEST_METHOD ] : 'GET' } ;
376+
377+ const actual = sampler . shouldSample ( ctx , traceId , spanName , spanKind , spanAttributes , undefined ) ;
378+ expect ( actual . decision ) . toBe ( SamplingDecision . RECORD_AND_SAMPLED ) ;
379+ expect ( actual . attributes ?. [ 'sentry.op' ] ) . toBeUndefined ( ) ;
380+ } ) ;
351381 } ) ;
352382} ) ;
0 commit comments