pub struct Batched<M: Batchable> { /* private fields */ }Expand description
A metric handle that publishes one writer’s updates to a shared metric in batches.
The handle keeps the writer’s total and adds the total’s change since the previous publication
to the shared metric after every size updates and when the handle is dropped. The shared
metric includes each update made before the writer’s latest publication exactly once, and none
made after it.
Writers that update one shared metric directly contend on its cache line with every update. Giving each writer its own handle limits that to one update of the shared metric per batch.
Implementations§
Source§impl<M: Batchable> Batched<M>
impl<M: Batchable> Batched<M>
Sourcepub fn new(shared: &Registered<M>, size: NonZeroU32) -> Self
pub fn new(shared: &Registered<M>, size: NonZeroU32) -> Self
Create a handle that publishes to shared’s metric after every size updates. The
writer’s total starts at zero, and every update counts toward a batch, including one that
leaves the total unchanged.
The handle does not hold shared’s registration, so the metric leaves the registry when
the last Registered handle to it is dropped. This handle does not publish to a fresh
metric registered under the same name afterwards.
Source§impl Batched<Gauge>
impl Batched<Gauge>
Sourcepub fn inc_by(&mut self, value: GaugeValue)
pub fn inc_by(&mut self, value: GaugeValue)
Increase the writer’s total by value.
Sourcepub fn dec_by(&mut self, value: GaugeValue)
pub fn dec_by(&mut self, value: GaugeValue)
Decrease the writer’s total by value.
Sourcepub fn set(&mut self, value: GaugeValue)
pub fn set(&mut self, value: GaugeValue)
Set the writer’s total to value.
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for Batched<M>
impl<M> RefUnwindSafe for Batched<M>where
M: RefUnwindSafe,
<M as Sealed>::Value: RefUnwindSafe,
impl<M> Send for Batched<M>
impl<M> Sync for Batched<M>
impl<M> Unpin for Batched<M>
impl<M> UnsafeUnpin for Batched<M>where
M: UnsafeUnpin,
<M as Sealed>::Value: UnsafeUnpin,
impl<M> UnwindSafe for Batched<M>where
M: UnwindSafe,
<M as Sealed>::Value: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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