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 (see [CompositeMetricsCollector]); 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, queue: &str, depth: usize)
fn set_queue_depth(&self, queue: &str, depth: usize)
Update the depth of a buffered stage’s queue
(
camel_queue_depth{queue}). The queue label is a closed set of
component-declared identifiers (seda:<endpoint-name>,
aggregator:<route>, resequencer:<route>).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
Source§fn record_histogram(&self, name: &str, value: f64, labels: &[(&str, &str)])
fn record_histogram(&self, name: &str, value: f64, labels: &[(&str, &str)])
Record a histogram observation (e.g., cost, latency distribution).
Default: no-op (backward-compatible).
Source§fn record_counter(&self, name: &str, value: f64, labels: &[(&str, &str)])
fn record_counter(&self, name: &str, value: f64, labels: &[(&str, &str)])
Record a monotonically-increasing counter (e.g.
foo_total).
Default: no-op (backward-compatible).Source§fn increment_retry_attempt(&self, scheme: &str, operation: &str)
fn increment_retry_attempt(&self, scheme: &str, operation: &str)
Increment the per-attempt retry counter (
camel_retry_attempts_total,
labels scheme+operation). Called once per retry attempt, including the
first. Default: no-op (backward-compatible).Source§fn increment_circuit_breaker_rejection(&self, route: &str)
fn increment_circuit_breaker_rejection(&self, route: &str)
Increment the circuit-breaker rejection counter
(
camel_circuit_breaker_rejections_total, label route). Open-breaker
fast-fails count here, not as errors. Default: no-op
(backward-compatible).Source§fn set_route_state(&self, route: &str, state: &str)
fn set_route_state(&self, route: &str, state: &str)
Publish a route lifecycle-state transition (
camel_route_state,
labels route+state). state is the projection’s state label — a
closed set by construction (Registered, Starting, Started,
Suspended, Stopping, Stopped, Failed). Implementations keep
the route’s last-published state so a transition sets the new series
to 1 and zeroes the previous one. Default: no-op
(backward-compatible).Source§fn clear_route_state(&self, route: &str)
fn clear_route_state(&self, route: &str)
Drop a route’s state series (route removed/undeployed) so a
scrape reflects only routes that exist.
Source§fn record_build_info(&self, version: &str, git_sha: &str)
fn record_build_info(&self, version: &str, git_sha: &str)
Publish build identification (
camel_build_info{git_sha,version},
value 1). Called once when the context is built. Default: no-op
(backward-compatible).Source§fn record_uptime(&self, seconds: f64)
fn record_uptime(&self, seconds: f64)
Publish process uptime in seconds (
camel_uptime_seconds),
refreshed periodically by the runtime. Default: no-op
(backward-compatible).Source§fn record_component_operation(
&self,
component: &str,
operation: &str,
outcome: &str,
)
fn record_component_operation( &self, component: &str, operation: &str, outcome: &str, )
Increment the uniform component-operations counter
(
camel_component_operations_total, labels component+operation+
outcome). outcome is a closed set — “success” or “failure”
only; callers derive it from a bool (see ComponentMetrics),
never pass free text. Default: no-op (backward-compatible).Source§fn set_pinned_client_cache_size(&self, component: &str, entries: u64)
fn set_pinned_client_cache_size(&self, component: &str, entries: u64)
Publish the pinned client cache size for a component
(
camel_pinned_client_cache_size{component}, gauge, unit: entries).
Emitted by the owning component after each lookup, reflecting the
current (approximate) entry count. Default:
no-op (backward-compatible).Source§fn increment_pinned_client_cache_hit(&self, component: &str)
fn increment_pinned_client_cache_hit(&self, component: &str)
Increment the pinned client cache hit counter for a component
(
camel_pinned_client_cache_hits_total{component}) — a pinned
lookup served by the cache without a rebuild. Default: no-op
(backward-compatible).Source§fn increment_pinned_client_cache_miss(&self, component: &str)
fn increment_pinned_client_cache_miss(&self, component: &str)
Increment the pinned client cache miss counter for a component
(
camel_pinned_client_cache_misses_total{component}) — a pinned
lookup that required a client rebuild. Default: no-op
(backward-compatible).Source§fn set_allocator_memory(&self, stat: AllocatorStat, bytes: u64)
fn set_allocator_memory(&self, stat: AllocatorStat, bytes: u64)
Publish an allocator memory statistic
(
camel_allocator_memory_bytes{stat}, gauge, unit: bytes). stat
is a closed AllocatorStat variant; the sampler refreshes the
current value periodically. Default: no-op (backward-compatible).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