
## Motivation As discussed in #136, a proposed `Layer` trait for composing subscribers required should probably _not_ be responsible for managing ref-counts and determining span closures. Instead, the root subscriber should be responsible for this, and `Layer`s should be able to opt into a callback that's notified _when_ a span is closed. Adding a callback that's called on closure to `Layer` requires modifying the `Subscriber` trait to allow indicating when a span closes. ## Solution This branch attempts to do this without a breaking change, by adding a new `try_close` trait method to `Subscriber`. `try_close` is identical to `drop_span` except that it returns a boolean value, set to `true` if the span has closed. The `try_close` default implementation simply calls `self.drop_span(...)` and returns `false`, so that if subscribers don't care about tracking ref counts, close notifications will never be triggered. The `drop_span` documentation now indicates that it is "soft deprecated" similarly to `std::error::Error`'s `description` method. This encourages subscribers to implement the new API, but isn't a breaking change. Existing _callers_ of `drop_span` are still able to call it without causing issues. A subsequent PR will mark `drop_span` as deprecated in favour of `try_close`. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
tracing-core
Core primitives for application-level tracing.
Overview
tracing
is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information. This crate defines the core
primitives of tracing
.
The crate provides:
-
Span
identifies a span within the execution of a program. -
Event
represents a single event within a trace. -
Subscriber
, the trait implemented to collect trace data. -
Field
,FieldSet
,Value
, andValueSet
represent the structured data attached to aSpan
. -
Dispatch
allows span events to be dispatched toSubscriber
s.
In addition, it defines the global callsite registry and per-thread current dispatcher which other components of the tracing system rely on.
Application authors will typically not use this crate directly. Instead, they
will use the tracing
crate, which provides a much more fully-featured
API. However, this crate's API will change very infrequently, so it may be used
when dependencies must be very stable.
License
This project is licensed under the MIT license.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tokio by you, shall be licensed as MIT, without any additional terms or conditions.