🛈 Note: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem.

For the release documentation, please see docs.rs, instead.

Module tracing_subscriber::registry

source ·
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§

  • Dataregistry and std
    Span data stored in a Registry.
  • An immutable, read-only reference to a Span’s extensions.
  • An mutable reference to a Span’s extensions.
  • Registryregistry and std
    A shared, reusable store for spans.
  • An iterator over the parents of a span, ordered from leaf to root.
  • ScopeFromRootalloc or std
    An iterator over the parents of a span, ordered from root to leaf.
  • A reference to [span data] and the associated registry.

Traits§

  • Provides access to stored span data.
  • A stored representation of data associated with a span.