ObservationBatch

Struct ObservationBatch 

Source
pub struct ObservationBatch<'a, P>
where P: PublishModel,
{ /* private fields */ }
Expand description

A batch of pending observations for an event, waiting for the magnitude to be specified.

Implementations§

Source§

impl<P> ObservationBatch<'_, P>
where P: PublishModel,

Source

pub fn observe_once(&self)

Observes a batch of events that have no explicit magnitude.

By convention, this is represented as a magnitude of 1. We expose a separate method for this to make it clear that the magnitude has no inherent meaning.

Source

pub fn observe(&self, magnitude: impl AsPrimitive<Magnitude>)

Observes a batch of events with a specific magnitude.

Source

pub fn observe_millis(&self, duration: Duration)

Observes an event with the magnitude being the indicated duration in milliseconds.

Only the whole number part of the duration is used - fractional milliseconds are ignored. Values outside the i64 range are not guaranteed to be correctly represented.

Source

pub fn observe_duration_millis<F, R>(&self, f: F) -> R
where F: FnOnce() -> R,

Observes the duration of a function call, in milliseconds.

Trait Implementations§

Source§

impl<'a, P> Debug for ObservationBatch<'a, P>
where P: PublishModel + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P> Observe for ObservationBatch<'_, P>
where P: PublishModel,

Source§

fn observe_once(&self)

Observes an event that has no explicit magnitude. Read more
Source§

fn observe(&self, magnitude: impl AsPrimitive<Magnitude>)

Observes an event with a specific magnitude. Read more
Source§

fn observe_millis(&self, duration: Duration)

Observes an event with the magnitude being the indicated duration in milliseconds. Read more
Source§

fn observe_duration_millis<F, R>(&self, f: F) -> R
where F: FnOnce() -> R,

Observes the duration of a function call, in milliseconds. Read more

Auto Trait Implementations§

§

impl<'a, P> Freeze for ObservationBatch<'a, P>

§

impl<'a, P> RefUnwindSafe for ObservationBatch<'a, P>
where P: RefUnwindSafe,

§

impl<'a, P> !Send for ObservationBatch<'a, P>

§

impl<'a, P> !Sync for ObservationBatch<'a, P>

§

impl<'a, P> Unpin for ObservationBatch<'a, P>

§

impl<'a, P> UnwindSafe for ObservationBatch<'a, P>
where P: RefUnwindSafe,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.