Skip to content

Commit d29a0a6

Browse files
committed
enable otel in tests on demand
1 parent d0c5ca2 commit d29a0a6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1616
<!--Extra xUnit customizations, not required for the test suite to work, but can speed up local test runs and help with debugging.-->
1717
<DefineConstants>XUNIT_EXTRAS</DefineConstants>
18+
<!--Uncomment to enable OpenTelemetry instrumentation for the test suite.-->
19+
<!--<DefineConstants>OTEL</DefineConstants>-->
1820
</PropertyGroup>
1921

2022
<PropertyGroup Condition="'$(BUILDING_USING_DOTNET)' == 'true'">

tests/FSharp.Test.Utilities/XunitHelpers.fs

+5
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,24 @@ type FSharpXunitFramework(sink: IMessageSink) =
155155
AssemblyResolver.addResolver ()
156156
#endif
157157

158+
// Uncomment definition in project file to enable OpenTelemetry tracing.
159+
#if OTEL
158160
let traceProvider =
159161
Sdk.CreateTracerProviderBuilder()
160162
.AddSource(ActivityNames.FscSourceName)
161163
.SetResourceBuilder(
162164
ResourceBuilder.CreateDefault().AddService(serviceName="F#", serviceVersion = "1.0.0"))
163165
.AddOtlpExporter()
164166
.Build()
167+
#endif
165168

166169
interface IDisposable with
167170
member _.Dispose() =
168171
cleanUpTemporaryDirectoryOfThisTestRun ()
172+
#if OTEL
169173
traceProvider.ForceFlush() |> ignore
170174
traceProvider.Dispose()
175+
#endif
171176
base.Dispose()
172177

173178
// Group test run under single activity, to make traces more readable.

0 commit comments

Comments
 (0)