-
Notifications
You must be signed in to change notification settings - Fork 34
Add support for the prometheus-client crate
#88
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
Changes from 5 commits
b255f8c
7cbe053
ff161ea
9e402eb
f29aae1
11d052f
9817601
8635ad7
8130657
49410dc
537553e
ecfe52f
e311510
ad830c3
4406f08
43bea12
36f65e2
fb34b11
8f263f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,9 @@ | |
| //! } | ||
| //! ``` | ||
|
|
||
| #[cfg(feature = "prometheus-client")] | ||
| use prometheus_client::encoding::{EncodeLabelValue, LabelValueEncoder}; | ||
|
|
||
| /// A Service-Level Objective (SLO) for a function or group of functions. | ||
| /// | ||
| /// The objective should be given a descriptive name and can represent | ||
|
|
@@ -119,6 +122,10 @@ impl Objective { | |
| } | ||
|
|
||
| /// The percentage of requests that must meet the given criteria (success rate or latency). | ||
| #[cfg_attr( | ||
| feature = "prometheus-client", | ||
| derive(Clone, Debug, PartialEq, Eq, Hash) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can also be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, true. Do you think we should derive all of those traits all of the time (not just when using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. saving |
||
| )] | ||
| #[non_exhaustive] | ||
| pub enum ObjectivePercentile { | ||
| /// 90% | ||
|
|
@@ -152,7 +159,18 @@ impl ObjectivePercentile { | |
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "prometheus-client")] | ||
| impl EncodeLabelValue for ObjectivePercentile { | ||
| fn encode(&self, encoder: &mut LabelValueEncoder) -> Result<(), std::fmt::Error> { | ||
| self.as_str().encode(encoder) | ||
| } | ||
| } | ||
|
|
||
| /// The latency threshold, in milliseoncds, for a given objective. | ||
| #[cfg_attr( | ||
| feature = "prometheus-client", | ||
| derive(Clone, Debug, PartialEq, Eq, Hash) | ||
| )] | ||
| #[non_exhaustive] | ||
| pub enum ObjectiveLatency { | ||
| /// 5 milliseconds | ||
|
|
@@ -234,3 +252,10 @@ impl ObjectiveLatency { | |
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "prometheus-client")] | ||
| impl EncodeLabelValue for ObjectiveLatency { | ||
| fn encode(&self, encoder: &mut LabelValueEncoder) -> Result<(), std::fmt::Error> { | ||
| self.as_str().encode(encoder) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.