pub struct MetricsHandle { /* private fields */ }Expand description
A late-bound MetricsCollector cell.
Contract:
- Late binding: a
MetricsHandlecan be handed to consumers before any real collector exists; it seeds itself withNoOpMetricsso calls before (and without) registration are safe no-ops. - Composition, not replacement: each
MetricsHandle::registercomposes the new collector over the currently stored one (seeCompositeMetricsCollector); previously registered collectors keep observing. - Same-Arc idempotence: registering the same collector
Arctwice is a no-op (detected viaArc::ptr_eqagainst the membership list), so a call site that wires the same collector through two builder paths does not double-count. - Delegation cost: each trait-method call costs one atomic load of the stored
Arc(ArcSwap::load); the hot path never clones theArc.
Implementations§
Source§impl MetricsHandle
impl MetricsHandle
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a handle that delegates to NoOpMetrics until a collector is
registered.
Sourcepub fn register(&self, collector: Arc<dyn MetricsCollector>)
pub fn register(&self, collector: Arc<dyn MetricsCollector>)
Registers collector, composing it over whatever is currently stored.
If the exact same Arc was already registered, this is a no-op
(see same-Arc idempotence in the type-level docs).
Trait Implementations§
Source§impl Default for MetricsHandle
impl Default for MetricsHandle
Source§impl MetricsCollector for MetricsHandle
impl MetricsCollector for MetricsHandle
Source§fn record_exchange_duration(&self, route_id: &str, duration: Duration)
fn record_exchange_duration(&self, route_id: &str, duration: Duration)
Record exchange processing time
Source§fn increment_errors(&self, route_id: &str, error_type: &str)
fn increment_errors(&self, route_id: &str, error_type: &str)
Increment error counter
Source§fn increment_exchanges(&self, route_id: &str)
fn increment_exchanges(&self, route_id: &str)
Increment exchange counter
Source§fn set_queue_depth(&self, route_id: &str, depth: usize)
fn set_queue_depth(&self, route_id: &str, depth: usize)
Update queue depth
Source§fn record_circuit_breaker_change(&self, route_id: &str, from: &str, to: &str)
fn record_circuit_breaker_change(&self, route_id: &str, from: &str, to: &str)
Record circuit breaker state change
Auto Trait Implementations§
impl !Freeze for MetricsHandle
impl !RefUnwindSafe for MetricsHandle
impl !UnwindSafe for MetricsHandle
impl Send for MetricsHandle
impl Sync for MetricsHandle
impl Unpin for MetricsHandle
impl UnsafeUnpin for MetricsHandle
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