pub struct InferenceTraceRecorder {
pub events: Vec<TraceEvent>,
pub spans: Vec<TraceSpan>,
pub next_span_id: u64,
pub stats: TraceStats,
pub max_events: usize,
}Expand description
Records and queries a bounded trace of inference execution events.
Fields§
§events: Vec<TraceEvent>Recorded events in order of occurrence.
spans: Vec<TraceSpan>Named spans.
next_span_id: u64Counter used to hand out monotonically increasing span IDs.
stats: TraceStatsAggregated statistics.
max_events: usizeMaximum number of events to retain (oldest are dropped when exceeded).
Implementations§
Source§impl InferenceTraceRecorder
impl InferenceTraceRecorder
Sourcepub fn record(&mut self, event: TraceEvent)
pub fn record(&mut self, event: TraceEvent)
Append an event, updating statistics.
If the number of events would exceed max_events, the oldest event is
removed first (and span indices that referenced it are not adjusted
— callers should treat indices as approximate after overflow).
Sourcepub fn begin_span(&mut self, label: String) -> u64
pub fn begin_span(&mut self, label: String) -> u64
Open a new named span and return its ID.
Sourcepub fn end_span(&mut self, span_id: u64)
pub fn end_span(&mut self, span_id: u64)
Close the span identified by span_id, recording the current event
count as the end boundary.
Sourcepub fn events_in_span(&self, span_id: u64) -> &[TraceEvent]
pub fn events_in_span(&self, span_id: u64) -> &[TraceEvent]
Return the slice of events that fall within the given span.
Returns an empty slice when the span is unknown or not yet closed.
Sourcepub fn filter_events(
&self,
pred: impl Fn(&TraceEvent) -> bool,
) -> Vec<&TraceEvent>
pub fn filter_events( &self, pred: impl Fn(&TraceEvent) -> bool, ) -> Vec<&TraceEvent>
Return all events for which pred returns true.
Sourcepub fn rules_fired_in_span(&self, span_id: u64) -> Vec<&TraceEvent>
pub fn rules_fired_in_span(&self, span_id: u64) -> Vec<&TraceEvent>
Return only the RuleFired events that fall inside the given span.
Sourcepub fn stats(&self) -> &TraceStats
pub fn stats(&self) -> &TraceStats
Borrow the accumulated statistics.
Sourcepub fn export_summary(&self) -> String
pub fn export_summary(&self) -> String
Produce a one-line human-readable summary of the trace statistics.
Auto Trait Implementations§
impl Freeze for InferenceTraceRecorder
impl RefUnwindSafe for InferenceTraceRecorder
impl Send for InferenceTraceRecorder
impl Sync for InferenceTraceRecorder
impl Unpin for InferenceTraceRecorder
impl UnsafeUnpin for InferenceTraceRecorder
impl UnwindSafe for InferenceTraceRecorder
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more