OpenTelemetry.Extensions.Enrichment.Http
1.19.1-beta.1
Prefix Reserved
dotnet add package OpenTelemetry.Extensions.Enrichment.Http --version 1.19.1-beta.1
NuGet\Install-Package OpenTelemetry.Extensions.Enrichment.Http -Version 1.19.1-beta.1
<PackageReference Include="OpenTelemetry.Extensions.Enrichment.Http" Version="1.19.1-beta.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Enrichment.Http" Version="1.19.1-beta.1" />
<PackageReference Include="OpenTelemetry.Extensions.Enrichment.Http" />
paket add OpenTelemetry.Extensions.Enrichment.Http --version 1.19.1-beta.1
#r "nuget: OpenTelemetry.Extensions.Enrichment.Http, 1.19.1-beta.1"
#:package OpenTelemetry.Extensions.Enrichment.Http@1.19.1-beta.1
#addin nuget:?package=OpenTelemetry.Extensions.Enrichment.Http&version=1.19.1-beta.1&prerelease
#tool nuget:?package=OpenTelemetry.Extensions.Enrichment.Http&version=1.19.1-beta.1&prerelease
OpenTelemetry .NET SDK HTTP telemetry enrichment
| Status | |
|---|---|
| Stability | Development |
| Code Owners | @evgenyfedorov2, @dariusclay |
Contains OpenTelemetry .NET SDK HTTP telemetry enrichment extensions which are used for enrichment of logs, metrics, and traces in outbound HTTP requests.
Introduction
HTTP Telemetry enrichment attaches various types of information to traces generated for outgoing HTTP requests. You can use the HTTP Telemetry enrichment framework to attach any custom information that you would like to be present in traces for outgoing HTTP requests.
With the HTTP 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 HttpClientTraceEnricher,
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 outgoing HTTP request in your app.
Traces
Currently this package supports trace enrichment only.
Steps to enable OpenTelemetry.Extensions.Enrichment.Http
Step 1: Install package
Download the OpenTelemetry.Extensions.Enrichment.Http package:
dotnet add package OpenTelemetry.Extensions.Enrichment.Http --prerelease
Step 2: Create enricher class
Create your custom enricher class that inherits from the HttpClientTraceEnricher
class and override one or more of the following virtual methods, as needed:
EnrichWithRequest(in TraceEnrichmentBag bag, HttpRequestMessage request)EnrichWithResponse(in TraceEnrichmentBag bag, HttpResponseMessage response)EnrichWithException(in TraceEnrichmentBag bag, Exception exception)
On .NET Framework targets, EnrichWithRequest and EnrichWithResponse instead
take an HttpWebRequest and HttpWebResponse respectively.
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 MyHttpClientTraceEnricher : HttpClientTraceEnricher
{
public override void EnrichWithRequest(in TraceEnrichmentBag bag, HttpRequestMessage request)
{
if (request.Headers.TryGetValues("x-my-custom-header", out var values))
{
bag.Add("http.request.header.x-my-custom-header", string.Join(",", values));
}
}
public override void EnrichWithResponse(in TraceEnrichmentBag bag, HttpResponseMessage response)
{
bag.Add("http.response.content-length", response.Content.Headers.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
TryAddHttpClientTraceEnricher<T>() method:
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddHttpClientInstrumentation()
.TryAddHttpClientTraceEnricher<MyHttpClientTraceEnricher>()
.AddConsoleExporter()
.Build();
Alternatively, you can add your custom enricher to the IServiceCollection
directly:
var builder = Host.CreateApplicationBuilder(args);
builder.Services.TryAddHttpClientTraceEnricher<MyHttpClientTraceEnricher>();
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddHttpClientInstrumentation()
.AddConsoleExporter());
var app = builder.Build();
app.Run();
Step 4: Usage
Once registered, the enrichment methods of your class are called automatically
for every outgoing HTTP request made through an instrumented HttpClient -
no additional code is required at the call site. Issue an outgoing request and
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 is compatible. 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. |
-
.NETFramework 4.6.2
- OpenTelemetry.Extensions.Enrichment (>= 1.19.1-beta.1 && < 2.0.0)
- OpenTelemetry.Instrumentation.Http (>= 1.19.0 && < 2.0.0)
-
.NETStandard 2.0
- OpenTelemetry.Extensions.Enrichment (>= 1.19.1-beta.1 && < 2.0.0)
- OpenTelemetry.Instrumentation.Http (>= 1.19.0 && < 2.0.0)
-
net10.0
- OpenTelemetry.Extensions.Enrichment (>= 1.19.1-beta.1 && < 2.0.0)
- OpenTelemetry.Instrumentation.Http (>= 1.19.0 && < 2.0.0)
-
net8.0
- OpenTelemetry.Extensions.Enrichment (>= 1.19.1-beta.1 && < 2.0.0)
- OpenTelemetry.Instrumentation.Http (>= 1.19.0 && < 2.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OpenTelemetry.Extensions.Enrichment.Http:
| 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 | 290 | 9/21/2026 |
| 1.19.0-beta.1 | 66 | 9/18/2026 |
| 1.18.0-beta.1 | 88 | 8/21/2026 |
| 1.17.0-beta.1 | 86 | 7/17/2026 |
| 1.16.0-beta.1 | 90 | 7/9/2026 |
| 1.15.1-beta.2 | 14,810 | 4/23/2026 |
| 1.15.1-beta.1 | 81 | 4/21/2026 |
| 1.15.0-beta.1 | 7,810 | 1/21/2026 |
| 1.14.0-alpha.1 | 432 | 11/20/2025 |