Module metrics

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

CommData
Communication metrics for a phase and its sub phases.
CommLayerData
The CommLayerData has shared ownership of the root SubCommData.
Counter
SubCommData
Sub communication data for different phases

Functions§

new_comm_layer
Instantiate a new CommLayer and corresponding CommLayerData.

Type Aliases§

CommLayer
Convenience type alias for a filtered CommLayerData which only handles spans and events with target = "cryprot_metrics".