OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule 1.14.0
ASP.NET Telemetry HttpModule for OpenTelemetry
| Status | |
|---|---|
| Stability | Stable |
| Code Owners | @open-telemetry/dotnet-contrib-maintainers |
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.AspNetTelemetryHttpModuleOptions.TextMapPropagatoris 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
|
2 |
|
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET.
|
2 |
.NET Framework 4.6.2
- OpenTelemetry.Api (>= 1.14.0 && < 2.0.0)
| Version | Downloads | Last updated |
|---|---|---|
| 1.14.0 | 1 | 12/09/2025 |
| 1.14.0-rc.1 | 1 | 12/10/2025 |
| 1.13.0-rc.1 | 1 | 12/10/2025 |
| 1.13.0-beta.2 | 1 | 12/10/2025 |
| 1.13.0-beta.1 | 1 | 12/10/2025 |
| 1.12.0-beta.2 | 1 | 12/10/2025 |
| 1.12.0-beta.1 | 1 | 12/10/2025 |
| 1.11.0-beta.2 | 1 | 12/10/2025 |
| 1.11.0-beta.1 | 1 | 12/10/2025 |
| 1.10.0-beta.1 | 1 | 12/10/2025 |
| 1.9.0-beta.1 | 1 | 12/10/2025 |
| 1.8.0-beta.3 | 1 | 12/10/2025 |
| 1.8.0-beta.2 | 1 | 12/10/2025 |
| 1.8.0-beta.1 | 1 | 12/10/2025 |
| 1.7.0-beta.2 | 1 | 12/10/2025 |
| 1.7.0-beta.1 | 1 | 12/10/2025 |
| 1.6.0-beta.2 | 1 | 12/10/2025 |
| 1.6.0-beta.1 | 1 | 12/10/2025 |
| 1.0.0-rc9.9 | 1 | 12/10/2025 |
| 1.0.0-rc9.8 | 1 | 12/10/2025 |
| 1.0.0-rc9.7 | 1 | 12/10/2025 |
| 1.0.0-rc9.6 | 1 | 12/11/2025 |
| 1.0.0-rc9.5 | 1 | 12/10/2025 |
| 1.0.0-rc9.4 | 1 | 12/10/2025 |
| 1.0.0-rc9.3 | 1 | 12/10/2025 |
| 1.0.0-rc9.2 | 1 | 12/10/2025 |
| 1.0.0-rc9.1 | 1 | 12/10/2025 |
| 1.0.0-rc9 | 1 | 12/10/2025 |
| 1.0.0-rc8 | 1 | 12/10/2025 |