55using System . Diagnostics ;
66using System . Collections . Generic ;
77using System . Threading . Tasks ;
8+ using Xunit . Abstractions ;
89
910namespace System . CommandLine . Tests
1011{
1112 public class ObservabilityTests
1213 {
14+ private readonly ITestOutputHelper log ;
15+
16+ public ObservabilityTests ( ITestOutputHelper output )
17+ {
18+ log = output ;
19+ }
1320
1421 [ Fact ]
1522 public void It_creates_activity_spans_for_parsing ( )
@@ -64,7 +71,6 @@ public async Task It_creates_activity_spans_for_invocations()
6471 command . SetAction ( async ( pr , ctok ) => await Task . FromResult ( 0 ) ) ;
6572
6673 var result = await command . Parse ( Array . Empty < string > ( ) ) . InvokeAsync ( ) ;
67-
6874 activities
6975 . Should ( )
7076 . ContainSingle (
@@ -90,7 +96,10 @@ public async Task It_creates_activity_spans_for_invocation_errors()
9096#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
9197
9298 var result = await command . Parse ( Array . Empty < string > ( ) ) . InvokeAsync ( ) ;
93-
99+ foreach ( var x in activities )
100+ {
101+ log . WriteLine ( $ "{ x . DisplayName } ({ x . OperationName } )/{ x . Status } ({ x . Duration } ) - { x . TagObjects } - { string . Join ( "," , x . Events . Select ( ( k ) => $ "{ k . Name } ,{ k . Tags } ") ) } ") ;
102+ }
94103 activities
95104 . Should ( )
96105 . ContainSingle (
@@ -100,7 +109,7 @@ public async Task It_creates_activity_spans_for_invocation_errors()
100109 && a . Tags . Any ( t => t . Key == "command" && t . Value == "the-command" )
101110 && a . Tags . Any ( t => t . Key == "invoke.type" && t . Value == "async" )
102111 && a . TagObjects . Any ( t => t . Key == "exitcode" && ( int ) t . Value == 1 )
103- && a . Baggage . Any ( t => t . Key == "exception" ) ) ;
112+ && a . Events . Any ( t => t . Name == "exception" ) ) ;
104113 }
105114
106115 private static List < Activity > SetupListener ( )
0 commit comments