-
Notifications
You must be signed in to change notification settings - Fork 734
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
add support for attributes in tracing-opentelemetry::MetricsLayer
#2337
Comments
I opened PR #2354 to implement your proposed solution after searching for similar functionality myself. I also think that including the explicit One case where this could a bit awkward when metrics and messages which are captured together contain overlapping attributes, such as info!(
monotonic_counter.foo = 1,
attribute.bar = "example",
bar = "example",
"Example Event"
); |
Hey folks, any updates on the PR from above? This would be an amazing feature to have. |
Sorry, I haven't had time to review this PR yet. I'll try to find the time to in the near future! |
howdy, @hawkw, wondering how this is going? we're fairly interested in it; so, let me know how we can help get it merged! ❤️ |
This seems fixed in https://github.com/tokio-rs/tracing-opentelemetry by tokio-rs/tracing-opentelemetry#43. |
Feature Request
Crates
tracing-opentelemetry
Motivation
Right now,
MetricsLayer
doesn't support specifying attributes when recording metrics value, but passes an empty slice instead.As a consequence, users of this crate have to create multiple metrics instead of using one but with different attributes values. When exposing metrics through an OpenMetrics HTTP endpoint, this means exposing metrics looking like this:
Instead of like this, which would simplify aggregations, as many observability solutions can aggregate per metrics, then allow to query for specific attribute values:
Supporting attributes would also allow using multiple attributes, instead of chaining those values in a single custom metric.
Proposal
I propose to utilise the prefix
attribute.
for capturing attributes inEvent
s, which would then be used to populate attributes when recording metrics:Alternatives
Discard the prefix
We could discard the
attribute.
prefix, but this could cause a significant increase in the number of recorded attributes for high cardinality values. By utilising a prefix, we increase the likelihood of users actually meaning to use this value as an attribute.For example, if developers records both metrics and messages in a single
Event
, with the messages being dynamically generated, this would create a new combination of attributes.For example, this code snippet:
Would result in the following metrics:
The text was updated successfully, but these errors were encountered: