OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule 1.14.0

ASP.NET Telemetry HttpModule for OpenTelemetry

Status
Stability Stable
Code Owners @open-telemetry/dotnet-contrib-maintainers

NuGet version badge NuGet download count badge codecov.io

The ASP.NET Telemetry HttpModule is a skeleton to enable distributed tracing and metrics of incoming ASP.NET requests using the OpenTelemetry API.

Usage

Step 1: Install NuGet package

If you are using the traditional packages.config reference style, a web.config transform should run automatically and configure the TelemetryHttpModule for you. If you are using the more modern PackageReference style, this may need to be done manually. For more information, see: Migrate from packages.config to PackageReference.

To configure your web.config manually, add this:

<system.webServer>
    <modules>
        <add
            name="TelemetryHttpModule"
            type="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule,
                OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule"
            preCondition="integratedMode,managedHandler" />
    </modules>
</system.webServer>

Step 2: Register hooks

TelemetryHttpModule provides hooks to create and manage activities and metrics.

To automatically register the entire infrastructure using OpenTelemetry, please use the OpenTelemetry.Instrumentation.AspNet NuGet package.

Options

TelemetryHttpModule provides a static options property (TelemetryHttpModule.Options) which can be used to configure the TelemetryHttpModule and listen to events it fires.

TextMapPropagator

TextMapPropagator controls how trace context will be extracted from incoming HTTP request messages. By default, W3C Trace Context is enabled.

The OpenTelemetry API ships with a handful of standard implementations which may be used, or you can write your own by deriving from the TextMapPropagator class.

To add support for Baggage propagation in addition to W3C Trace Context, use:

TelemetryHttpModuleOptions.TextMapPropagator = new CompositeTextMapPropagator(
    new TextMapPropagator[]
    {
        new TraceContextPropagator(),
        new BaggagePropagator(),
    });

[!NOTE] When using the OpenTelemetry.Instrumentation.AspNet TelemetryHttpModuleOptions.TextMapPropagator is automatically initialized to the SDK default propagator (Propagators.DefaultTextMapPropagator) which by default supports W3C Trace Context & Baggage.

Events

OnRequestStartedCallback, OnRequestStoppedCallback, and OnExceptionCallback are provided on TelemetryHttpModuleOptions and will be fired by the TelemetryHttpModule as requests are processed.

A typical use case for the OnRequestStartedCallback event is to create an activity based on the HttpContextBase and ActivityContext.

OnRequestStoppedCallback and OnExceptionCallback are needed to add information (tags, events, and/or links) to the created Activity based on the request, response, and/or exception event being fired.

Showing the top 20 packages that depend on OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.

Packages Downloads
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
27
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
30
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
31
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
32
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
33
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
34
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
35
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
36
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
37
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET.
30

For detailed changes see: https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/b2b24b2af4c67152b3ba4633487917d56ebbf07c/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md.

.NET Framework 4.6.2

Version Downloads Last updated
1.14.0 3 11/28/2025
1.14.0-rc.1 7 11/14/2025
1.13.0-rc.1 9 10/29/2025
1.13.0-beta.2 10 10/24/2025
1.13.0-beta.1 10 10/20/2025
1.12.0-beta.2 12 09/19/2025
1.12.0-beta.1 18 05/09/2025
1.11.0-beta.2 27 03/06/2025
1.11.0-beta.1 26 02/02/2025
1.10.0-beta.1 29 01/04/2025
1.9.0-beta.1 25 11/29/2024
1.8.0-beta.3 27 05/25/2024
1.8.0-beta.2 24 05/25/2024
1.8.0-beta.1 32 05/25/2024
1.7.0-beta.2 30 05/25/2024
1.7.0-beta.1 25 05/25/2024
1.6.0-beta.2 33 05/25/2024
1.6.0-beta.1 23 05/25/2024
1.0.0-rc9.9 30 05/25/2024
1.0.0-rc9.8 26 05/25/2024
1.0.0-rc9.7 26 05/25/2024
1.0.0-rc9.6 27 05/25/2024
1.0.0-rc9.5 31 05/25/2024
1.0.0-rc9.4 28 05/25/2024
1.0.0-rc9.3 29 05/25/2024
1.0.0-rc9.2 25 05/25/2024
1.0.0-rc9.1 40 05/25/2024
1.0.0-rc9 25 05/25/2024
1.0.0-rc8 29 05/25/2024