pub struct OpenAIMetrics {Show 13 fields
pub total_requests: u64,
pub successful_requests: u64,
pub failed_requests: u64,
pub total_tokens_processed: u64,
pub cache_hits: u64,
pub cache_misses: u64,
pub total_cost_usd: f64,
pub retry_count: u64,
pub rate_limit_waits: u64,
pub average_response_time_ms: f64,
pub last_request_time: Option<SystemTime>,
pub requests_by_model: HashMap<String, u64>,
pub errors_by_type: HashMap<String, u64>,
}Expand description
Metrics for OpenAI API usage
Fields§
§total_requests: u64§successful_requests: u64§failed_requests: u64§total_tokens_processed: u64§cache_hits: u64§cache_misses: u64§total_cost_usd: f64§retry_count: u64§rate_limit_waits: u64§average_response_time_ms: f64§last_request_time: Option<SystemTime>§requests_by_model: HashMap<String, u64>§errors_by_type: HashMap<String, u64>Implementations§
Source§impl OpenAIMetrics
impl OpenAIMetrics
Sourcepub fn cache_hit_ratio(&self) -> f64
pub fn cache_hit_ratio(&self) -> f64
Calculate cache hit ratio
Sourcepub fn success_rate(&self) -> f64
pub fn success_rate(&self) -> f64
Calculate success rate
Sourcepub fn average_cost_per_request(&self) -> f64
pub fn average_cost_per_request(&self) -> f64
Calculate average cost per request
Trait Implementations§
Source§impl Clone for OpenAIMetrics
impl Clone for OpenAIMetrics
Source§fn clone(&self) -> OpenAIMetrics
fn clone(&self) -> OpenAIMetrics
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OpenAIMetrics
impl Debug for OpenAIMetrics
Source§impl Default for OpenAIMetrics
impl Default for OpenAIMetrics
Source§fn default() -> OpenAIMetrics
fn default() -> OpenAIMetrics
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OpenAIMetrics
impl RefUnwindSafe for OpenAIMetrics
impl Send for OpenAIMetrics
impl Sync for OpenAIMetrics
impl Unpin for OpenAIMetrics
impl UnwindSafe for OpenAIMetrics
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.