pub struct Gauge<N = i64, A = Atomic<i64>> { /* 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§impl GaugeExt for Gauge
impl GaugeExt for Gauge
Source§fn try_set<T: TryInto<GaugeValue>>(
&self,
value: T,
) -> Result<GaugeValue, T::Error>
fn try_set<T: TryInto<GaugeValue>>( &self, value: T, ) -> Result<GaugeValue, T::Error>
Set a gauge from a lossless integer conversion.
Source§fn try_set_max<T: TryInto<GaugeValue> + Copy>(
&self,
value: T,
) -> Result<GaugeValue, T::Error>
fn try_set_max<T: TryInto<GaugeValue> + Copy>( &self, value: T, ) -> Result<GaugeValue, T::Error>
Atomically raise a gauge to at least the provided value.
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> Freeze for Gauge<N, A>
impl<N, A> RefUnwindSafe for Gauge<N, A>where
N: RefUnwindSafe,
A: 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> UnsafeUnpin for Gauge<N, A>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more