pub struct TraceContext { /* private fields */ }Expand description
Cloneable handle carrying the sink, the lazily-loaded digest key, the session identity, and metadata-only degradation counters.
Implementations§
Source§impl TraceContext
impl TraceContext
Sourcepub fn emit_execution_enriched(&self, request_id: &TraceId)
pub fn emit_execution_enriched(&self, request_id: &TraceId)
Replace the first matching request record with an execution-enriched snapshot. Sinks that persist append-only records may retain both; the latest snapshot is authoritative for the request ID.
Sourcepub fn session_id(&self) -> &TraceId
pub fn session_id(&self) -> &TraceId
Session identity shared by all request/tool events in this context.
Sourcepub fn record_execution_event(&self, event: ToolExecutionEvent)
pub fn record_execution_event(&self, event: ToolExecutionEvent)
Append bounded execution metadata for a request. This never fails the turn; malformed/unrepresentable fields are rejected before this seam.
pub fn execution_events(&self, request_id: &TraceId) -> Vec<ToolExecutionEvent>
Sourcepub fn latest_request_correlation(&self) -> Option<(TraceId, TraceId, TraceId)>
pub fn latest_request_correlation(&self) -> Option<(TraceId, TraceId, TraceId)>
Test/stream seam: correlated IDs for the most recently begun request.
pub fn reserve_request_correlation(&self) -> Option<RequestCorrelation>
Sourcepub fn with_sink(sink: Arc<dyn TraceSink>) -> Self
pub fn with_sink(sink: Arc<dyn TraceSink>) -> Self
Context with the given sink and the installation default key path.
Sourcepub fn fork_with_sink(&self, sink: Arc<dyn TraceSink>) -> Self
pub fn fork_with_sink(&self, sink: Arc<dyn TraceSink>) -> Self
Fork this context with a replacement sink, preserving the session
identity, digest-key state, degradation counters, request sequence,
and — crucially — the shared session [CacheSnapshotStore], so an
armed one-shot request feeds the same §6.6 diagnostics that
/context reads. The one-shot gate and content capture are NOT
inherited: the caller attaches them explicitly.
Sourcepub fn with_content_capture(self, capture: Arc<ContentCapture>) -> Self
pub fn with_content_capture(self, capture: Arc<ContentCapture>) -> Self
Attach a one-request content capture arm (see trace::controls).
Sourcepub fn with_one_shot_request_gate(self) -> Self
pub fn with_one_shot_request_gate(self) -> Self
Arm the one-shot request gate: exactly one logical request
(RequestTracer::begin) traces through this context, all its retry
attempts included; subsequent requests are disabled. Only armed
ephemeral contexts carry this — normal Basic/Full contexts never do.
Sourcepub fn cache_snapshots(&self) -> &Arc<CacheSnapshotStore> ⓘ
pub fn cache_snapshots(&self) -> &Arc<CacheSnapshotStore> ⓘ
The session cache snapshot store (spec §6.6 previous-turn compare).
Sourcepub fn capture_request_content(&self, request_id: &TraceId, body_bytes: &[u8])
pub fn capture_request_content(&self, request_id: &TraceId, body_bytes: &[u8])
Capture the request body for an armed one-shot content capture
(no-op in every other context). body_bytes must be the request
body only — never headers or credentials.
Sourcepub fn capture_unsupported(&self, reason: &str)
pub fn capture_unsupported(&self, reason: &str)
Explicitly fail an armed content capture on a provider path that has
no capturable request body (e.g. the extension sidecar, which owns
framing/serialization out of process). Fix for silent consumption:
the arm is consumed visibly — one metadata-only warning plus a
bump of the degraded-records counter that /trace status reports —
instead of vanishing with no artifact and no signal. No-op in every
context without an armed capture.
Sourcepub fn with_key_path(self, path: PathBuf) -> Self
pub fn with_key_path(self, path: PathBuf) -> Self
Override the digest-key path (tests / non-default installs).
pub fn enabled(&self) -> bool
Sourcepub fn degraded_records(&self) -> u64
pub fn degraded_records(&self) -> u64
Records degraded/dropped for internal reasons since context creation.
Sourcepub async fn digest_key(&self) -> Option<Arc<TraceDigestKey>>
pub async fn digest_key(&self) -> Option<Arc<TraceDigestKey>>
Load (or create) the installation digest key, once per context, off
the async threads. Failure is remembered: it warns once (metadata
only), bumps the degradation counter, and yields None forever —
it can never fail or delay the request itself.
Trait Implementations§
Source§impl Clone for TraceContext
impl Clone for TraceContext
Source§impl Debug for TraceContext
impl Debug for TraceContext
Auto Trait Implementations§
impl !RefUnwindSafe for TraceContext
impl !UnwindSafe for TraceContext
impl Freeze for TraceContext
impl Send for TraceContext
impl Sync for TraceContext
impl Unpin for TraceContext
impl UnsafeUnpin for TraceContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.