Enum metrics_util::Handle[][src]

pub enum Handle {
    Counter(Arc<AtomicU64>),
    Gauge(Arc<AtomicU64>),
    Histogram(Arc<AtomicBucket<f64>>),
}
Expand description

Basic metric handle.

Provides fast, thread-safe access and storage for the three supported metric types: counters, gauges, and histograms.

Variants

Counter(Arc<AtomicU64>)

A counter.

Gauge(Arc<AtomicU64>)

A gauge.

Histogram(Arc<AtomicBucket<f64>>)

A histogram.

Implementations

impl Handle[src]

pub fn counter() -> Handle[src]

Creates a counter handle.

The counter is initialized to 0.

pub fn gauge() -> Handle[src]

Creates a gauge handle.

The gauge is initialized to 0.

pub fn histogram() -> Handle[src]

Creates a histogram handle.

The histogram handle is initialized to empty.

pub fn increment_counter(&self, value: u64)[src]

Increments this handle as a counter.

Panics if this handle is not a counter.

pub fn update_gauge(&self, value: GaugeValue)[src]

Updates this handle as a gauge.

Panics if this handle is not a gauge.

pub fn record_histogram(&self, value: f64)[src]

Records to this handle as a histogram.

Panics if this handle is not a histogram.

pub fn read_counter(&self) -> u64[src]

Reads this handle as a counter.

Panics if this handle is not a counter.

pub fn read_gauge(&self) -> f64[src]

Reads this handle as a gauge.

Panics if this handle is not a gauge.

pub fn read_histogram(&self) -> Vec<f64>[src]

Reads this handle as a histogram.

Panics if this handle is not a histogram.

pub fn read_histogram_is_empty(&self) -> bool[src]

Reads this handle as a histogram, and whether or not it’s empty.

Panics if this handle is not a histogram.

pub fn read_histogram_with_clear<F>(&self, f: F) where
    F: FnMut(&[f64]), 
[src]

Reads this handle as a histogram incrementally into a closure, and clears the histogram.

The closure f passed in is invoked multiple times with slices of values present in the histogram currently. Once all values have been read, the histogram is cleared of all values.

Panics if this handle is not a histogram.

Trait Implementations

impl Clone for Handle[src]

fn clone(&self) -> Handle[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Handle[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl !RefUnwindSafe for Handle

impl Send for Handle

impl Sync for Handle

impl Unpin for Handle

impl !UnwindSafe for Handle

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T[src]

pub const ALIGN: usize[src]

The alignment of pointer.

type Init = T

The type for initializers.

pub unsafe fn init(init: <T as Pointable>::Init) -> usize[src]

Initializes a with the given initializer. Read more

pub unsafe fn deref<'a>(ptr: usize) -> &'a T[src]

Dereferences the given pointer. Read more

pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T[src]

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)[src]

Drops the object pointed to by the given pointer. Read more

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.