pub struct HookManager { /* private fields */ }Expand description
Hook manager — accumulates execution metrics.
Implementations§
Source§impl HookManager
impl HookManager
Sourcepub fn on_unit_start(&mut self, unit_name: &str, persona_name: &str)
pub fn on_unit_start(&mut self, unit_name: &str, persona_name: &str)
Signal the start of an execution unit.
Sourcepub fn on_unit_end(&mut self)
pub fn on_unit_end(&mut self)
Signal the end of an execution unit.
Sourcepub fn on_step_start(&mut self, step_name: &str, step_type: &str)
pub fn on_step_start(&mut self, step_name: &str, step_type: &str)
Signal the start of a step.
Sourcepub fn on_step_end(
&mut self,
input_tokens: u64,
output_tokens: u64,
anchor_breaches: u32,
chain_activations: u32,
was_retried: bool,
)
pub fn on_step_end( &mut self, input_tokens: u64, output_tokens: u64, anchor_breaches: u32, chain_activations: u32, was_retried: bool, )
Signal the end of a step with metrics.
Sourcepub fn step_metrics(&self) -> &[StepMetrics]
pub fn step_metrics(&self) -> &[StepMetrics]
Get all step metrics.
Sourcepub fn unit_metrics(&self) -> &[UnitMetrics]
pub fn unit_metrics(&self) -> &[UnitMetrics]
Get all unit metrics.
Sourcepub fn total_duration_ms(&self) -> u64
pub fn total_duration_ms(&self) -> u64
Total execution time across all units.
Sourcepub fn total_input_tokens(&self) -> u64
pub fn total_input_tokens(&self) -> u64
Total input tokens across all steps.
Sourcepub fn total_output_tokens(&self) -> u64
pub fn total_output_tokens(&self) -> u64
Total output tokens across all steps.
Sourcepub fn total_steps(&self) -> usize
pub fn total_steps(&self) -> usize
Total steps executed.
Sourcepub fn retried_steps(&self) -> usize
pub fn retried_steps(&self) -> usize
Number of steps that were retried.
Sourcepub fn slowest_step(&self) -> Option<&StepMetrics>
pub fn slowest_step(&self) -> Option<&StepMetrics>
Slowest step by duration.
Sourcepub fn most_expensive_step(&self) -> Option<&StepMetrics>
pub fn most_expensive_step(&self) -> Option<&StepMetrics>
Most expensive step by total tokens.
Sourcepub fn avg_step_duration_ms(&self) -> u64
pub fn avg_step_duration_ms(&self) -> u64
Average step duration in milliseconds.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HookManager
impl RefUnwindSafe for HookManager
impl Send for HookManager
impl Sync for HookManager
impl Unpin for HookManager
impl UnsafeUnpin for HookManager
impl UnwindSafe for HookManager
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.