pub struct ContextStore { /* private fields */ }Expand description
Store for active contexts and traces
Implementations§
Source§impl ContextStore
impl ContextStore
Sourcepub fn new(
max_traces: usize,
max_spans_per_trace: usize,
trace_ttl: Duration,
) -> Self
pub fn new( max_traces: usize, max_spans_per_trace: usize, trace_ttl: Duration, ) -> Self
Create a new store with the given capacity limits and TTL
Sourcepub fn with_sampler(self, sampler: Sampler) -> Self
pub fn with_sampler(self, sampler: Sampler) -> Self
Replace the default sampler. Useful when an operator wants
deterministic capture (e.g. AlwaysOn for diagnostics) or
a custom ratio different from the default.
Source§impl ContextStore
impl ContextStore
Sourcepub fn with_sampling(self, strategy: SamplingStrategy) -> Self
pub fn with_sampling(self, strategy: SamplingStrategy) -> Self
Override the default sampling strategy for this store
Sourcepub fn create_context(
&self,
origin_node: NodeId,
) -> Result<Context, ContextError>
pub fn create_context( &self, origin_node: NodeId, ) -> Result<Context, ContextError>
Create a new context and register it
Capacity admission goes through the atomic
try_reserve_slot CAS rather than a contexts.len() >= max
probe. Two threads inserting at exactly capacity could
otherwise both observe len < max after a
cleanup_expired and both insert, growing the map past
max_traces. The slot is reserved atomically before the
insert; if the reserve fails after a cleanup_expired
retry, we surface CapacityExceeded.
Sourcepub fn continue_context(&self, ctx: Context) -> Result<Context, ContextError>
pub fn continue_context(&self, ctx: Context) -> Result<Context, ContextError>
Continue a context from a remote node
Sourcepub fn get_context(&self, trace_id: &TraceId) -> Option<Context>
pub fn get_context(&self, trace_id: &TraceId) -> Option<Context>
Get a context by trace ID
Sourcepub fn complete_trace(&self, trace_id: &TraceId) -> Option<(Context, Vec<Span>)>
pub fn complete_trace(&self, trace_id: &TraceId) -> Option<(Context, Vec<Span>)>
Complete a trace and return all spans
Also releases the active_count slot so the
try_reserve_slot admission gate can re-admit.
Sourcepub fn cleanup_expired(&self)
pub fn cleanup_expired(&self)
Cleanup expired traces
Every successful removal also releases an active_count
slot so the try_reserve_slot admission gate can re-admit
work as soon as expired entries are reclaimed.
Sourcepub fn stats(&self) -> ContextStoreStats
pub fn stats(&self) -> ContextStoreStats
Get statistics