mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-02 07:20:35 +00:00

## Motivation Currently, when using `tracing-subscriber`'s `Layer` API, it is necessary for each layer to manage its own storage for per-span data. Since subscribers are shared concurrently, this means that `Layer`s must also manage synchronization on this storage. This is easy to get wrong, and even when it's implemented correctly, having every layer synchronize separately adds a lot of overhead. Ideally, it should be possible for state stored by the subscriber to be exposed to `Layer`s. ## Solution: This branch *starts* on the project of a general-purpose span registry by adding a new trait, `LookupMetadata`. Subscribers may implement this trait to allow looking up a span's `Metadata` by ID. If a subscriber implements this trait, the `layer::Context` type will then allow any layers wrapping that subscriber to look up metadata by ID. The `FmtSubscriber` implements this trait. Future work will be able to an interface for `Subscriber`s to expose more span data, such as parents, children, and arbitrarily-typed extensions, to `Layer`s as well. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
tracing-subscriber
Utilities for implementing and composing tracing
subscribers.
Documentation | Chat (gitter) | Chat (discord)
License
This project is licensed under the MIT license.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tracing by you, shall be licensed as MIT, without any additional terms or conditions.