pub struct ContextMetricsSampler<'a> { /* private fields */ }Expand description
Tracks successive context metrics snapshots and computes deltas between them.
Implementations§
Source§impl<'a> ContextMetricsSampler<'a>
impl<'a> ContextMetricsSampler<'a>
pub fn new(context: &'a Context) -> Self
pub fn snapshot(&self) -> ContextMetricsSnapshot
pub fn sample(&mut self) -> Option<ContextMetricsDelta>
Sourcepub fn sample_snapshot(
&mut self,
current: ContextMetricsSnapshot,
) -> Option<ContextMetricsDelta>
pub fn sample_snapshot( &mut self, current: ContextMetricsSnapshot, ) -> Option<ContextMetricsDelta>
Computes a delta from a caller-supplied snapshot using its wall-clock
captured_at timestamp. This clears the monotonic baseline used by
sample() and sample_snapshot_at().
Sourcepub fn sample_snapshot_at(
&mut self,
current: ContextMetricsSnapshot,
sampled_at: Instant,
) -> Option<ContextMetricsDelta>
pub fn sample_snapshot_at( &mut self, current: ContextMetricsSnapshot, sampled_at: Instant, ) -> Option<ContextMetricsDelta>
Computes a delta from a caller-supplied snapshot and monotonic capture
instant. The first call after sample_snapshot() establishes a new
monotonic baseline and returns None.
pub fn reset(&mut self)
pub fn previous(&self) -> Option<&ContextMetricsSnapshot>
Sourcepub fn delta(&mut self) -> Option<ContextMetricsDelta>
pub fn delta(&mut self) -> Option<ContextMetricsDelta>
Convenience alias for sample().
Trait Implementations§
Source§impl<'a> Clone for ContextMetricsSampler<'a>
impl<'a> Clone for ContextMetricsSampler<'a>
Source§fn clone(&self) -> ContextMetricsSampler<'a>
fn clone(&self) -> ContextMetricsSampler<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for ContextMetricsSampler<'a>
impl<'a> RefUnwindSafe for ContextMetricsSampler<'a>
impl<'a> Send for ContextMetricsSampler<'a>
impl<'a> Sync for ContextMetricsSampler<'a>
impl<'a> Unpin for ContextMetricsSampler<'a>
impl<'a> UnsafeUnpin for ContextMetricsSampler<'a>
impl<'a> UnwindSafe for ContextMetricsSampler<'a>
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