Microsoft.Testing.Extensions.OpenTelemetry
2.4.0
Prefix Reserved
dotnet add package Microsoft.Testing.Extensions.OpenTelemetry --version 2.4.0
NuGet\Install-Package Microsoft.Testing.Extensions.OpenTelemetry -Version 2.4.0
<PackageReference Include="Microsoft.Testing.Extensions.OpenTelemetry" Version="2.4.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.OpenTelemetry" Version="2.4.0" />
<PackageReference Include="Microsoft.Testing.Extensions.OpenTelemetry" />
paket add Microsoft.Testing.Extensions.OpenTelemetry --version 2.4.0
#r "nuget: Microsoft.Testing.Extensions.OpenTelemetry, 2.4.0"
#:package Microsoft.Testing.Extensions.OpenTelemetry@2.4.0
#addin nuget:?package=Microsoft.Testing.Extensions.OpenTelemetry&version=2.4.0
#tool nuget:?package=Microsoft.Testing.Extensions.OpenTelemetry&version=2.4.0
Microsoft.Testing.Extensions.OpenTelemetry
Microsoft.Testing.Extensions.OpenTelemetry is an extension for Microsoft.Testing.Platform that instruments test execution with OpenTelemetry-compatible traces and metrics.
Microsoft.Testing.Platform is open source. You can find Microsoft.Testing.Extensions.OpenTelemetry code in the microsoft/testfx GitHub repository.
Install the package
dotnet add package Microsoft.Testing.Extensions.OpenTelemetry
About
This package extends Microsoft.Testing.Platform with:
- OpenTelemetry integration: exposes the Microsoft Testing Platform activity source and meter (both named
Microsoft.Testing.Platform) so test execution can be observed via the OpenTelemetry .NET SDK. - Semantic conventions: where an OpenTelemetry convention exists it is used verbatim —
test.case.name,test.case.result.status(upstreampass/fail),test.suite.name,code.function.name,code.file.path,code.line.number,code.stacktrace,error.type, plus anexceptionspan event and anErrorspan status on failures. The pre-existing attribute and instrument names are still emitted by default so existing dashboards keep working; setTESTINGPLATFORM_OTEL_EMIT_LEGACY_ATTRIBUTES=0to drop them. - Platform extensions: OpenTelemetry does not define any
test.*metrics or test-case span conventions (as of semantic conventions 1.43.0), andtest.case.result.statusupstream only definespassandfail. The instruments listed below, the additional result statuses (skipped,error,timeout,cancelled,unknown),cicd.provider.name, and thetest.case.*attributes not listed above are therefore Microsoft.Testing.Platform extensions, deliberately placed in the namespace where an upstream definition would land. - Resource attributes:
AddTestingPlatformResource()describes where the run happened — test assembly, host, OS, runtime — and detects the CI provider, pipeline run, branch and commit (cicd.*/vcs.*) from GitHub Actions, Azure Pipelines, GitLab CI and Jenkins. - Turnkey configuration:
AddOpenTelemetryProviderFromEnvironment()wires instrumentation, resource and an OTLP exporter purely from the standardOTEL_*environment variables, so a run can be exported without writing configuration code. - Trace context propagation: when the process that started the test run publishes a
TRACEPARENTenvironment variable (CI runners,dotnet test, IDEs), the whole run nests under that trace instead of starting an orphan one. - Lifecycle management: ties the lifetime of a
TracerProviderandMeterProviderto the test application, so they are disposed alongside the test host. - Observability: lets you route test execution data, via your own OpenTelemetry exporter configuration, into observability backends (e.g. Jaeger, Prometheus, Grafana).
- Standards-based: leverages the OpenTelemetry .NET SDK so that data is sent only to the telemetry exporters and endpoints that you configure.
Note:
AddOpenTelemetryProviderdoes not register any instrumentation or exporter by default. To actually collect MTP telemetry you must, from thewithTracing/withMetricsdelegates:
- call
AddTestingPlatformInstrumentation()on both theTracerProviderBuilderand theMeterProviderBuilderto subscribe to the Microsoft Testing Platform source/meter, and- register at least one exporter (for example
AddOtlpExporter,AddConsoleExporter, or a vendor-specific exporter).Without instrumentation, no MTP activities or metrics are collected; without an exporter, collected telemetry is not emitted anywhere.
Use
AddOpenTelemetryProviderFromEnvironment()instead if you want all of that configured for you from the standardOTEL_*variables. It only installs the instrumentation when an exporter is actually configured (viaOTEL_TRACES_EXPORTER/OTEL_METRICS_EXPORTER/OTEL_EXPORTER_OTLP_ENDPOINT) or when you pass a configuration delegate, so leaving it inProgram.csunconditionally costs nothing on machines that do not opt in.
Emitted metrics
| Instrument | Type | Unit | Description |
|---|---|---|---|
test.case.duration |
Histogram | s |
Duration of a single test case, dimensioned by test.case.result.status and test.suite.name. |
test.case.result.count |
Counter | {test} |
Number of test cases, dimensioned by test.case.result.status and test.suite.name. |
test.case.active |
UpDownCounter | {test} |
Test cases currently running. |
test.run.duration |
Histogram | s |
Duration of the whole run, dimensioned by test.run.result.status and test.run.exit_code. |
test.case.retry.count |
Counter | {test} |
Test cases scheduled for a retry attempt (requires Microsoft.Testing.Extensions.Retry). |
Metric dimensions are deliberately kept low-cardinality. Unbounded values such as the per-run test counts are set on
the root span (test.run.total, test.run.failed, test.run.skipped) rather than used as metric dimensions.
Span durations are reported in milliseconds under test.case.duration_ms, distinct from the seconds-valued
test.case.duration metric.
The legacy tests.discovered / tests.started / tests.completed / tests.passed / tests.failed / tests.skipped / tests.unknown counters and the tests.duration histogram (in milliseconds) are still emitted unless legacy attributes are disabled.
Configuration
| Environment variable | Default | Meaning |
|---|---|---|
TRACEPARENT / TRACESTATE |
unset | W3C trace context to nest the run under. |
TESTINGPLATFORM_OTEL_CAPTURE_TEST_OUTPUT |
1 |
Attach captured stdout/stderr to test spans. Set to 0 when the output can contain secrets. |
TESTINGPLATFORM_OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT |
8192 |
Maximum characters kept for a single string attribute. Applies to both the semantic-convention and the legacy attribute names. |
TESTINGPLATFORM_OTEL_EMIT_LEGACY_ATTRIBUTES |
1 |
Emit the pre-semantic-convention attribute and instrument names alongside the new ones. |
OTEL_SDK_DISABLED, OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER |
unset | Standard OpenTelemetry variables honored by AddOpenTelemetryProviderFromEnvironment. |
Data exported and controlling sensitive values
Telemetry is only ever sent to the exporters and endpoints you configure — nothing leaves the process unless you register an exporter (directly, or via AddOpenTelemetryProviderFromEnvironment and the OTEL_* variables). Once an exporter is configured, the following attributes can carry environment-specific or sensitive values, so review them against your exporter's destination:
| Attribute (and legacy twin) | Carries | Control |
|---|---|---|
test.case.name (test.name) |
The test's framework-provided display name, which for parameterized or data-driven tests can embed argument values or other user data. Exported verbatim (not truncated). | Emitted for every test. Disable the legacy twin with TESTINGPLATFORM_OTEL_EMIT_LEGACY_ATTRIBUTES=0. |
test.case.id / test.case.parent.id (test.id / test.parent.id) |
The framework-provided test UID(s), which can embed parameter values. Exported verbatim (not truncated). | test.case.id is emitted for every test; test.case.parent.id is emitted when the test has a parent. Disable the legacy twins with TESTINGPLATFORM_OTEL_EMIT_LEGACY_ATTRIBUTES=0. |
test.step.<id>.description (test.step<id>.description) |
Per-step descriptions supplied by the framework. Exported verbatim (not truncated). | Emitted whenever a test reports step timings. Disable the legacy twin with TESTINGPLATFORM_OTEL_EMIT_LEGACY_ATTRIBUTES=0. |
code.file.path (test.file.path), code.line.number (test.line.start/test.line.end) |
Absolute source file path of the test — reveals machine and repository layout. Exported verbatim (not truncated). | On by default whenever a test reports a file location. Disable the legacy twin with TESTINGPLATFORM_OTEL_EMIT_LEGACY_ATTRIBUTES=0. |
test.artifact.file[N].path |
Absolute path of each file artifact a test attaches (dumps, logs, screenshots). Exported verbatim (not truncated). | Emitted whenever a test produces file artifacts. |
test.output.stdout / test.output.stderr (test.stdout / test.stderr) |
Captured standard output and error of the test, which routinely contains secrets or environment data. | Off when TESTINGPLATFORM_OTEL_CAPTURE_TEST_OUTPUT=0; truncated to TESTINGPLATFORM_OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT. |
code.stacktrace, test.case.result.explanation (test.result.explanation), the exception span event (exception.type / exception.message / exception.stacktrace), the span status description, and the legacy test.result.exception.type / test.result.exception.message / test.result.exception.stacktrace |
Exception message and stack-trace text. | Truncated to TESTINGPLATFORM_OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT. Disable the legacy twins with TESTINGPLATFORM_OTEL_EMIT_LEGACY_ATTRIBUTES=0. |
test.metadata.* (test.metadataProperty.*) |
Framework-supplied trait/metadata values, exported verbatim (not truncated). | Emitted whenever a test carries metadata. Disable the legacy twin with TESTINGPLATFORM_OTEL_EMIT_LEGACY_ATTRIBUTES=0. |
Resource vcs.repository.url.full, plus the other resource attributes (host.name, os.description, and in CI the cicd.* / vcs.* pipeline, branch and commit — see Resource attributes above) |
The machine, OS and CI provenance attached to every span and metric point. | User-info credentials in the repository URL (https://user:token@host/...) are stripped before export. |
Only the captured output, the result explanation and the exception message and stack trace are truncated to TESTINGPLATFORM_OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT (8192 characters by default); all other listed values are exported verbatim unless the Control column notes otherwise, so truncation is a size guard rather than redaction. Set TESTINGPLATFORM_OTEL_CAPTURE_TEST_OUTPUT=0 on any job whose test output can contain secrets, and prefer sending telemetry to a backend you control.
Documentation
For this extension, see https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-open-telemetry.
For comprehensive documentation, see https://aka.ms/testingplatform.
Feedback & contributing
Microsoft.Testing.Platform is an open source project. Provide feedback or report issues in the microsoft/testfx GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Testing.Platform (>= 2.4.0 && < 3.0.0)
- OpenTelemetry (>= 1.15.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
-
net8.0
- Microsoft.Testing.Platform (>= 2.4.0 && < 3.0.0)
- OpenTelemetry (>= 1.15.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
-
net9.0
- Microsoft.Testing.Platform (>= 2.4.0 && < 3.0.0)
- OpenTelemetry (>= 1.15.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.4.0 | 38 | 9/2/2026 |
| 1.0.0-alpha.26377.5 | 77 | 7/28/2026 |
| 1.0.0-alpha.26363.8 | 64 | 7/13/2026 |
| 1.0.0-alpha.26358.12 | 57 | 7/8/2026 |
| 1.0.0-alpha.26357.13 | 67 | 7/7/2026 |
| 1.0.0-alpha.26264.3 | 83 | 5/14/2026 |
| 1.0.0-alpha.26228.3 | 73 | 4/30/2026 |
| 1.0.0-alpha.26202.7 | 80 | 4/7/2026 |
| 1.0.0-alpha.26103.11 | 102 | 2/3/2026 |
See the release notes at https://github.com/microsoft/testfx/blob/main/docs/Changelog-Platform.md#2.4.0.