OpenTelemetry.Extensions.Enrichment.AspNetCore
1.19.1-beta.1
Prefix Reserved
dotnet add package OpenTelemetry.Extensions.Enrichment.AspNetCore --version 1.19.1-beta.1
NuGet\Install-Package OpenTelemetry.Extensions.Enrichment.AspNetCore -Version 1.19.1-beta.1
<PackageReference Include="OpenTelemetry.Extensions.Enrichment.AspNetCore" Version="1.19.1-beta.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Enrichment.AspNetCore" Version="1.19.1-beta.1" />
<PackageReference Include="OpenTelemetry.Extensions.Enrichment.AspNetCore" />
paket add OpenTelemetry.Extensions.Enrichment.AspNetCore --version 1.19.1-beta.1
#r "nuget: OpenTelemetry.Extensions.Enrichment.AspNetCore, 1.19.1-beta.1"
#:package OpenTelemetry.Extensions.Enrichment.AspNetCore@1.19.1-beta.1
#addin nuget:?package=OpenTelemetry.Extensions.Enrichment.AspNetCore&version=1.19.1-beta.1&prerelease
#tool nuget:?package=OpenTelemetry.Extensions.Enrichment.AspNetCore&version=1.19.1-beta.1&prerelease
OpenTelemetry .NET SDK ASP.NET Core telemetry enrichment
| Status | |
|---|---|
| Stability | Development |
| Code Owners | @evgenyfedorov2, @dariusclay |
Contains OpenTelemetry .NET SDK ASP.NET Core telemetry enrichment extensions which are used for enrichment of logs, metrics, and traces in inbound HTTP requests.
Introduction
ASP.NET Core Telemetry enrichment attaches various types of information to traces generated for incoming HTTP requests. You can use the ASP.NET Core Telemetry enrichment framework to attach any custom information that you would like to be present in traces for incoming HTTP requests.
With the ASP.NET Core Telemetry enrichment framework, you don't need to worry
about attaching the information carefully to each telemetry object you touch.
Instead, if you implement your enricher class inherited from AspNetCoreTraceEnricher,
it takes care of the details automatically. You simply register your class with
the enrichment framework and the enrichment framework will make sure to call the
enrichment methods of your class for every incoming HTTP request in your app.
Traces
Currently this package supports trace enrichment only.
Steps to enable OpenTelemetry.Extensions.Enrichment.AspNetCore
Step 1: Install package
Download the OpenTelemetry.Extensions.Enrichment.AspNetCore package:
dotnet add package OpenTelemetry.Extensions.Enrichment.AspNetCore --prerelease
Step 2: Create enricher class
Create your custom enricher class that inherits from the AspNetCoreTraceEnricher
class and override one or more of the following virtual methods, as needed:
EnrichWithHttpRequest(in TraceEnrichmentBag bag, HttpRequest request)EnrichWithHttpResponse(in TraceEnrichmentBag bag, HttpResponse response)EnrichWithException(in TraceEnrichmentBag bag, Exception exception)
Each method receives a TraceEnrichmentBag, the same lightweight readonly struct
used by OpenTelemetry.Extensions.Enrichment, which exposes a single
Add(string key, object? value) method for adding tags.
internal sealed class MyAspNetCoreTraceEnricher : AspNetCoreTraceEnricher
{
public override void EnrichWithHttpRequest(in TraceEnrichmentBag bag, HttpRequest request)
{
bag.Add("http.request.header.x-my-custom-header", request.Headers["x-my-custom-header"].ToString());
}
public override void EnrichWithHttpResponse(in TraceEnrichmentBag bag, HttpResponse response)
{
bag.Add("http.response.content-length", response.ContentLength);
}
public override void EnrichWithException(in TraceEnrichmentBag bag, Exception exception)
{
bag.Add("exception.source", exception.Source);
}
}
Optionally, inject other services your enricher class depends on via its constructor,
the same way you would with TraceEnricher (see the
OpenTelemetry.Extensions.Enrichment README
for an example).
Step 3: Register enricher class
Add your custom enricher class to the TracerProviderBuilder by calling the
TryAddAspNetCoreTraceEnricher<T>() method:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.TryAddAspNetCoreTraceEnricher<MyAspNetCoreTraceEnricher>()
.AddConsoleExporter());
var app = builder.Build();
app.MapGet("/", () => "Hello OpenTelemetry!");
app.Run();
Alternatively, you can add your custom enricher to the IServiceCollection
directly:
var builder = WebApplication.CreateBuilder(args);
builder.Services.TryAddAspNetCoreTraceEnricher<MyAspNetCoreTraceEnricher>();
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.AddConsoleExporter());
var app = builder.Build();
app.MapGet("/", () => "Hello OpenTelemetry!");
app.Run();
The TryAddAspNetCoreTraceEnricher() call should be done before exporter
related Activity processors are added.
Step 4: Usage
Once registered, the enrichment methods of your class are called automatically
for every incoming HTTP request handled by ASP.NET Core - no additional code is
required at the request-handling site. Run your application and issue a request;
the tags added in your enricher will appear on the resulting Activity.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- OpenTelemetry.Extensions.Enrichment (>= 1.19.1-beta.1 && < 2.0.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.19.0 && < 2.0.0)
-
net10.0
- OpenTelemetry.Extensions.Enrichment (>= 1.19.1-beta.1 && < 2.0.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.19.0 && < 2.0.0)
-
net8.0
- OpenTelemetry.Extensions.Enrichment (>= 1.19.1-beta.1 && < 2.0.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.19.0 && < 2.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OpenTelemetry.Extensions.Enrichment.AspNetCore:
| Package | Downloads |
|---|---|
|
xSdk.Extensions.Telemetry
xSdk.Extensions.Telemetry - Telemetry extensions for the xSdk project. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.19.1-beta.1 | 67 | 9/21/2026 |
| 1.19.0-beta.1 | 90 | 9/18/2026 |
| 1.18.0-beta.1 | 218 | 8/21/2026 |
| 1.17.0-beta.1 | 285 | 7/17/2026 |
| 1.16.0-beta.1 | 101 | 7/9/2026 |
| 1.15.1-beta.2 | 591 | 4/23/2026 |
| 1.15.1-beta.1 | 86 | 4/21/2026 |
| 1.15.0-beta.1 | 3,737 | 1/21/2026 |
| 1.14.0-alpha.1 | 296 | 11/14/2025 |