Skip to main content

SubMsObserver

Trait SubMsObserver 

Source
pub trait SubMsObserver: Send + Sync {
    // Provided methods
    fn on_record(&self, _ctx: &ObservationCtx<'_>, _ns: u64) { ... }
    fn on_summarize(&self, _summary: &SubMsBenchSummary) { ... }
}
Expand description

Hook a sibling crate (or downstream consumer) can register against a [SubMsPerfHarness] to react to every recorded sample plus the post-bench summary. Both methods default to a no-op so adding methods to the trait later is non-breaking.

Send + Sync are required so the same observer can be shared across harness instances (e.g., one OTEL exporter wired up at process start).

Provided Methods§

Source

fn on_record(&self, _ctx: &ObservationCtx<'_>, _ns: u64)

Called for each recorded sample. Fires from Stage::record, Stage::time, Stage::warm_then_time, and PacedStage::time - anywhere a ns value lands in a stage’s sample buffer.

Source

fn on_summarize(&self, _summary: &SubMsBenchSummary)

Called once when crate::summarize is invoked on the harness. Receives the typed summary including inputs + meta + per-stage stats.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§