@@ -459,6 +459,88 @@ public void OnEnd_FinishesTransaction()
459
459
}
460
460
}
461
461
462
+ [ Fact ]
463
+ public void OnEnd_FilteredTransaction_DoesNotFinishTransaction ( )
464
+ {
465
+ // Arrange
466
+ _fixture . Options . Instrumenter = Instrumenter . OpenTelemetry ;
467
+ var sut = _fixture . GetSut ( ) ;
468
+
469
+ var parent = Tracer . StartActivity ( "transaction" ) ! ;
470
+ sut . OnStart ( parent ) ;
471
+
472
+ var data = Tracer . StartActivity ( "test operation" , kind : ActivityKind . Internal ) ! ;
473
+ data . DisplayName = "test display name" ;
474
+ sut . OnStart ( data ) ;
475
+
476
+ FilterActivity ( parent ) ;
477
+
478
+ sut . _map . TryGetValue ( parent . SpanId , out var span ) ;
479
+
480
+ // Act
481
+ sut . OnEnd ( data ) ;
482
+ sut . OnEnd ( parent ) ;
483
+
484
+ // Assert
485
+ if ( span is not TransactionTracer transaction )
486
+ {
487
+ Assert . Fail ( "Span is not a transaction tracer" ) ;
488
+ return ;
489
+ }
490
+
491
+ using ( new AssertionScope ( ) )
492
+ {
493
+ transaction . EndTimestamp . Should ( ) . BeNull ( ) ;
494
+ transaction . Status . Should ( ) . BeNull ( ) ;
495
+ }
496
+ }
497
+
498
+ [ Fact ]
499
+ public void OnEnd_FilteredSpan_RemovesSpan ( )
500
+ {
501
+ // Arrange
502
+ _fixture . Options . Instrumenter = Instrumenter . OpenTelemetry ;
503
+ var sut = _fixture . GetSut ( ) ;
504
+
505
+ var parent = Tracer . StartActivity ( "transaction" ) ! ;
506
+ sut . OnStart ( parent ) ;
507
+
508
+ var data = Tracer . StartActivity ( "test operation" , kind : ActivityKind . Internal ) ! ;
509
+ data . DisplayName = "test display name" ;
510
+ sut . OnStart ( data ) ;
511
+
512
+ FilterActivity ( data ) ;
513
+
514
+ sut . _map . TryGetValue ( parent . SpanId , out var parentSpan ) ;
515
+ sut . _map . TryGetValue ( data . SpanId , out var childSpan ) ;
516
+
517
+ // Act
518
+ sut . OnEnd ( data ) ;
519
+ sut . OnEnd ( parent ) ;
520
+
521
+ // Assert
522
+ if ( parentSpan is not TransactionTracer transaction )
523
+ {
524
+ Assert . Fail ( "parentSpan is not a transaction tracer" ) ;
525
+ return ;
526
+ }
527
+ if ( childSpan is not SpanTracer span )
528
+ {
529
+ Assert . Fail ( "span is not a span tracer" ) ;
530
+ return ;
531
+ }
532
+
533
+ using ( new AssertionScope ( ) )
534
+ {
535
+ span . EndTimestamp . Should ( ) . BeNull ( ) ;
536
+ span . Status . Should ( ) . BeNull ( ) ;
537
+
538
+ transaction . EndTimestamp . Should ( ) . NotBeNull ( ) ;
539
+ transaction . Status . Should ( ) . Be ( SpanStatus . Ok ) ;
540
+ transaction . Spans . Should ( ) . BeEmpty ( ) ;
541
+ }
542
+ }
543
+
462
544
[ Theory ]
463
545
[ InlineData ( OtelSemanticConventions . AttributeUrlFull ) ]
464
546
[ InlineData ( OtelSemanticConventions . AttributeHttpUrl ) ]
0 commit comments