@@ -2653,4 +2653,90 @@ describe('ignoreSpans (core path, streaming)', () => {
26532653 expect ( spyOnDroppedEvent ) . toHaveBeenCalledTimes ( 1 ) ;
26542654 expect ( spyOnDroppedEvent ) . toHaveBeenCalledWith ( 'ignored' , 'span' ) ;
26552655 } ) ;
2656+
2657+ it ( 'sets ignored segment span onto the scope' , ( ) => {
2658+ const options = getDefaultTestClientOptions ( {
2659+ tracesSampleRate : 1 ,
2660+ traceLifecycle : 'stream' ,
2661+ ignoreSpans : [ 'ignored' ] ,
2662+ } ) ;
2663+ client = new TestClient ( options ) ;
2664+ setCurrentClient ( client ) ;
2665+ client . init ( ) ;
2666+
2667+ startSpan ( { name : 'ignored-segment' } , ignoredSegmentSpan => {
2668+ expect ( ignoredSegmentSpan ) . toBeInstanceOf ( SentryNonRecordingSpan ) ;
2669+ expect ( getActiveSpan ( ) ) . toBe ( ignoredSegmentSpan ) ;
2670+
2671+ startSpan ( { name : 'child' } , ( ) => {
2672+ expect ( getActiveSpan ( ) ) . toBe ( ignoredSegmentSpan ) ;
2673+ } ) ;
2674+ } ) ;
2675+ } ) ;
2676+
2677+ it ( "doesn't set ignored child span onto the scope" , ( ) => {
2678+ const options = getDefaultTestClientOptions ( {
2679+ tracesSampleRate : 1 ,
2680+ traceLifecycle : 'stream' ,
2681+ ignoreSpans : [ 'ignored' ] ,
2682+ } ) ;
2683+ client = new TestClient ( options ) ;
2684+ setCurrentClient ( client ) ;
2685+ client . init ( ) ;
2686+
2687+ startSpan ( { name : 'segment' } , segmentSpan => {
2688+ expect ( getActiveSpan ( ) ) . toBe ( segmentSpan ) ;
2689+
2690+ startSpan ( { name : 'ignored-child' } , ( ) => {
2691+ expect ( getActiveSpan ( ) ) . toBe ( segmentSpan ) ;
2692+
2693+ startSpan ( { name : 'ignored-child-2' } , ( ) => {
2694+ expect ( getActiveSpan ( ) ) . toBe ( segmentSpan ) ;
2695+
2696+ startSpan ( { name : 'normal-child-2' } , normalChild2Span => {
2697+ expect ( getActiveSpan ( ) ) . toBe ( normalChild2Span ) ;
2698+ } ) ;
2699+ } ) ;
2700+
2701+ startSpan ( { name : 'normal-child' } , normalChildSpan => {
2702+ expect ( getActiveSpan ( ) ) . toBe ( normalChildSpan ) ;
2703+ } ) ;
2704+ } ) ;
2705+ } ) ;
2706+ } ) ;
2707+
2708+ it ( "assigns the parent span's trace id to the ignored segment span" , ( ) => {
2709+ const options = getDefaultTestClientOptions ( {
2710+ tracesSampleRate : 1 ,
2711+ traceLifecycle : 'stream' ,
2712+ ignoreSpans : [ 'ignored' ] ,
2713+ } ) ;
2714+ client = new TestClient ( options ) ;
2715+ setCurrentClient ( client ) ;
2716+ client . init ( ) ;
2717+
2718+ startSpan ( { name : 'ignored-segment' } , ignoredSegmentSpan => {
2719+ startSpan ( { name : 'child' } , childSpan => {
2720+ expect ( childSpan . spanContext ( ) . traceId ) . toBe ( ignoredSegmentSpan . spanContext ( ) . traceId ) ;
2721+ } ) ;
2722+ } ) ;
2723+ } ) ;
2724+
2725+ it ( "doesn't set inactive ignored segment spans onto the scope" , ( ) => {
2726+ const options = getDefaultTestClientOptions ( {
2727+ tracesSampleRate : 1 ,
2728+ traceLifecycle : 'stream' ,
2729+ ignoreSpans : [ 'ignored' ] ,
2730+ } ) ;
2731+ client = new TestClient ( options ) ;
2732+ setCurrentClient ( client ) ;
2733+ client . init ( ) ;
2734+
2735+ const span = startInactiveSpan ( { name : 'ignored-segment' } ) ;
2736+ expect ( getActiveSpan ( ) ) . toBeUndefined ( ) ;
2737+
2738+ span . end ( ) ;
2739+
2740+ expect ( getActiveSpan ( ) ) . toBeUndefined ( ) ;
2741+ } ) ;
26562742} ) ;
0 commit comments