@@ -37,8 +37,13 @@ public void W3CTraceContextTestSuiteAsync(string value)
37
37
{
38
38
// configure SDK
39
39
using var tracerProvider = Sdk . CreateTracerProviderBuilder ( )
40
- . AddAspNetCoreInstrumentation ( )
41
- . Build ( ) ;
40
+ . AddAspNetCoreInstrumentation ( )
41
+ . Build ( ) ;
42
+
43
+ #if NET10_0_OR_GREATER
44
+ // See https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/10.0/default-trace-context-propagator
45
+ System . Diagnostics . DistributedContextPropagator . Current = System . Diagnostics . DistributedContextPropagator . CreatePreW3CPropagator ( ) ;
46
+ #endif
42
47
43
48
var builder = WebApplication . CreateBuilder ( ) ;
44
49
using var app = builder . Build ( ) ;
@@ -68,12 +73,23 @@ public void W3CTraceContextTestSuiteAsync(string value)
68
73
69
74
app . RunAsync ( "http://localhost:5000/" ) ;
70
75
71
- string result = RunCommand ( "python" , "trace-context/test/test.py http://localhost:5000/" ) ;
76
+ ( var stdout , var stderr ) = RunCommand ( "python" , "-W ignore trace-context/test/test.py http://localhost:5000/" ) ;
72
77
73
78
// Assert
74
- string lastLine = ParseLastLine ( result ) ;
79
+ // TODO: after W3C Trace Context test suite passes, it might go in standard output
80
+ string lastLine = ParseLastLine ( stderr ) ;
81
+
82
+ this . output . WriteLine ( "[stderr]" + stderr ) ;
83
+ this . output . WriteLine ( "[stdout]" + stdout ) ;
84
+ this . output . WriteLine ( "[result]" + lastLine ) ;
85
+
86
+ Console . WriteLine ( "[stderr]" + stderr ) ;
87
+ Console . WriteLine ( "[stdout]" + stdout ) ;
88
+ Console . WriteLine ( "[result]" + lastLine ) ;
75
89
76
- this . output . WriteLine ( "result:" + result ) ;
90
+ Thread . Sleep ( 5_000 ) ;
91
+
92
+ this . output . WriteLine ( "DONE" ) ;
77
93
78
94
// Assert on the last line
79
95
Assert . StartsWith ( "OK" , lastLine , StringComparison . Ordinal ) ;
@@ -82,9 +98,10 @@ public void W3CTraceContextTestSuiteAsync(string value)
82
98
public void Dispose ( )
83
99
{
84
100
this . httpClient . Dispose ( ) ;
101
+ Thread . Sleep ( 5_000 ) ;
85
102
}
86
103
87
- private static string RunCommand ( string command , string args )
104
+ private static ( string StdOut , string StdErr ) RunCommand ( string command , string args )
88
105
{
89
106
using var proc = new Process
90
107
{
@@ -101,10 +118,12 @@ private static string RunCommand(string command, string args)
101
118
} ;
102
119
proc . Start ( ) ;
103
120
104
- // TODO: after W3C Trace Context test suite passes, it might go in standard output
105
- var results = proc . StandardError . ReadToEnd ( ) ;
121
+ var stdout = proc . StandardOutput . ReadToEnd ( ) ;
122
+ var stderr = proc . StandardError . ReadToEnd ( ) ;
123
+
106
124
proc . WaitForExit ( ) ;
107
- return results ;
125
+
126
+ return ( stdout , stderr ) ;
108
127
}
109
128
110
129
private static string ParseLastLine ( string output )
0 commit comments