Struct prometheus_client::metrics::gauge::Gauge
source · pub struct Gauge<N = i64, A = AtomicI64> { /* 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 AtomicI64
as a
storage and i64
on the interface by default.
Examples
Using AtomicI64
as storage and i64
on the interface
let gauge: Gauge = Gauge::default();
gauge.set(42);
let _value = 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§
Trait Implementations§
source§impl<N, A> EncodeMetric for Gauge<N, A>where
N: EncodeGaugeValue,
A: Atomic<N>,
impl<N, A> EncodeMetric for Gauge<N, A>where
N: EncodeGaugeValue,
A: Atomic<N>,
source§fn encode(&self, encoder: MetricEncoder<'_>) -> Result<(), Error>
fn encode(&self, encoder: MetricEncoder<'_>) -> Result<(), Error>
Encode the given instance in the OpenMetrics text encoding.
source§fn metric_type(&self) -> MetricType
fn metric_type(&self) -> MetricType
The OpenMetrics metric type of the instance.
source§impl<N, A> TypedMetric for Gauge<N, A>
impl<N, A> TypedMetric for Gauge<N, A>
source§const TYPE: MetricType = MetricType::Gauge
const TYPE: MetricType = MetricType::Gauge
The OpenMetrics metric type.
Auto Trait Implementations§
impl<N, A> RefUnwindSafe for Gauge<N, A>where
A: RefUnwindSafe,
N: RefUnwindSafe,
impl<N, A> Send for Gauge<N, A>
impl<N, A> Sync for Gauge<N, A>
impl<N, A> Unpin for Gauge<N, A>where
N: Unpin,
impl<N, A> UnwindSafe for Gauge<N, A>where
A: RefUnwindSafe,
N: UnwindSafe,
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