Struct prometheus_utils::HistogramWithLabels
source · [−]pub struct HistogramWithLabels<L: Labels> { /* private fields */ }Expand description
A Prometheus histogram metric, with labels described by the type L.
The type L must implement the Labels trait; see the documentation for that trait
for an overview of Prometheus metric labels.
Implementations
sourceimpl<L: Labels> HistogramWithLabels<L>
impl<L: Labels> HistogramWithLabels<L>
sourcepub fn register_new(name: &str, help: &str) -> Self
pub fn register_new(name: &str, help: &str) -> Self
Construct and immediately register a new HistogramWithLabels instance.
sourcepub fn register_new_with_buckets(
name: &str,
help: &str,
buckets: Vec<f64>
) -> Self
pub fn register_new_with_buckets(
name: &str,
help: &str,
buckets: Vec<f64>
) -> Self
Construct and immediately register a new HistogramWithLabels instance.
This will use the provided buckets when registering the underlying HistogramVec.
sourcepub fn observe(&self, labels: &L, value: f64)
pub fn observe(&self, labels: &L, value: f64)
Add a single observation to the histogram with the provided labels.
sourcepub fn start_timer(&self, labels: &L) -> HistogramTimer
pub fn start_timer(&self, labels: &L) -> HistogramTimer
Return a HistogramTimer to track a duration, using the provided labels.
sourcepub fn observe_closure_duration<F, T>(&self, labels: &L, f: F) -> T where
F: FnOnce() -> T,
pub fn observe_closure_duration<F, T>(&self, labels: &L, f: F) -> T where
F: FnOnce() -> T,
Observe execution time of a closure, in seconds.
sourcepub fn get_sample_sum(&self, labels: &L) -> f64
pub fn get_sample_sum(&self, labels: &L) -> f64
Return accumulated sum of all samples, using the provided labels.
sourcepub fn get_sample_count(&self, labels: &L) -> u64
pub fn get_sample_count(&self, labels: &L) -> u64
Return count of all samples, using the provided labels.
Auto Trait Implementations
impl<L> !RefUnwindSafe for HistogramWithLabels<L>
impl<L> Send for HistogramWithLabels<L> where
L: Send,
impl<L> Sync for HistogramWithLabels<L> where
L: Sync,
impl<L> Unpin for HistogramWithLabels<L> where
L: Unpin,
impl<L> !UnwindSafe for HistogramWithLabels<L>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more