[][src]Trait tracing_timing::EventGroup

pub trait EventGroup {
    type Id;
    fn group(&self, event: &Event) -> Self::Id;
}

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());

Associated Types

type Id

The type of the timing event group.

Loading content...

Required methods

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

Extract the group for this event.

Loading content...

Implementors

impl EventGroup for ByField[src]

type Id = String

impl EventGroup for ByMessage[src]

type Id = String

impl EventGroup for ByName[src]

type Id = &'static str

impl EventGroup for ByTarget[src]

type Id = &'static str

impl<F, R> EventGroup for F where
    F: Fn(&Event) -> R, 
[src]

type Id = R

Loading content...