open-telemetry / opentelemetry-dotnet

The OpenTelemetry .NET Client
https://opentelemetry.io
Apache License 2.0
3.22k stars 763 forks source link

Support dropping of specific attributes from instrument #4427

Open dpk83 opened 1 year ago

dpk83 commented 1 year ago

Feature Request

Is your feature request related to a problem?

We need the ability to drop specific attributes from reported metrics.

Taking the example from the View spec.

For example, an HTTP server library might expose HTTP verb (e.g. GET, POST) and HTTP status code (e.g. 200, 301, 404). The application developer might only care about HTTP status code (e.g. reporting the total count of HTTP requests for each HTTP status code).

The SDK currently provides an option to specify a set of keys which are the only ones to be included, however in our scenario we support dynamic enrichment of metrics so some of the attributes are not known at the time of creation of the instrument. So to drop the specific instruments we need the ability to specify the list of attributes which needs to be dropped and rest all needs to be included in reported metrics.

Currently support only provide the option to include certain attributes while dropping rest of the attributes which doesn't cover the above scenario and is not sufficient.

Describe the solution you'd like:

Need ability to specify a set of attributes (as part of the View) which needs to be dropped from the metric (if exists).

Describe alternatives you've considered.

The only alternative is to capture the emitted metric and create a completely new metric which drops the desired attributes while dropping the original metric completely. This is unacceptable alternative though.

Additional Context

dpk83 commented 1 year ago

@noahfalk This is one missing piece of support that will be needed from either OpenTelemetry SDK or directly from .NET Meter API to be able to consume .NET metrics that James plugged in. I assumed this should be coming from OpenTelemetry SDK based on the other similar features like renaming metric, including only specific attributes etc.

FYI @reyang

reyang commented 1 year ago

What's missing? https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/metrics/customizing-the-sdk#select-specific-tags

reyang commented 1 year ago

If there is additional feature needed which is not captured by the SDK spec, file issue in the spec repo.

dpk83 commented 1 year ago

@reyang Created an issue on spec as well https://github.com/open-telemetry/opentelemetry-specification/issues/3441

github-actions[bot] commented 3 weeks ago

This issue was marked stale due to lack of activity and will be closed in 7 days. Commenting will instruct the bot to automatically remove the label. This bot runs once per day.

cijothomas commented 3 weeks ago

Spec allows this now, https://github.com/open-telemetry/opentelemetry-specification/pull/4188 So this issue must be un-stale