pub struct ProviderMetrics { /* private fields */ }Expand description
Atomic counters for a single RPC provider endpoint.
Implementations§
Source§impl ProviderMetrics
impl ProviderMetrics
Sourcepub fn new(url: impl Into<String>) -> Self
pub fn new(url: impl Into<String>) -> Self
Create a new metrics instance for the given provider URL.
Sourcepub fn record_success(&self, latency: Duration)
pub fn record_success(&self, latency: Duration)
Record a successful request with the given latency.
Sourcepub fn record_failure(&self)
pub fn record_failure(&self)
Record a failed request.
Sourcepub fn record_rate_limit(&self)
pub fn record_rate_limit(&self)
Record a rate-limit rejection.
Sourcepub fn record_circuit_open(&self)
pub fn record_circuit_open(&self)
Record the circuit breaker opening.
Sourcepub fn avg_latency(&self) -> Duration
pub fn avg_latency(&self) -> Duration
Compute the average latency across all successful requests.
Returns Duration::ZERO if no successful requests have been recorded.
Sourcepub fn success_rate(&self) -> f64
pub fn success_rate(&self) -> f64
Compute the success rate as a fraction in [0.0, 1.0].
Returns 1.0 if no requests have been made.
Sourcepub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Produce an immutable snapshot for reporting / serialization.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ProviderMetrics
impl RefUnwindSafe for ProviderMetrics
impl Send for ProviderMetrics
impl Sync for ProviderMetrics
impl Unpin for ProviderMetrics
impl UnsafeUnpin for ProviderMetrics
impl UnwindSafe for ProviderMetrics
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