Skip to main content
Table of Contents

Class AspNetCoreOpenTelemetryExtensions

Namespace
Microsoft.Extensions.Hosting
Assembly
Stratara.ServiceDefaults.AspNetCore.dll

ASP.NET-specific extensions to the base OpenTelemetry pipeline from Stratara.ServiceDefaults. Adds request instrumentation and excludes the health-check endpoints from traces.

public static class AspNetCoreOpenTelemetryExtensions
Inheritance
AspNetCoreOpenTelemetryExtensions
Inherited Members

Remarks

Server-side ASP.NET Core instrumentation registers an enrichment callback that overwrites any captured http.request.header.authorization / http.request.header.cookie / http.response.header.set-cookie tags with "REDACTED". This is a defensive measure for hosts that opt into header capture via OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS or the SDK's own options — without that opt-in, OTel does not record headers anyway, so this is a belt-and-braces safeguard against incoming bearer tokens or session cookies leaking through trace exporters.

Methods

ConfigureAspNetOpenTelemetry<TBuilder>(TBuilder)

Wires ASP.NET Core request instrumentation on metrics + tracing on top of the base pipeline configured by ConfigureOpenTelemetry. Filters out the health (/health) and aliveness (/alive) endpoints from tracing so they don't pollute the request stream.

public static TBuilder ConfigureAspNetOpenTelemetry<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder

Parameters

builder TBuilder

The host application builder.

Returns

TBuilder

The same builder for chaining.

Type Parameters

TBuilder

The host-builder type.

Examples

Layers ASP.NET Core request instrumentation on top of the base pipeline, filtering the health and aliveness endpoints out of tracing:

builder.ConfigureOpenTelemetry();
builder.ConfigureAspNetOpenTelemetry();