Skip to content

[MTP Diagnostic Analysis] AddOpenTelemetryProvider defaults to a no-op despite documented default behavior #8409

@Evangelink

Description

@Evangelink

Summary

AddOpenTelemetryProvider() documents that null delegates use default tracing/metrics behavior, but the implementation just builds empty TracerProvider / MeterProvider instances. No Microsoft Testing Platform instrumentation or exporter is added unless the caller wires everything manually.

Evidence

  • Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.OpenTelemetry\OpenTelemetryProviderExtensions.cs:20-29
    • If no delegates are supplied, default OpenTelemetry settings are used.
    • public static void AddOpenTelemetryProvider(..., Action<TracerProviderBuilder>? withTracing = null, Action<MeterProviderBuilder>? withMetrics = null)
  • Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.OpenTelemetry\OpenTelemetryProvider.cs:19-25
    • TracerProviderBuilder tracerProviderBuilder = Sdk.CreateTracerProviderBuilder();
    • withTracing?.Invoke(tracerProviderBuilder);
    • _tracerProvider = tracerProviderBuilder.Build();
    • MeterProviderBuilder meterProviderBuilder = Sdk.CreateMeterProviderBuilder();
    • withMetrics?.Invoke(meterProviderBuilder);
    • _meterProvider = meterProviderBuilder.Build();
  • Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.OpenTelemetry\OpenTelemetryProviderExtensions.cs:45-59
    • AddTestingPlatformInstrumentation(...) => builder.AddSource(OpenTelemetryPlatformService.ActivitySourceName);
    • AddTestingPlatformInstrumentation(...) => builder.AddMeter(OpenTelemetryPlatformService.MeterName);
  • Q:\src\testfx\samples\public\MTPOTel\Program.cs:31-42
    • sample has to call tracing.AddTestingPlatformInstrumentation();
    • sample has to call metrics.AddTestingPlatformInstrumentation();
    • sample has to add exporters explicitly.

Why this is a real issue

builder.AddOpenTelemetryProvider(); looks valid from the API and XML docs, but it produces no test traces or metrics. The package README also says the extension "instruments test execution with OpenTelemetry-compatible traces and metrics", which is not true for the zero-configuration path.

Suggested resolution

Either:

  1. register Microsoft Testing Platform instrumentation by default (and document that exporters are still caller-configured), or
  2. fail fast / warn when neither delegate configures instrumentation/exporters, and update the XML docs/README so the API contract matches reality.

Related issues

  • None found

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mtp-extensionsMTP extensions (TrxReport, Retry, HtmlReport, ...).type/automationCreated or maintained by an agentic workflow.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions