opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

Custom tags for AspNetCore metrics

Open ImoutoChan opened this issue 1 year ago • 7 comments

Feature Request

Is there any way to add custom tags for /metrics in OpenTelemetry.Instrumentation.AspNetCore? I want to add environment and service name.

Describe the solution you'd like:

It would be great to have the ability to enrich default metrics with custom tags. For example, it can look like this:

.AddAspNetCoreInstrumentation(x => x.CustomStaticTags = new Dictionary<string, string>()
{
    ["environment"] = "stage",
    ["application"] = "orders"
})

Describe alternatives you've considered.

The only alternative I see is to copy-paste MeterProviderBuilderExtensions.cs AspNetCoreMetrics.cs HttpInMetricsListener.cs DiagnosticSourceSubscriber.cs HttpTagHelper.cs ListenerHandler.cs

to my project and add a way to customize tags myself.

ImoutoChan avatar Nov 01 '22 08:11 ImoutoChan