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§
Source§impl<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) -> Twhere
F: FnOnce() -> T,
pub fn observe_closure_duration<F, T>(&self, labels: &L, f: F) -> Twhere
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> Freeze for HistogramWithLabels<L>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more