@@ -10,6 +10,12 @@ open Xunit.Abstractions
10
10
11
11
open TestFramework
12
12
13
+ open FSharp.Compiler .Diagnostics
14
+
15
+ open OpenTelemetry
16
+ open OpenTelemetry.Resources
17
+ open OpenTelemetry.Trace
18
+
13
19
/// Disables custom internal parallelization added with XUNIT_EXTRAS.
14
20
/// Execute test cases in a class or a module one by one instead of all at once. Allow other collections to run simultaneously.
15
21
[<AttributeUsage( AttributeTargets.Class ||| AttributeTargets.Method, AllowMultiple = false ) >]
@@ -45,6 +51,7 @@ type ConsoleCapturingTestRunner(test, messageBus, testClass, constructorArgument
45
51
override this.InvokeTestAsync ( aggregator : ExceptionAggregator ) =
46
52
task {
47
53
use capture = new TestConsole.ExecutionCapture()
54
+ use _ = Activity.start test.DisplayName [ ]
48
55
let! executionTime = this.BaseInvokeTestMethodAsync aggregator
49
56
let output =
50
57
seq {
@@ -139,9 +146,24 @@ type FSharpXunitFramework(sink: IMessageSink) =
139
146
log " FSharpXunitFramework with XUNIT_EXTRAS installing TestConsole redirection"
140
147
TestConsole.install()
141
148
149
+ // TODO: Currently does not work with Desktop .NET Framework. Upcoming OpenTelemetry 1.11.0 may change it.
150
+ #if NETCOREAPP
151
+ let traceProvider =
152
+ Sdk.CreateTracerProviderBuilder()
153
+ .AddSource( ActivityNames.FscSourceName)
154
+ .SetResourceBuilder(
155
+ ResourceBuilder.CreateDefault() .AddService( serviceName= " F#" , serviceVersion = " 1.0.0" ))
156
+ .AddOtlpExporter()
157
+ .Build()
158
+ #endif
159
+
142
160
interface IDisposable with
143
161
member _.Dispose () =
144
162
cleanUpTemporaryDirectoryOfThisTestRun ()
163
+ #if NETCOREAPP
164
+ traceProvider.ForceFlush() |> ignore
165
+ traceProvider.Dispose()
166
+ #endif
145
167
base .Dispose()
146
168
147
169
override this.CreateDiscoverer ( assemblyInfo ) =
0 commit comments