Skip to main content

Reporter

Struct Reporter 

Source
pub struct Reporter { /* private fields */ }
Expand description

A set of Sources that are all sampled together.

The reporter can be sampled like any other source through its own Source implementation.

§Normalization

The reporter will attempt to normalize the extents of any metrics sampled from its sources. Normalization will:

  1. Take the current timestamp, now, when sampling metrics.
  2. If the metric sample has no extent, or has a point extent, it will be replaced with now.
  3. If the metric sample has a range extent, the end will be set to now and the start will be now minus the original length. If this would produce an invalid range then the original is kept.

When the std Cargo feature is enabled this will be done automatically. In other cases, normalization won’t happen unless it’s configured by Reporter::normalize_with_clock.

Normalization can be disabled by calling Reporter::without_normalization.

Implementations§

Source§

impl Reporter

Source

pub const fn new() -> Self

Create a new empty reporter.

When the std Cargo feature is enabled, the reporter will normalize timestamps on reported samples using the system clock. When the std Cargo feature is not enabled, the reporter will not attempt to normalize timestamps.

Source

pub fn normalize_with_clock( &mut self, clock: impl Clock + Send + Sync + 'static, ) -> &mut Self

Set the clock the reporter will use to unify timestamps on sampled metrics.

Source

pub fn without_normalization(&mut self) -> &mut Self

Disable the clock, preventing the reporter from normalizing timestamps on sampled metrics.

Source

pub fn add_source( &mut self, source: impl Source + Send + Sync + 'static, ) -> &mut Self

Add a Source to the reporter.

Source

pub fn sample_metrics<S: Sampler>(&self, sampler: S)

Produce a current sample for all metrics.

Source

pub fn emit_metrics<E: Emitter>(&self, emitter: E)

Produce a current sample for all metrics, emitting them as diagnostic events to the given Emitter.

Trait Implementations§

Source§

impl Source for Reporter

Source§

fn sample_metrics<S: Sampler>(&self, sampler: S)

Produce a current sample for all metrics in the source.
Source§

fn and_sample<U>(self, other: U) -> And<Self, U>
where Self: Sized,

Chain this source to other, sampling metrics from both.

Auto Trait Implementations§

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

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

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedSource for T
where T: Source,