Skip to main content

Batched

Struct Batched 

Source
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>

Source

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

pub const fn get(&self) -> M::Value

The writer’s total, including updates not yet published.

Source§

impl Batched<Counter>

Source

pub fn inc(&mut self)

Increase the writer’s total by one.

Source

pub fn inc_by(&mut self, value: u64)

Increase the writer’s total by value.

Source§

impl Batched<Gauge>

Source

pub fn inc(&mut self)

Increase the writer’s total by one.

Source

pub fn dec(&mut self)

Decrease the writer’s total by one.

Source

pub fn inc_by(&mut self, value: GaugeValue)

Increase the writer’s total by value.

Source

pub fn dec_by(&mut self, value: GaugeValue)

Decrease the writer’s total by value.

Source

pub fn set(&mut self, value: GaugeValue)

Set the writer’s total to value.

Trait Implementations§

Source§

impl<M: Batchable> Drop for Batched<M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<M> Freeze for Batched<M>
where M: Freeze, <M as Sealed>::Value: Freeze,

§

impl<M> RefUnwindSafe for Batched<M>
where M: RefUnwindSafe, <M as Sealed>::Value: RefUnwindSafe,

§

impl<M> Send for Batched<M>
where M: Send, <M as Sealed>::Value: Send,

§

impl<M> Sync for Batched<M>
where M: Sync, <M as Sealed>::Value: Sync,

§

impl<M> Unpin for Batched<M>
where M: Unpin, <M as Sealed>::Value: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Threaded<T> for T

Source§

type Rest = ()

The outputs beyond the threaded value.
Source§

fn split(self) -> (T, ())

Splits into the threaded value and the extra outputs.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more