pub struct Metrics;Expand description
Helper for recording common metrics in API and Admin handlers.
This provides a static interface to record requests, durations, errors, and circuit breaker states without needing to pass around recorder handles.
Implementations§
Source§impl Metrics
impl Metrics
Sourcepub fn increment_requests(provider: &str, format: &str)
pub fn increment_requests(provider: &str, format: &str)
Increments the total request count for a given provider and format.
Sourcepub fn record_duration(provider: &str, format: &str, seconds: f64)
pub fn record_duration(provider: &str, format: &str, seconds: f64)
Records the end-to-end duration of a request.
Sourcepub fn increment_errors(provider: &str, format: &str, error_kind: &str)
pub fn increment_errors(provider: &str, format: &str, error_kind: &str)
Records a rendering error, categorized by error kind.
Sourcepub fn record_payload_size(provider: &str, format: &str, bytes: f64)
pub fn record_payload_size(provider: &str, format: &str, bytes: f64)
Records the size of the input payload (compressed/encoded source).
Sourcepub fn record_conversion_time(provider: &str, format: &str, seconds: f64)
pub fn record_conversion_time(provider: &str, format: &str, seconds: f64)
Records the pure conversion time (excluding server overhead).
Sourcepub fn set_active_connections(provider: &str, format: &str, count: f64)
pub fn set_active_connections(provider: &str, format: &str, count: f64)
Updates the gauge for currently active concurrent requests.
Sourcepub fn set_circuit_breaker_state(provider: &str, state: f64)
pub fn set_circuit_breaker_state(provider: &str, state: f64)
Updates the gauge for a provider’s circuit breaker state (0=Closed, 1=Open, 2=HalfOpen).
Auto Trait Implementations§
impl Freeze for Metrics
impl RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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