[][src]Trait tracing_subscriber::registry::LookupMetadata

pub trait LookupMetadata {
    fn metadata(&self, id: &Id) -> Option<&'static Metadata<'static>>;

    fn exists(&self, id: &Id) -> bool { ... }
}

Provides access to stored span metadata.

Subscribers which store span metadata and associate it with span IDs should implement this trait; if they do, any Layers wrapping them can look up metadata via the Context type's metadata() method.

Required methods

fn metadata(&self, id: &Id) -> Option<&'static Metadata<'static>>

Returns metadata for tne span with the given id, if it exists.

If no span exists for the provided ID (e.g. the span has closed and been removed from the registry, or the ID is invalid), this should return None.

Loading content...

Provided methods

fn exists(&self, id: &Id) -> bool

Returns true if a span with the given id exists, false otherwise.

Note: The default implementation of this method is simply:

This example is not tested
 fn exists(&self, id: &span::Id) -> bool {
     self.metadata(id).is_some()
 }

If the subscriber has a faster way of determining whether a span exists for a given ID (e.g., if the ID is greater than the current value of an increasing ID counter, etc), this method may be overridden as an optimization.

Loading content...

Implementors

impl<L> LookupMetadata for L where
    L: for<'a> LookupSpan<'a>, 
[src]

impl<N, E, F, W> LookupMetadata for Subscriber<N, E, F, W> where
    Layered<F, Formatter<N, E, W>>: LookupMetadata
[src]

Loading content...