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,
}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)
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 RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl UnsafeUnpin for Metrics
impl UnwindSafe for Metrics
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 more