OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule
1.13.0-rc.1
Prefix Reserved
See the version list below for details.
dotnet add package OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule --version 1.13.0-rc.1
NuGet\Install-Package OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule -Version 1.13.0-rc.1
<PackageReference Include="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule" Version="1.13.0-rc.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule" Version="1.13.0-rc.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule" />
paket add OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule --version 1.13.0-rc.1
#r "nuget: OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule, 1.13.0-rc.1"
#:package OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule@1.13.0-rc.1
#addin nuget:?package=OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule&version=1.13.0-rc.1&prerelease
#tool nuget:?package=OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule&version=1.13.0-rc.1&prerelease
ASP.NET Telemetry HttpModule for OpenTelemetry
| Status | |
|---|---|
| Stability | Release candidate |
| Code Owners | @open-telemetry/dotnet-contrib-maintainers |
The ASP.NET Telemetry HttpModule enables distributed tracing 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 be needed 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 a listener
TelemetryHttpModule registers an
ActivitySource
with the name OpenTelemetry.Instrumentation.AspNet. By default, .NET
ActivitySource will not generate any Activity objects unless there is
a registered listener.
To register a listener automatically using OpenTelemetry, please use the OpenTelemetry.Instrumentation.AspNet NuGet package.
To register a listener manually, use code such as the following:
using System.Diagnostics;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using OpenTelemetry.Instrumentation.AspNet;
namespace Examples.AspNet;
public class WebApiApplication : HttpApplication
{
private ActivityListener aspNetActivityListener;
protected void Application_Start()
{
this.aspNetActivityListener = new ActivityListener
{
ShouldListenTo = (activitySource) =>
{
// Only listen to TelemetryHttpModule's ActivitySource.
return activitySource.Name == "OpenTelemetry.Instrumentation.AspNet";
},
Sample = (ref ActivityCreationOptions<ActivityContext> options) =>
{
// Sample everything created by TelemetryHttpModule's ActivitySource.
return ActivitySamplingResult.AllDataAndRecorded;
},
};
ActivitySource.AddActivityListener(this.aspNetActivityListener);
GlobalConfiguration.Configure(WebApiConfig.Register);
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
protected void Application_End()
{
this.aspNetActivityListener?.Dispose();
}
}
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(),
});
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, & OnExceptionCallback
are provided on TelemetryHttpModuleOptions and will be fired by the
TelemetryHttpModule as requests are processed.
A typical use case for these events is to add information (tags, events, and/or
links) to the created Activity based on the request, response, and/or
exception event being fired.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- OpenTelemetry.Api (>= 1.13.1 && < 2.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule:
| Package | Downloads |
|---|---|
|
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET. |
|
|
C3D.Extensions.SystemWeb.OpenTelemetry.Application
Assembly Version: 0.1.0.0 File Version: 0.1.122.35648 Informational Version: 0.1.122+408be8c6f1 Build Configuration: Release |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.14.0 | 7,578 | 11/27/2025 |
| 1.14.0-rc.1 | 9,901 | 11/13/2025 |
| 1.13.0-rc.1 | 7,395 | 10/28/2025 |
| 1.13.0-beta.2 | 3,823 | 10/22/2025 |
| 1.13.0-beta.1 | 12,027 | 10/15/2025 |
| 1.12.0-beta.2 | 21,850 | 9/18/2025 |
| 1.12.0-beta.1 | 111,023 | 5/5/2025 |
| 1.11.0-beta.2 | 82,669 | 3/5/2025 |
| 1.11.0-beta.1 | 51,832 | 1/27/2025 |
| 1.10.0-beta.1 | 72,024 | 12/9/2024 |
| 1.9.0-beta.1 | 559,224 | 6/18/2024 |
| 1.8.0-beta.3 | 184,944 | 5/23/2024 |
| 1.8.0-beta.2 | 157,637 | 4/17/2024 |
| 1.8.0-beta.1 | 38,930 | 4/5/2024 |
| 1.7.0-beta.2 | 126,518 | 2/7/2024 |
| 1.7.0-beta.1 | 71,116 | 12/20/2023 |
| 1.6.0-beta.2 | 142,348 | 11/6/2023 |
| 1.6.0-beta.1 | 30,637 | 10/12/2023 |
| 1.0.0-rc9.9 | 231,546 | 6/9/2023 |
| 1.0.0-rc9.8 | 285,247 | 2/28/2023 |
| 1.0.0-rc9.7 | 138,116 | 11/28/2022 |
| 1.0.0-rc9.6 | 67,372 | 9/28/2022 |
| 1.0.0-rc9.5 | 114,682 | 6/21/2022 |
| 1.0.0-rc9.4 | 63,703 | 6/3/2022 |
| 1.0.0-rc9.3 | 10,263 | 4/20/2022 |
| 1.0.0-rc9.2 | 28,952 | 4/13/2022 |
| 1.0.0-rc9.1 | 85,481 | 3/30/2022 |
| 1.0.0-rc9 | 102,959 | 2/3/2022 |
| 1.0.0-rc8 | 102,481 | 10/8/2021 |