5
5
using System . Diagnostics ;
6
6
using System . Collections . Generic ;
7
7
using System . Threading . Tasks ;
8
+ using Xunit . Abstractions ;
8
9
9
10
namespace System . CommandLine . Tests
10
11
{
11
12
public class ObservabilityTests
12
13
{
14
+ private readonly ITestOutputHelper log ;
15
+
16
+ public ObservabilityTests ( ITestOutputHelper output )
17
+ {
18
+ log = output ;
19
+ }
13
20
14
21
[ Fact ]
15
22
public void It_creates_activity_spans_for_parsing ( )
@@ -64,7 +71,6 @@ public async Task It_creates_activity_spans_for_invocations()
64
71
command . SetAction ( async ( pr , ctok ) => await Task . FromResult ( 0 ) ) ;
65
72
66
73
var result = await command . Parse ( Array . Empty < string > ( ) ) . InvokeAsync ( ) ;
67
-
68
74
activities
69
75
. Should ( )
70
76
. ContainSingle (
@@ -90,7 +96,10 @@ public async Task It_creates_activity_spans_for_invocation_errors()
90
96
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
91
97
92
98
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
+ }
94
103
activities
95
104
. Should ( )
96
105
. ContainSingle (
@@ -100,7 +109,7 @@ public async Task It_creates_activity_spans_for_invocation_errors()
100
109
&& a . Tags . Any ( t => t . Key == "command" && t . Value == "the-command" )
101
110
&& a . Tags . Any ( t => t . Key == "invoke.type" && t . Value == "async" )
102
111
&& 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" ) ) ;
104
113
}
105
114
106
115
private static List < Activity > SetupListener ( )
0 commit comments