Trait EventGroup

Source
pub trait EventGroup {
    type Id;

    // Required method
    fn group(&self, event: &Event<'_>) -> Self::Id;
}
Expand description

Translate attributes from a tracing event into a timing event group.

All events that share a SpanGroup, and whose attributes produce the same Id-typed value when passed through group, are considered a single timing target, and have their samples recorded together.

This trait is implemented for all functions with the appropriate signature. Note that you may run into weird lifetime errors from the compiler when using a closure as an EventGroup. This is a known compiler issue. You can work around it by adding a slight type hint to the arguments passed to the closure as follows (note the : &_):

use tracing_timing::{Builder, Histogram};
use tracing::Event;
let s = Builder::default()
    .events(|_: &Event| "all events as one")
    .build(|| Histogram::new(3).unwrap());

Required Associated Types§

Source

type Id

The type of the timing event group.

Required Methods§

Source

fn group(&self, event: &Event<'_>) -> Self::Id

Extract the group for this event.

Implementors§

Source§

impl EventGroup for ByField

Source§

impl EventGroup for ByMessage

Source§

impl EventGroup for ByName

Source§

type Id = &'static str

Source§

impl EventGroup for ByTarget

Source§

type Id = &'static str

Source§

impl<F, R> EventGroup for F
where F: Fn(&Event<'_>) -> R,

Source§

type Id = R