pub struct RequestLog { /* private fields */ }Expand description
Append-only log of LLM API requests.
Implementations§
Source§impl RequestLog
impl RequestLog
pub fn new() -> Self
Sourcepub fn record(
&mut self,
request_id: impl Into<String>,
model: impl Into<String>,
input_tokens: u64,
output_tokens: u64,
latency_ms: u64,
)
pub fn record( &mut self, request_id: impl Into<String>, model: impl Into<String>, input_tokens: u64, output_tokens: u64, latency_ms: u64, )
Record a successful request.
Sourcepub fn record_with_meta(
&mut self,
request_id: impl Into<String>,
model: impl Into<String>,
input_tokens: u64,
output_tokens: u64,
latency_ms: u64,
metadata: Value,
)
pub fn record_with_meta( &mut self, request_id: impl Into<String>, model: impl Into<String>, input_tokens: u64, output_tokens: u64, latency_ms: u64, metadata: Value, )
Record a request with metadata.
Sourcepub fn record_error(
&mut self,
request_id: impl Into<String>,
model: impl Into<String>,
error: impl Into<String>,
latency_ms: u64,
)
pub fn record_error( &mut self, request_id: impl Into<String>, model: impl Into<String>, error: impl Into<String>, latency_ms: u64, )
Record a failed request.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn entries(&self) -> &[LogEntry]
pub fn get(&self, request_id: &str) -> Option<&LogEntry>
pub fn by_model(&self, model: &str) -> Vec<&LogEntry>
pub fn errors(&self) -> Vec<&LogEntry>
pub fn total_input_tokens(&self) -> u64
pub fn total_output_tokens(&self) -> u64
pub fn avg_latency_ms(&self) -> f64
pub fn slowest(&self) -> Option<&LogEntry>
pub fn clear(&mut self)
Trait Implementations§
Source§impl Debug for RequestLog
impl Debug for RequestLog
Source§impl Default for RequestLog
impl Default for RequestLog
Source§fn default() -> RequestLog
fn default() -> RequestLog
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RequestLog
impl RefUnwindSafe for RequestLog
impl Send for RequestLog
impl Sync for RequestLog
impl Unpin for RequestLog
impl UnsafeUnpin for RequestLog
impl UnwindSafe for RequestLog
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