pub struct Gauge<N = u64, A = AtomicU64> { /* private fields */ }
Expand description

Open Metrics Gauge to record current measurements.

Single increasing, decreasing or constant value metric.

Gauge is generic over the actual data type tracking the Gauge state as well as the data type used to interact with the Gauge. Out of convenience the generic type parameters are set to use an AtomicU64 as a storage and u64 on the interface by default.

Examples

Using AtomicU64 as storage and u64 on the interface

let gauge: Gauge = Gauge::default();
gauge.set(42u64);
let _value: u64 = gauge.get();

Using AtomicU64 as storage and f64 on the interface

let gauge = Gauge::<f64, AtomicU64>::default();
gauge.set(42.0);
let _value: f64 = gauge.get();

Implementations§

Increase the Gauge by 1, returning the previous value.

Increase the Gauge by v, returning the previous value.

Decrease the Gauge by 1, returning the previous value.

Decrease the Gauge by v, returning the previous value.

Sets the Gauge to v, returning the previous value.

Get the current value of the Gauge.

Exposes the inner atomic type of the Gauge.

This should only be used for advanced use-cases which are not directly supported by the library.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.