Skip to content
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

Closed
austince opened this issue Nov 28, 2022 · 5 comments
Closed

Support WithAttributes for default MeterProvider #3494

austince opened this issue Nov 28, 2022 · 5 comments
Labels
blocked:specification Waiting on clarification of the OpenTelemetry specification before progress can be made enhancement New feature or request

Comments

@austince
Copy link

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.

// WithAttributes adds the attributes related to a span life-cycle event.
// These attributes are used to describe the work a Span represents when this
// option is provided to a Span's start or end events. Otherwise, these
// attributes provide additional information about the event being recorded
// (e.g. error, state change, processing progress, system event).
//
// If multiple of these options are passed the attributes of each successive
// option will extend the attributes instead of overwriting. There is no
// guarantee of uniqueness in the resulting attributes.
func WithAttributes(attributes ...attribute.KeyValue) SpanStartEventOption {
return attributeOption(attributes)
}

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.Clients. 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 new MeterOption that accepts a slice of attributes to attach.

Alternatives

Use the Resource in the MeterProvider. 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

@austince austince added the enhancement New feature or request label Nov 28, 2022
@Aneurysm9 Aneurysm9 added the blocked:specification Waiting on clarification of the OpenTelemetry specification before progress can be made label Nov 28, 2022
@Aneurysm9
Copy link
Member

This functionality would need to be defined in the OpenTelemetry Specification before we could begin any implementation here.

@austince
Copy link
Author

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

[since 1.13.0] attributes (optional): Specifies the instrumentation scope attributes to associate with emitted telemetry.

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.

@austince
Copy link
Author

austince commented Nov 28, 2022

Or is this a duplicate of #3368? EDIT: I think so, I'll close this and track that.

@austince austince closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2022
@Aneurysm9
Copy link
Member

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.

@austince
Copy link
Author

Hmm, alright. I've seen those comments elsewhere. Thanks for the pointers, I'll keep up with those discussions 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked:specification Waiting on clarification of the OpenTelemetry specification before progress can be made enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants