Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
This feature requires the Microsoft.Testing.Extensions.OpenTelemetry NuGet package.
This extension integrates OpenTelemetry with Microsoft.Testing.Platform, allowing test runs to emit traces and metrics through the standard OpenTelemetry SDK.
Important
This extension is currently experimental. All public APIs are gated behind the TPEXP diagnostic ID.
Registration
Note
This extension doesn't support auto-registration. You must register it manually by disabling the auto-generated entry point (<GenerateTestingPlatformEntryPoint>false</GenerateTestingPlatformEntryPoint>) and calling AddOpenTelemetryProvider in your Main method.
var builder = await TestApplication.CreateBuilderAsync(args);
builder.AddOpenTelemetryProvider(
withTracing: tracing => tracing
.AddTestingPlatformInstrumentation()
.AddConsoleExporter(),
withMetrics: metrics => metrics
.AddTestingPlatformInstrumentation()
.AddConsoleExporter()
);
using var app = await builder.BuildAsync();
return await app.RunAsync();
API
AddOpenTelemetryProvider
Registers the OpenTelemetry provider on ITestApplicationBuilder. Accepts two optional callbacks:
withTracing: configures theTracerProviderBuilderfor distributed tracing.withMetrics: configures theMeterProviderBuilderfor metrics collection.
AddTestingPlatformInstrumentation
Call on TracerProviderBuilder or MeterProviderBuilder to subscribe to the built-in Microsoft.Testing.Platform activity source and meter.
Activity source and meter
The extension emits telemetry under:
- Activity source:
Microsoft.Testing.Platform - Meter:
Microsoft.Testing.Platform