Expand description
tracing_subscriber::Layer for structured communication metrics.
The CommLayer is a tracing_subscriber::Layer which records numbers
of bytes read and written. Metrics are collected by
instrumenting spans with the
cryprot_metrics target and a phase. From within these spans, events with
the same target can be emitted to track the number of bytes read/written.
use tracing::{event, instrument, Level};
#[instrument(target = "cryprot_metrics", fields(phase = "Online"))]
async fn online() {
event!(target: "cryprot_metrics", Level::TRACE, bytes_written = 5);
interleaved_setup().await
}
#[instrument(target = "cryprot_metrics", fields(phase = "Setup"))]
async fn interleaved_setup() {
// Will be recorded in the sub phase "Setup" of the online phase
event!(target: "cryprot_metrics", Level::TRACE, bytes_written = 10);
}Structs§
- Comm
Data - Communication metrics for a phase and its sub phases.
- Comm
Layer Data - The
CommLayerDatahas shared ownership of the rootSubCommData. - Counter
- SubComm
Data - Sub communication data for different phases
Functions§
- new_
comm_ layer - Instantiate a new
CommLayerand correspondingCommLayerData.
Type Aliases§
- Comm
Layer - Convenience type alias for a filtered
CommLayerDatawhich only handles spans and events withtarget = "cryprot_metrics".