-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Feature] Adds a histogram label #2357
Conversation
@collinc97 can you adjust the settings so we can add @miazn as reviewer? |
We can actually remove |
metrics/src/lib.rs
Outdated
@@ -98,3 +98,17 @@ pub fn histogram<V: Into<f64>>(name: &'static str, value: V) { | |||
let histogram = ::metrics::histogram!(name); | |||
histogram.record(value.into()); | |||
} | |||
|
|||
pub fn histogram_label<V: Into<f64>>(name: &'static str, label_key: &'static str, label_value: String, value: V) { | |||
let labels = vec![::metrics::Label::new(label_key, label_value)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are only using a string label key and value, it might be easier to just use the macro, as i did here:
https://github.com/AleoHQ/snarkOS/pull/3064/files#diff-8663d09365b76641c32c45870cbd1915ab198258eb6b823b0aa779128a5b4ff1R93
this makes it cleaner to add the label function to the other two types (counter and gauge), which we should probably do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, now I switched to owned string for the label value, it's possible to use the macro. This was giving trouble with 'static
when it was still a &str
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add label variants to the gauge and counter too, but there's no need at the moment?
I kept the register functions for backwards compatibility. They were already useless when we bumped to |
ecf291e
to
839175e
Compare
Motivation
This adds a
histogram_label
method to allow passing a label to the histogram. A limitation is that you can only attach one label.