pub struct Metrics {Show 18 fields
pub tokens_input: AtomicU64,
pub tokens_output: AtomicU64,
pub tokens_saved: AtomicU64,
pub tool_calls_total: AtomicU64,
pub tool_calls_error: AtomicU64,
pub tool_call_latency_sum_us: AtomicU64,
pub search_queries_total: AtomicU64,
pub search_latency_sum_us: AtomicU64,
pub search_results_total: AtomicU64,
pub embedding_inferences_total: AtomicU64,
pub embedding_latency_sum_us: AtomicU64,
pub embedding_tokens_total: AtomicU64,
pub cache_hits: AtomicU64,
pub cache_misses: AtomicU64,
pub compression_calls: AtomicU64,
pub compression_input_bytes: AtomicU64,
pub compression_output_bytes: AtomicU64,
pub session_start: Instant,
/* private fields */
}Fields§
§tokens_input: AtomicU64§tokens_output: AtomicU64§tokens_saved: AtomicU64§tool_calls_total: AtomicU64§tool_calls_error: AtomicU64§tool_call_latency_sum_us: AtomicU64§search_queries_total: AtomicU64§search_latency_sum_us: AtomicU64§search_results_total: AtomicU64§embedding_inferences_total: AtomicU64§embedding_latency_sum_us: AtomicU64§embedding_tokens_total: AtomicU64§cache_hits: AtomicU64§cache_misses: AtomicU64§compression_calls: AtomicU64§compression_input_bytes: AtomicU64§compression_output_bytes: AtomicU64§session_start: InstantImplementations§
Source§impl Metrics
impl Metrics
pub fn new() -> Self
pub fn record_tool_call(&self, latency_us: u64, success: bool)
Sourcepub fn record_named_tool_call(
&self,
tool: &'static str,
latency_us: u64,
success: bool,
)
pub fn record_named_tool_call( &self, tool: &'static str, latency_us: u64, success: bool, )
Record a call of a built-in tool: the totals and the tool’s own counter move together under one lock.
Sourcepub fn record_named_tool_outcome(
&self,
tool: &'static str,
latency_us: u64,
failure: Option<FailureKind>,
)
pub fn record_named_tool_outcome( &self, tool: &'static str, latency_us: u64, failure: Option<FailureKind>, )
Like Self::record_named_tool_call, with the class of a failure.
Sourcepub fn record_named_tool_failure(
&self,
tool: &'static str,
latency_us: u64,
failure: Option<Failure>,
)
pub fn record_named_tool_failure( &self, tool: &'static str, latency_us: u64, failure: Option<Failure>, )
Like Self::record_named_tool_outcome, also counting the failure’s
scrubbed template. Templates are bounded per process.
pub fn record_tokens(&self, input: u64, output: u64, saved: u64)
pub fn record_search(&self, latency_us: u64, result_count: u64)
pub fn record_embedding(&self, latency_us: u64, token_count: u64)
pub fn record_cache(&self, hit: bool)
pub fn record_compression(&self, input_bytes: u64, output_bytes: u64)
pub fn snapshot(&self) -> MetricsSnapshot
Sourcepub fn to_otel_attributes(&self) -> Vec<(&'static str, String)>
pub fn to_otel_attributes(&self) -> Vec<(&'static str, String)>
Format as OpenTelemetry-compatible attributes for logging.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Metrics
impl Forget for Metrics
impl Move for Metrics
impl RefUnwindSafe for Metricswhere
Mutex<BTreeMap<&'static str, ToolCallCounter>>: RefUnwindSafe,
Mutex<BTreeMap<(&'static str, String), u64>>: RefUnwindSafe,
Atomic<u64>: RefUnwindSafe,
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl UnsafeUnpin for Metricswhere
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const LeafNode<&'static str, ToolCallCounter> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(&'static str, ToolCallCounter)>>: UnsafeUnpin,
*const LeafNode<(&'static str, String), u64> is !null: UnsafeUnpin,
PhantomData<Box<((&'static str, String), u64)>>: UnsafeUnpin,
Align8<u64>: UnsafeUnpin,
impl UnwindSafe for Metricswhere
Mutex<BTreeMap<&'static str, ToolCallCounter>>: UnwindSafe,
Mutex<BTreeMap<(&'static str, String), u64>>: UnwindSafe,
Align8<u64>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more