
## Motivation Currently, `tokio-trace-core` permits `Subscriber`s to indicate that they are "always", "sometimes", or "never" interested in a particular callsite. When "always" or "never" is returned, then the interest is cached and the subscriber will not be asked again about that callsite. This is much more efficient than requiring the filter to be re-evaluated every time the callsite is hit. However, if a subscriber wishes to change its filter configuration dynamically at runtime, it cannot benefit from this caching. Instead, it must always return `Interest::sometimes`. Even when filters change very infrequently, they must still always be re-evaluated every time. In order to support a use-case where subscribers may change their filter configuration at runtime (e.g. tokio-rs/tokio-trace-nursery#42), but do so infrequently, we should introducing a new function to invalidate the cached interest. ## Solution This branch adds a new function in the `callsite` module, called `rebuild_interest_cache`, that will invalidate and rebuild all cached interest. ## Breaking Change In order to fix a race condition that could occur when rebuilding interest caches using `clear_interest` and `add_interest`, these methods have been replaced by a new `set_interest` method. `set_interest` should have the semantics of atomically replacing the previous cached interest, so that the callsite does not enter a temporary state where it has no interest. Closes #1038 Co-Authored-By: yaahallo <jlusby42@gmail.com>
tokio-trace-core
Core primitives for tokio-trace
.
Overview
tokio-trace
is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information. This crate defines the core
primitives of tokio-trace
.
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 tokio-trace
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.