-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support WithAttributes
for default MeterProvider
#3494
Comments
This functionality would need to be defined in the OpenTelemetry Specification before we could begin any implementation here. |
It looks like this was actually already added to the spec in 1.13.0: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#get-a-meter
Part of the "Scope Attributes" effort: https://github.com/open-telemetry/oteps/blob/main/text/0201-scope-attributes.md#meter Do you read this the same way? If so, I can update this issue to reflect the ask better. I'd also be happy to work on a PR. |
Or is this a duplicate of #3368? EDIT: I think so, I'll close this and track that. |
Instrumentation scope attributes may be the thing you're looking for, but there are still unresolved questions in the spec SIG regarding whether they are identifying for instruments produced by a meter bearing them or not. |
Hmm, alright. I've seen those comments elsewhere. Thanks for the pointers, I'll keep up with those discussions 👍🏼 |
Problem Statement
For adding a static set of attributes to spans, the SpanConfig offers a nice way (along with the
WithAttributes
option builder) to accomplish this.opentelemetry-go/trace/config.go
Lines 218 to 229 in 7aba25d
There doesn't seem to be compatible functionality for the Metrics API. The motivation is the same as for spans, where some meters could be given additional information about what is being metered.
Let's say we have two k8s services that our process talks to via
http.Client
s. We want to track the number of requests and have the ability to group by service name. The conventional attributes are too low-level to be able to do this nicely.Proposed Solution
Similar to the
WithAttributes(..)
func for spans, we could add a newMeterOption
that accepts a slice of attributes to attach.Alternatives
Use the
Resource
in theMeterProvider
. This seems to be a good place for global attributes but not for dynamic local ones.Prior Art
I can't find any similar examples in the Java or .NET implementations.
Additional Context
Discussed a bit on Slack: https://cloud-native.slack.com/archives/C01NPAXACKT/p1669499929785919
The text was updated successfully, but these errors were encountered: