Skip to content

Custom tags for AspNetCore metrics #1772

Open
@ImoutoChan

Description

@ImoutoChan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions