[][src]Trait tracing_timing::SpanGroup

pub trait SpanGroup {
    type Id;
    fn group(&self, span: &Attributes) -> Self::Id;
}

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

All spans whose attributes produce the same Id-typed value when passed through group share a namespace for the groups produced by EventGroup::group on their contained events.

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 a SpanGroup. 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::span;
let s = Builder::default()
    .spans(|_: &span::Attributes| "all spans as one")
    .build(|| Histogram::new(3).unwrap());

Associated Types

type Id

The type of the timing span group.

Loading content...

Required methods

fn group(&self, span: &Attributes) -> Self::Id

Extract the group for this span's attributes.

Loading content...

Implementors

impl SpanGroup for ByField[src]

type Id = String

impl SpanGroup for ByName[src]

type Id = &'static str

impl SpanGroup for ByTarget[src]

type Id = &'static str

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

type Id = R

Loading content...