Skip to content

Support for adding static tags to specific meter and/or instruments #4316

@dpk83

Description

@dpk83

Feature Request

Is your feature request related to a problem?
Yes

If so, provide a concise description of the problem.

Currently, the metric agents/extension that we use is working on adding a feature to direct different metrics to different namespaces. The way this feature is being added is by means of a tag i.e. if a user wants to direct a specific metric to a non-default namespace then the instrument needs to add an additional dimension that carries the namespace to override the default.

It's not feasible for the specific instrument add/record calls to add the specific dimensions as becomes too messy to use. E.g. consider the scenario of third party library that emits metrics. As a service owner I use 10s of 3rd party libraries that emit metrics and I want to emit metrics from different libraries to different namespaces. Not all 3rd party libraries can't be modified to support the same feature so I need an ability to add some static properties for all metrics emitted by meter objects or specific instruments.

Currently .NET instrument APIs don't provide any such mechanism and OpenTelemetry metrics implementation also doesn't provide any such mechanism either.

Describe the solution you'd like:

I should be able to configure some static tags to be included for specific instruments and/or all instruments emitted from a specific meter instance, possibly at the startup configuration time.

What do you want to happen instead? What is the expected behavior?

Describe alternatives you've considered.

There are no straightforward alternatives today when using .NET Meter APIs and OpenTelemetry. The only alternative is to wrap .NET Meter APIs behind custom meter/instrument APIs, so metrics can be customized before they are fed into .NET meter

Additional Context

Add any other context about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds-runtime-changeIssues which likely require changes from dotnet runtime - typically DiagnosticSource package

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions