From d0c8a3893c3d02003ba18ab85faaf18d32cf8e8a Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Tue, 10 Sep 2024 10:27:12 +0200 Subject: [PATCH 01/11] Add Enrichment instructions --- .../README.md | 46 ++++++++++++++ .../README.md | 60 +++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md index 12a76ed607..8e1a7e8a88 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md @@ -311,6 +311,52 @@ the library you can do so as follows: }); ``` +#### Enriching ASP.NET Core Request Metrics + +ASP.NET Core supports enriching request metrics using `IHttpMetricsTagsFeature`. +This feature allows you to add custom tags to metrics like `http.server.request.duration`, +which records the duration of HTTP requests on the server. + +Here's an example of enriching the `http.server.request.duration` metric: + +```csharp +using Microsoft.AspNetCore.Http.Features; + +var builder = WebApplication.CreateBuilder(); +var app = builder.Build(); + +app.Use(async (context, next) => +{ + var tagsFeature = context.Features.Get(); + if (tagsFeature != null) + { + var source = context.Request.Query["utm_medium"].ToString() switch + { + "" => "none", + "social" => "social", + "email" => "email", + "organic" => "organic", + _ => "other" + }; + tagsFeature.Tags.Add(new KeyValuePair("mkt_medium", source)); + } + + await next.Invoke(); +}); + +app.MapGet("/", () => "Hello World!"); + +app.Run(); +``` + +In this example: + +* Middleware is added to enrich the ASP.NET Core request metric. +* `IHttpMetricsTagsFeature` is obtained from the `HttpContext`. + This feature is only available if someone is listening to the metric. +* A custom tag `mkt_medium` is added to the `http.server.request.duration` metric. + The value of this tag is determined based on the `utm_medium` query string parameter. + #### RecordException This instrumentation automatically sets Activity Status to Error if an unhandled diff --git a/src/OpenTelemetry.Instrumentation.Http/README.md b/src/OpenTelemetry.Instrumentation.Http/README.md index cf729c8252..a7a3e9630c 100644 --- a/src/OpenTelemetry.Instrumentation.Http/README.md +++ b/src/OpenTelemetry.Instrumentation.Http/README.md @@ -263,6 +263,66 @@ var tracerProvider = Sdk.CreateTracerProviderBuilder() .Build(); ``` +#### Enriching HttpClient Metrics + +Metrics enrichment in HttpClient allows adding custom tags to metrics, such as +`http.client.request.duration`. This is especially useful for categorizing +metrics in dashboards or alerts. + +Using `HttpMetricsEnrichmentContext` for Enrichment +To enrich metrics, you can register callbacks with `HttpMetricsEnrichmentContext`. +This requires setting up a custom `DelegatingHandler` that intercepts requests +and adds custom tags before they are sent to the server. + +Here’s how you can implement a custom `DelegatingHandler` to enrich metrics: + +```csharp +using System.Net.Http.Metrics; + +using HttpClient client = new(new EnrichmentHandler() { InnerHandler = new HttpClientHandler() }); + +await client.GetStringAsync("https://httpbin.org/response-headers?Enrichment-Value=A"); +await client.GetStringAsync("https://httpbin.org/response-headers?Enrichment-Value=B"); + +sealed class EnrichmentHandler : DelegatingHandler +{ + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + HttpMetricsEnrichmentContext.AddCallback(request, static context => + { + if (context.Response is not null) // Response is null when an exception occurs. + { + // Use any information available on the request or the response to emit custom tags. + string? value = context.Response.Headers.GetValues("Enrichment-Value").FirstOrDefault(); + if (value != null) + { + context.AddCustomTag("enrichment_value", value); + } + } + }); + return base.SendAsync(request, cancellationToken); + } +} +``` + +If you're working with IHttpClientFactory, you can use AddHttpMessageHandler +to register the EnrichmentHandler: + +```csharp +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using System.Net.Http.Metrics; + +ServiceCollection services = new(); +services.AddHttpClient(Options.DefaultName).AddHttpMessageHandler(() => new EnrichmentHandler()); + +ServiceProvider serviceProvider = services.BuildServiceProvider(); +HttpClient client = serviceProvider.GetRequiredService(); + +await client.GetStringAsync("https://httpbin.org/response-headers?Enrichment-Value=A"); +await client.GetStringAsync("https://httpbin.org/response-headers?Enrichment-Value=B"); +``` + #### .NET Framework ##### Filter HttpWebRequest API From c2fdc143e8728ebfaa9fb27c4b2b269ee226f7d0 Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Tue, 10 Sep 2024 11:14:40 +0200 Subject: [PATCH 02/11] replase Non-ASCII character --- src/OpenTelemetry.Instrumentation.Http/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.Http/README.md b/src/OpenTelemetry.Instrumentation.Http/README.md index a7a3e9630c..6832168710 100644 --- a/src/OpenTelemetry.Instrumentation.Http/README.md +++ b/src/OpenTelemetry.Instrumentation.Http/README.md @@ -274,7 +274,7 @@ To enrich metrics, you can register callbacks with `HttpMetricsEnrichmentContext This requires setting up a custom `DelegatingHandler` that intercepts requests and adds custom tags before they are sent to the server. -Here’s how you can implement a custom `DelegatingHandler` to enrich metrics: +Here's how you can implement a custom `DelegatingHandler` to enrich metrics: ```csharp using System.Net.Http.Metrics; From 99a4211340adb3c944e2380f9f010a72d6933dac Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Wed, 11 Sep 2024 10:18:29 +0200 Subject: [PATCH 03/11] apply suggestion --- .../README.md | 27 +++++++++++++++++-- .../README.md | 3 +++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md index 8e1a7e8a88..e9b1b8fe25 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md @@ -313,6 +313,9 @@ the library you can do so as follows: #### Enriching ASP.NET Core Request Metrics +> [!IMPORTANT] +> Only applicable for .NET 8 and newer. + ASP.NET Core supports enriching request metrics using `IHttpMetricsTagsFeature`. This feature allows you to add custom tags to metrics like `http.server.request.duration`, which records the duration of HTTP requests on the server. @@ -320,11 +323,31 @@ which records the duration of HTTP requests on the server. Here's an example of enriching the `http.server.request.duration` metric: ```csharp +using OpenTelemetry.Metrics; +using OpenTelemetry.Resources; +using OpenTelemetry.Trace; using Microsoft.AspNetCore.Http.Features; -var builder = WebApplication.CreateBuilder(); +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddOpenTelemetry() + .WithMetrics(metricsBuilder => + { + metricsBuilder + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("MyService")) + .AddOtlpExporter() + .AddMeter("Microsoft.AspNetCore.Hosting", "Microsoft.AspNetCore.Server.Kestrel") + .AddView("http.server.request.duration", + new ExplicitBucketHistogramConfiguration + { + Boundaries = new double[] { 0, 0.005, 0.01, 0.025, 0.05, + 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 } + }); + }); + var app = builder.Build(); +// Middleware to enrich the request metric with marketing source app.Use(async (context, next) => { var tagsFeature = context.Features.Get(); @@ -344,7 +367,7 @@ app.Use(async (context, next) => await next.Invoke(); }); -app.MapGet("/", () => "Hello World!"); +app.MapGet("/", () => "Hello OpenTelemetry!"); app.Run(); ``` diff --git a/src/OpenTelemetry.Instrumentation.Http/README.md b/src/OpenTelemetry.Instrumentation.Http/README.md index 6832168710..047dd71cad 100644 --- a/src/OpenTelemetry.Instrumentation.Http/README.md +++ b/src/OpenTelemetry.Instrumentation.Http/README.md @@ -265,6 +265,9 @@ var tracerProvider = Sdk.CreateTracerProviderBuilder() #### Enriching HttpClient Metrics +> [!IMPORTANT] +> Only applicable for .NET 8 and newer. + Metrics enrichment in HttpClient allows adding custom tags to metrics, such as `http.client.request.duration`. This is especially useful for categorizing metrics in dashboards or alerts. From 0efd73af6021ecb640fcd0ab6043336b4764e537 Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Tue, 17 Sep 2024 10:49:43 +0200 Subject: [PATCH 04/11] update docs based on the suggestions --- .../README.md | 31 +++++-------------- .../README.md | 28 +++++++---------- 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md index e9b1b8fe25..21f5ec43a8 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md @@ -317,15 +317,13 @@ the library you can do so as follows: > Only applicable for .NET 8 and newer. ASP.NET Core supports enriching request metrics using `IHttpMetricsTagsFeature`. -This feature allows you to add custom tags to metrics like `http.server.request.duration`, -which records the duration of HTTP requests on the server. +This feature allows you to add custom tags to metrics. Here's an example of enriching the `http.server.request.duration` metric: ```csharp using OpenTelemetry.Metrics; using OpenTelemetry.Resources; -using OpenTelemetry.Trace; using Microsoft.AspNetCore.Http.Features; var builder = WebApplication.CreateBuilder(args); @@ -336,32 +334,20 @@ builder.Services.AddOpenTelemetry() metricsBuilder .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("MyService")) .AddOtlpExporter() - .AddMeter("Microsoft.AspNetCore.Hosting", "Microsoft.AspNetCore.Server.Kestrel") - .AddView("http.server.request.duration", - new ExplicitBucketHistogramConfiguration - { - Boundaries = new double[] { 0, 0.005, 0.01, 0.025, 0.05, - 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 } - }); + .AddMeter("Microsoft.AspNetCore.Hosting"); }); var app = builder.Build(); -// Middleware to enrich the request metric with marketing source +// Middleware to enrich the request metric with a custom tag app.Use(async (context, next) => { var tagsFeature = context.Features.Get(); if (tagsFeature != null) { - var source = context.Request.Query["utm_medium"].ToString() switch - { - "" => "none", - "social" => "social", - "email" => "email", - "organic" => "organic", - _ => "other" - }; - tagsFeature.Tags.Add(new KeyValuePair("mkt_medium", source)); + // Add a custom tag based on the "utm_medium" query parameter + var source = context.Request.Query["utm_medium"].ToString(); + tagsFeature.Tags.Add(new KeyValuePair("utm_medium", source)); } await next.Invoke(); @@ -374,11 +360,10 @@ app.Run(); In this example: -* Middleware is added to enrich the ASP.NET Core request metric. +* Middleware is used to add a custom tag `utm_medium` to the + `http.server.request.duration` metric. * `IHttpMetricsTagsFeature` is obtained from the `HttpContext`. This feature is only available if someone is listening to the metric. -* A custom tag `mkt_medium` is added to the `http.server.request.duration` metric. - The value of this tag is determined based on the `utm_medium` query string parameter. #### RecordException diff --git a/src/OpenTelemetry.Instrumentation.Http/README.md b/src/OpenTelemetry.Instrumentation.Http/README.md index 047dd71cad..7d2e2c2bcb 100644 --- a/src/OpenTelemetry.Instrumentation.Http/README.md +++ b/src/OpenTelemetry.Instrumentation.Http/README.md @@ -268,9 +268,8 @@ var tracerProvider = Sdk.CreateTracerProviderBuilder() > [!IMPORTANT] > Only applicable for .NET 8 and newer. -Metrics enrichment in HttpClient allows adding custom tags to metrics, such as -`http.client.request.duration`. This is especially useful for categorizing -metrics in dashboards or alerts. +Metrics enrichment in HttpClient allows adding custom tags to metrics. + This is especially useful for categorizing metrics in dashboards or alerts. Using `HttpMetricsEnrichmentContext` for Enrichment To enrich metrics, you can register callbacks with `HttpMetricsEnrichmentContext`. @@ -284,8 +283,7 @@ using System.Net.Http.Metrics; using HttpClient client = new(new EnrichmentHandler() { InnerHandler = new HttpClientHandler() }); -await client.GetStringAsync("https://httpbin.org/response-headers?Enrichment-Value=A"); -await client.GetStringAsync("https://httpbin.org/response-headers?Enrichment-Value=B"); +await client.GetStringAsync("https://example.com"); sealed class EnrichmentHandler : DelegatingHandler { @@ -293,23 +291,22 @@ sealed class EnrichmentHandler : DelegatingHandler { HttpMetricsEnrichmentContext.AddCallback(request, static context => { - if (context.Response is not null) // Response is null when an exception occurs. + if (context.Request is not null) // Ensure the request is available. { - // Use any information available on the request or the response to emit custom tags. - string? value = context.Response.Headers.GetValues("Enrichment-Value").FirstOrDefault(); - if (value != null) - { - context.AddCustomTag("enrichment_value", value); - } + // Use request information to add custom tags + string? userAgent = context.Request.Headers.UserAgent.ToString(); + context.AddCustomTag("user_agent", userAgent ?? "unknown"); } }); + return base.SendAsync(request, cancellationToken); } } + ``` -If you're working with IHttpClientFactory, you can use AddHttpMessageHandler -to register the EnrichmentHandler: +If you're working with `IHttpClientFactory`, you can use `AddHttpMessageHandler` +to register the `EnrichmentHandler`: ```csharp using Microsoft.Extensions.DependencyInjection; @@ -322,8 +319,7 @@ services.AddHttpClient(Options.DefaultName).AddHttpMessageHandler(() => new Enri ServiceProvider serviceProvider = services.BuildServiceProvider(); HttpClient client = serviceProvider.GetRequiredService(); -await client.GetStringAsync("https://httpbin.org/response-headers?Enrichment-Value=A"); -await client.GetStringAsync("https://httpbin.org/response-headers?Enrichment-Value=B"); +await client.GetStringAsync("https://example.com"); ``` #### .NET Framework From b6315d5d9fa525b0c62b929bc65225dc5cc61a3a Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Tue, 17 Sep 2024 11:06:54 +0200 Subject: [PATCH 05/11] update --- src/OpenTelemetry.Instrumentation.AspNetCore/README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md index 21f5ec43a8..a983251a45 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md @@ -329,13 +329,9 @@ using Microsoft.AspNetCore.Http.Features; var builder = WebApplication.CreateBuilder(args); builder.Services.AddOpenTelemetry() - .WithMetrics(metricsBuilder => - { - metricsBuilder - .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("MyService")) - .AddOtlpExporter() - .AddMeter("Microsoft.AspNetCore.Hosting"); - }); + .WithMetrics(builder => builder + .AddAspNetCoreInstrumentation() + .AddConsoleExporter()); var app = builder.Build(); From 9b83165ece99ecf8187cc69d77554214bff3d0de Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Wed, 18 Sep 2024 09:45:47 +0200 Subject: [PATCH 06/11] remove the string allocation --- src/OpenTelemetry.Instrumentation.AspNetCore/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md index a983251a45..3d4acb2352 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md @@ -341,9 +341,12 @@ app.Use(async (context, next) => var tagsFeature = context.Features.Get(); if (tagsFeature != null) { - // Add a custom tag based on the "utm_medium" query parameter - var source = context.Request.Query["utm_medium"].ToString(); - tagsFeature.Tags.Add(new KeyValuePair("utm_medium", source)); + string utmMediumKey = "utm_medium"; + + if (context.Request.Query.TryGetValue(utmMediumKey, out var source) && !StringValues.IsNullOrEmpty(source)) + { + tagsFeature.Tags.Add(new KeyValuePair(utmMediumKey, source)); + } } await next.Invoke(); From 84a2b8c33d1fd6eb83c59f38ad03f3cbcd7d0160 Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Mon, 30 Sep 2024 15:48:08 +0200 Subject: [PATCH 07/11] update --- .../README.md | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md index 3d4acb2352..04f93f06d8 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md @@ -317,9 +317,27 @@ the library you can do so as follows: > Only applicable for .NET 8 and newer. ASP.NET Core supports enriching request metrics using `IHttpMetricsTagsFeature`. -This feature allows you to add custom tags to metrics. +This feature allows you to add custom tags to the default HTTP metrics collected + by ASP.NET Core. -Here's an example of enriching the `http.server.request.duration` metric: +### Automatic Application to HTTP Metrics + +The tags added via `IHttpMetricsTagsFeature` are automatically applied to **all** +the HTTP metrics provided by ASP.NET Core's OpenTelemetry instrumentation, such as: + +* `http.server.request.duration` +* `http.server.request.count` +* `http.server.request.size` +* `http.server.response.size` + +If you are enriching metrics using `IHttpMetricsTagsFeature`, the enrichment will +apply to **all** relevant HTTP metrics unless further filtering is done during +the metrics collection/export phase. + +### Example: Enriching `http.server.request.duration` Metric + +Here's an example of enriching the `http.server.request.duration` metric by +adding a custom tag: ```csharp using OpenTelemetry.Metrics; @@ -359,10 +377,16 @@ app.Run(); In this example: -* Middleware is used to add a custom tag `utm_medium` to the - `http.server.request.duration` metric. -* `IHttpMetricsTagsFeature` is obtained from the `HttpContext`. - This feature is only available if someone is listening to the metric. +* Automatic Metric Enrichment: The IHttpMetricsTagsFeature enriches all relevant + HTTP metrics(like http.server.request.duration) by default. There is no need to + explicitly specify the metric you want to enrich. +* Context-Specific Tags: In the middleware, custom tags such as utm_medium are + added to the request's metrics context. These tags will automatically appear in + the exported data for any related metrics. +* Customizing Exported Metrics: To focus on enriching or exporting a specific + metric (e.g., http.server.request.duration), you can control this at the exporting + stage, either by filtering specific metrics in the exporter or by customizing + the telemetry pipeline configuration. #### RecordException From 45e662366477ba333b294bffb20ed7a3c833a312 Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Mon, 7 Oct 2024 09:23:55 +0200 Subject: [PATCH 08/11] Update src/OpenTelemetry.Instrumentation.AspNetCore/README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Piotr Kiełkowicz --- src/OpenTelemetry.Instrumentation.AspNetCore/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md index 04f93f06d8..370887dc46 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md @@ -377,8 +377,8 @@ app.Run(); In this example: -* Automatic Metric Enrichment: The IHttpMetricsTagsFeature enriches all relevant - HTTP metrics(like http.server.request.duration) by default. There is no need to +* Automatic Metric Enrichment: The `IHttpMetricsTagsFeature` enriches all relevant + HTTP metrics (like `http.server.request.duration`) by default. There is no need to explicitly specify the metric you want to enrich. * Context-Specific Tags: In the middleware, custom tags such as utm_medium are added to the request's metrics context. These tags will automatically appear in From 373e887393a32b17630611f3819dcb3b7b714fca Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Mon, 7 Oct 2024 09:24:10 +0200 Subject: [PATCH 09/11] Update src/OpenTelemetry.Instrumentation.AspNetCore/README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Piotr Kiełkowicz --- src/OpenTelemetry.Instrumentation.AspNetCore/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md index 370887dc46..1316939556 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md @@ -384,7 +384,7 @@ In this example: added to the request's metrics context. These tags will automatically appear in the exported data for any related metrics. * Customizing Exported Metrics: To focus on enriching or exporting a specific - metric (e.g., http.server.request.duration), you can control this at the exporting + metric (e.g. `http.server.request.duration`), you can control this at the exporting stage, either by filtering specific metrics in the exporter or by customizing the telemetry pipeline configuration. From 3d4c4bc8257f688e1ac3e1ddef1ac5cb2a48d733 Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Mon, 7 Oct 2024 09:24:21 +0200 Subject: [PATCH 10/11] Update src/OpenTelemetry.Instrumentation.Http/README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Piotr Kiełkowicz --- src/OpenTelemetry.Instrumentation.Http/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.Http/README.md b/src/OpenTelemetry.Instrumentation.Http/README.md index 7d2e2c2bcb..ef2e9f3917 100644 --- a/src/OpenTelemetry.Instrumentation.Http/README.md +++ b/src/OpenTelemetry.Instrumentation.Http/README.md @@ -269,7 +269,7 @@ var tracerProvider = Sdk.CreateTracerProviderBuilder() > Only applicable for .NET 8 and newer. Metrics enrichment in HttpClient allows adding custom tags to metrics. - This is especially useful for categorizing metrics in dashboards or alerts. +This is especially useful for categorizing metrics in dashboards or alerts. Using `HttpMetricsEnrichmentContext` for Enrichment To enrich metrics, you can register callbacks with `HttpMetricsEnrichmentContext`. From f554c9d019e7285b54880bb59774bc7b5ae3345d Mon Sep 17 00:00:00 2001 From: Yevhenii Solomchenko Date: Mon, 7 Oct 2024 10:19:45 +0200 Subject: [PATCH 11/11] fix lint --- src/OpenTelemetry.Instrumentation.AspNetCore/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md index 1316939556..b47893748f 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/README.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/README.md @@ -378,8 +378,8 @@ app.Run(); In this example: * Automatic Metric Enrichment: The `IHttpMetricsTagsFeature` enriches all relevant - HTTP metrics (like `http.server.request.duration`) by default. There is no need to - explicitly specify the metric you want to enrich. + HTTP metrics (like `http.server.request.duration`) by default. There is no + need to explicitly specify the metric you want to enrich. * Context-Specific Tags: In the middleware, custom tags such as utm_medium are added to the request's metrics context. These tags will automatically appear in the exported data for any related metrics.