Uh oh!
There was an error while loading. Please reload this page.
Document that AddOpenTelemetryProvider does not register default instrumentation or exporters - #8930
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the zero-configuration behavior of the Microsoft.Testing.Platform (MTP) OpenTelemetry extension by ensuring MTP’s ActivitySource and Meter are automatically registered when AddOpenTelemetryProvider() is used, bringing runtime behavior in line with the documented contract (Fixes #8409).
Changes:
- Auto-registers MTP tracing/metrics instrumentation (
Microsoft.Testing.Platform) insideOpenTelemetryProviderprior to invoking user configuration delegates. - Updates XML docs and package documentation to clarify the new contract (instrumentation auto-wired; exporters still caller-configured).
- Simplifies the public sample by removing redundant
AddTestingPlatformInstrumentation()calls.
Show a summary per file
| File | Description |
|---|---|
| src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/OpenTelemetryProvider.cs | Adds .AddSource(...) and .AddMeter(...) by default so zero-config calls actually instrument MTP telemetry. |
| src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/OpenTelemetryProviderExtensions.cs | Updates XML docs to reflect auto-wiring and clarify what callers still must configure. |
| src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/PACKAGE.md | Updates package docs to describe exporter responsibility and the zero-config behavior more accurately. |
| samples/public/MTPOTel/Program.cs | Removes redundant instrumentation calls to demonstrate the simplified API surface. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…TelemetryProvider Fixesmicrosoft#8409. `AddOpenTelemetryProvider` documented that omitting the delegates would use "default OpenTelemetry settings", but in practice it built empty `TracerProvider` / `MeterProvider` instances and the package README claimed it instruments test execution out of the box - neither of which matches reality. Rather than auto-registering MTP sources (which would also prevent callers from hosting an OTel pipeline through this extension for app-only telemetry), this change keeps full control in the caller's hands and makes the API contract honest: - XML docs on `AddOpenTelemetryProvider` now state explicitly that no instrumentation or exporter is registered by default, and that the caller must wire both via the `withTracing` / `withMetrics` delegates. - `AddTestingPlatformInstrumentation` docs describe both use sites (from inside the delegates and from a builder configured outside the helper). - PACKAGE.md drops the misleading "instruments test execution" wording and spells out the wiring required to actually collect MTP telemetry. - The MTPOTel sample gets a comment summarising the contract. No public API surface change, no runtime behavior change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7630129 to
59104d9CompareAmaury Levé (Evangelink)
commented
Jun 8, 2026
Filed #8931 to track the Roslyn analyzer follow-up (warn when |
Uh oh!
There was an error while loading. Please reload this page.
Fixes#8409.
Problem
AddOpenTelemetryProviderdocumented that omittingwithTracing/withMetricswould use "default OpenTelemetry settings", but it actually built emptyTracerProvider/MeterProviderinstances. The PACKAGE.md claim that the extension "instruments test execution with OpenTelemetry-compatible traces and metrics" was therefore not true for the zero-configuration path —builder.AddOpenTelemetryProvider();produced no MTP telemetry.Approach
Per the issue, option #2: keep runtime behavior under the caller's control and make the API contract honest. Auto-registering MTP instrumentation inside the provider was considered but rejected to preserve the (real, if niche) scenario of using this extension purely to manage the lifecycle of an OTel pipeline for application-only telemetry; the caller still needs a
Program.csto wire exporters either way, so the convenience gain was small.OpenTelemetryProviderExtensions.cs: XML docs onAddOpenTelemetryProvidernow state explicitly that no instrumentation or exporter is registered by default and that the caller must wire both via the delegates, includingAddTestingPlatformInstrumentation()to subscribe to MTP.AddTestingPlatformInstrumentationdocs describe both use sites (inside the delegates and on aTracerProviderBuilder/MeterProviderBuilderconfigured outside the helper).PACKAGE.md: drops the misleading "instruments test execution" framing and spells out the wiring required to actually collect MTP telemetry.samples/public/MTPOTel/Program.cs: adds a short comment summarising the contract.No public API surface change, no runtime behavior change — docs and sample only.
Verification
Built the extension cleanly (Debug, all TFMs) — 0 warnings, 0 errors.