MetricGauge

Struct MetricGauge 

Source
pub struct MetricGauge { /* private fields */ }
Expand description

Current-value gauge (atomic i64).

Gauges go up and down — use them for values like “active leases” or “connections open”.

§Examples

use grafos_observe::MetricGauge;

let g = MetricGauge::new();
g.inc();
g.inc();
g.dec();
assert_eq!(g.get(), 1);

g.set(-5);
assert_eq!(g.get(), -5);

Implementations§

Source§

impl MetricGauge

Source

pub const fn new() -> Self

Create a new gauge starting at zero.

Source

pub fn inc(&self)

Increment the gauge by one.

Source

pub fn dec(&self)

Decrement the gauge by one.

Source

pub fn set(&self, val: i64)

Set the gauge to an absolute value.

Source

pub fn get(&self) -> i64

Read the current gauge value.

Trait Implementations§

Source§

impl Default for MetricGauge

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.