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:
- Take the current timestamp,
now, when sampling metrics. - If the metric sample has no extent, or has a point extent, it will be replaced with
now. - If the metric sample has a range extent, the end will be set to
nowand the start will benowminus 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
impl Reporter
Sourcepub const fn new() -> Self
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.
Sourcepub fn normalize_with_clock(
&mut self,
clock: impl Clock + Send + Sync + 'static,
) -> &mut Self
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.
Sourcepub fn without_normalization(&mut self) -> &mut Self
pub fn without_normalization(&mut self) -> &mut Self
Disable the clock, preventing the reporter from normalizing timestamps on sampled metrics.
Sourcepub fn add_source(
&mut self,
source: impl Source + Send + Sync + 'static,
) -> &mut Self
pub fn add_source( &mut self, source: impl Source + Send + Sync + 'static, ) -> &mut Self
Add a Source to the reporter.
Sourcepub fn sample_metrics<S: Sampler>(&self, sampler: S)
pub fn sample_metrics<S: Sampler>(&self, sampler: S)
Produce a current sample for all metrics.
Sourcepub fn emit_metrics<E: Emitter>(&self, emitter: E)
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.