Skip to main content

SpanGroup

Trait SpanGroup 

Source
pub trait SpanGroup {
    type Id;

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

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

Required Associated Types§

Source

type Id

The type of the timing span group.

Required Methods§

Source

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

Extract the group for this span’s attributes.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl SpanGroup for ByField

Source§

impl SpanGroup for ByName

Source§

type Id = &'static str

Source§

impl SpanGroup for ByTarget

Source§

type Id = &'static str

Source§

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

Source§

type Id = R