Skip to main content

Crate tracing_cache

Crate tracing_cache 

Source
Expand description

In-memory tracing::Subscriber that holds spans and events for inspection by a console UI.

Open spans live in a sharded slab; closed spans flow through a lock-free spillway channel into a background Driver that commits them to a shared BTreeMap. Filtering is pluggable via EnabledPredicate; the default LevelPredicate enables everything at or below a given level.

Structs§

CacheConfig
Optional knobs for the cache + driver. Pass to crate::SpanCache::with_config / crate::SpanCache::with_predicate_and_config; the no-config constructors use CacheConfig::default.
ChanceHandle
Remote control for a ChancePredicate’s active percentage. Cloning shares the same atomic — multiple owners observe and mutate the same value. Reads are Relaxed since per-span freshness is not required; updates are visible to the next roll.
ChancePredicate
Predicate wrapper that probabilistically denies root spans before they get to the inner predicate. Root spans (the ones whose Attributes carry tracing::span::Attributes::is_root() — typically tracing::span!(parent: None, …)) are gated by a runtime-tunable percentage; descendants and events pass straight through to the inner predicate.
Driver
EventRecord
One captured event. metadata and recorded_at are Option purely so EventRecord can implement Default for the internal object pool — they are always Some once an event has been published through the subscriber. Helper accessors metadata() / recorded_at() fall back to safe defaults rather than panic.
LevelHandle
Remote control for a LevelPredicate’s active level. Cloning shares the same atomic — multiple owners (e.g. one per administrative connection) all see and mutate the same value.
LevelPredicate
Default predicate: enables everything at or below the current LevelFilter setting (including OFF for “disable everything”).
ReuseRef
A pool-backed owned reference. Deref / DerefMut give access to the inner T; on drop the value is reset and handed back to the source shard if room is available and try_lock succeeds — otherwise dropped.
SpanCache
A tracing::Subscriber that funnels closed spans to live consumers.
SpanRecord

Enums§

FieldValue
Each captured field value. Str keeps a &'static str (zero-copy for literal field arguments), SmallString keeps the stack-inline-up-to-24-byte CompactString (no heap for short dynamic strings), SharedString keeps an Arc<String> for callers that want sharing, and String is the unrestricted owned fallback.
Interest
Mirror of tracing::subscriber::Interest — kept as our own type so the predicate trait isn’t bound to tracing’s exact type.

Constants§

DEFAULT_LANE_COUNT
Default number of in-flight slab shards (must be a power of two).

Traits§

EnabledPredicate

Type Aliases§

FieldList
A field list small enough to keep inline for the typical span. Spans or events with > 8 fields spill to the heap.