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,
impl<P> ObservationBatch<'_, P>where
P: PublishModel,
Sourcepub fn observe_once(&self)
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.
Sourcepub fn observe(&self, magnitude: impl AsPrimitive<Magnitude>)
pub fn observe(&self, magnitude: impl AsPrimitive<Magnitude>)
Observes a batch of events with a specific magnitude.
Sourcepub fn observe_millis(&self, duration: Duration)
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.
Sourcepub fn observe_duration_millis<F, R>(&self, f: F) -> Rwhere
F: FnOnce() -> R,
pub fn observe_duration_millis<F, R>(&self, f: F) -> Rwhere
F: FnOnce() -> R,
Observes the duration of a function call, in milliseconds.
Uses a low-precision clock optimized for high-frequency capture. The measurement has a granularity of roughly 1-20 ms. Durations shorter than the granularity may appear as zero.