-
Notifications
You must be signed in to change notification settings - Fork 82
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
Impl EncodeLabelValue for Option<T> #137
Conversation
Signed-off-by: Evan Schwartz <[email protected]>
I've implemented an equivalent of this where I use this crate to allow For derived |
Can you expand on the use-case for a metric with a label key but an empty string as label value? Ideally the use-case and the corresponding Prometheus query? Thank you for your upstream work! |
I'm working on the Autometrics project, which generates metrics from function names. We have a feature where you can define Service-Level Objectives in your code and then attach them to metrics. This works by adding some "objective"-related labels to the metrics produced by each function. My label set thus contains some values that will always be there and some that are optional. To be honest, it doesn't matter to me whether they show up as label keys with empty values or just aren't attached at all (and I'm not sure if it makes a difference to Prometheus as querying Here is a detailed write-up of the SLO feature in autometrics-rs: https://fiberplane.com/blog/autometrics-rs-0-3-defining-service-level-objectives-in-rust-source-code |
Thanks @emschwartz and @drbrain for the additional input.
Backing this up:
https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#label With that, I am fine either way. In case neither of you objects to this pull request as is, would you @emschwartz mind bumping the minor version and adding a changelog entry? |
Released through #141 as |
Thanks @mxinden! |
Alternatively, the
EncodeLabelSet
derive macro could add code that checks whether the value of theOption
and only encodes theSome
value