pub struct Gauge(/* private fields */);
Expand description
A gauge. Indicates the current value of some host parameter.
In case of overflow/underflow the gauge will wrap around. However, internally it uses a signed 64-bit integer so for most use cases this should be unlikely.
§Example
#[metric(name = "my.gauge")]
static A_METHOD_RUNNING: Gauge = Gauge::new();
fn a_method() {
A_METHOD_RUNNING.increment();
// ...
A_METHOD_RUNNING.decrement();
}
Implementations§
source§impl Gauge
impl Gauge
sourcepub const fn with_value(value: i64) -> Self
pub const fn with_value(value: i64) -> Self
Create a new guage with the provided initial value.
sourcepub fn increment(&self) -> i64
pub fn increment(&self) -> i64
Increment the value of this gauge by 1.
Returns the old value of the gauge.
sourcepub fn decrement(&self) -> i64
pub fn decrement(&self) -> i64
Decrement the value of this gauge by 1.
Returns the old value of the gauge.
sourcepub fn add(&self, value: i64) -> i64
pub fn add(&self, value: i64) -> i64
Increase the value of this gauge by value
.
Returns the od value of the gauge.
sourcepub fn sub(&self, value: i64) -> i64
pub fn sub(&self, value: i64) -> i64
Decrease the value of this gauge by value
.
Returns the od value of the gauge.
pub fn value(&self) -> i64
pub fn set(&self, value: i64) -> i64
pub fn reset(&self) -> i64
Trait Implementations§
source§impl Metric for Gauge
impl Metric for Gauge
source§fn as_any(&self) -> Option<&dyn Any>
fn as_any(&self) -> Option<&dyn Any>
Get the current metric as an
Any
instance. This is meant to allow
custom processing for known metric types.source§fn value(&self) -> Option<Value<'_>>
fn value(&self) -> Option<Value<'_>>
Get the value of the current metric, should it be enabled. Read more
source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Indicate whether this metric has been set up. Read more
Auto Trait Implementations§
impl !Freeze for Gauge
impl RefUnwindSafe for Gauge
impl Send for Gauge
impl Sync for Gauge
impl Unpin for Gauge
impl UnwindSafe for Gauge
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