dotnet / dotnet/aspnetcore

Allow removal or alteration of framework-added metric tags.

Open
#57,831 1 comment 0 reactions 0 assignees View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I have a multi-tenant system where I am starting to record metrics. There are some important tags that I need to add to the framework provided `http.server.request.duration` such as user, tenant. I can do this via the `IHttpMetricsTagsFeature` which provides a Tags collection.

What I can't do it prevent the addition of, or remove after their addition, of framework provided tags like `url.scheme` or `network.protocol.version` which have no value to me. These tags seem to be added very late in the lifecycle of the request so when I have access to the `IHttpMetricsTagsFeature.Tags` through middleware the framework added tags are not present.

In the opentelemetry aspnet (not core) instrumentation there is a callback available which is called once tags have been added and the metric is about to be dispatched. This pattern is ideal. The opentelemetry aspnetcore instrumentation does not have this callback because the metric is now raised by the framework.

### Describe the solution you'd like

I would like to have a callback method that I can use to edit the tags on the framework-provided `http.server.request.duration` event allowing me to remove unwanted tags.

### Additional context

The tags can be removed if you are using the otelcol-contrib collector to route data from your app to the destination. This costs resources that could be better spent. It would be better not to generate unwanted information to start with.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.