Expand description
Storage for span data shared by multiple Subscribes.
§Using the Span Registry
This module provides the Registry type, a Collect implementation
which tracks per-span data and exposes it to subscribers. When a Registry
is used as the base Collect of a Subscribe stack, the
subscribe::Context type will provide methods allowing subscribers to
look up span data stored in the registry. While Registry is a
reasonable default for storing spans and events, other stores that implement
LookupSpan and Collect themselves (with SpanData implemented
by the per-span data they store) can be used as a drop-in replacement.
For example, we might create a Registry and add multiple Subscribers like so:
use tracing_subscriber::{registry::Registry, Subscribe, prelude::*};
let subscriber = Registry::default()
.with(FooSubscriber::new())
.with(BarSubscriber::new());If a type implementing Subscribe depends on the functionality of a Registry
implementation, it should bound its Collect type parameter with the
LookupSpan trait, like so:
use tracing_subscriber::{registry, Subscribe};
use tracing_core::Collect;
pub struct MySubscriber {
// ...
}
impl<C> Subscribe<C> for MySubscriber
where
C: Collect + for<'a> registry::LookupSpan<'a>,
{
// ...
}When this bound is added, the subscriber implementation will be guaranteed
access to the Context methods, such as Context::span, that
require the root collector to be a registry.
Structs§
- Data
registryandstd - Span data stored in a
Registry. - Extensions
std - An immutable, read-only reference to a Span’s extensions.
- Extensions
Mut std - An mutable reference to a Span’s extensions.
- Registry
registryandstd - A shared, reusable store for spans.
- Scope
- An iterator over the parents of a span, ordered from leaf to root.
- Scope
From Root allocorstd - An iterator over the parents of a span, ordered from root to leaf.
- SpanRef
- A reference to [span data] and the associated registry.
Traits§
- Lookup
Span - Provides access to stored span data.
- Span
Data - A stored representation of data associated with a span.