pub struct FailureMetrics { /* private fields */ }Expand description
Live, mutable accumulator for failure-cause counters.
Cheap to clone via Arc; every method takes &self.
Implementations§
Source§impl FailureMetrics
impl FailureMetrics
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a fresh accumulator with all counters and gauges zeroed.
§Examples
use dynomite::stats::FailureMetrics;
let m = FailureMetrics::new();
assert_eq!(m.snapshot().backend_send_full, 0);Sourcepub fn record_no_targets(
&self,
dc: &str,
rack: &str,
consistency: ConsistencyLevel,
)
pub fn record_no_targets( &self, dc: &str, rack: &str, consistency: ConsistencyLevel, )
Increment the dispatch_no_targets_total counter for the
given local-DC labels.
§Examples
use dynomite::msg::ConsistencyLevel;
use dynomite::stats::FailureMetrics;
let m = FailureMetrics::new();
m.record_no_targets("dc1", "rA", ConsistencyLevel::DcOne);
m.record_no_targets("dc1", "rA", ConsistencyLevel::DcOne);
assert_eq!(m.snapshot().no_targets[0].count, 2);Sourcepub fn record_peer_send_full(&self, peer_idx: u32, peer_dc: &str)
pub fn record_peer_send_full(&self, peer_idx: u32, peer_dc: &str)
Increment the dispatch_peer_send_full_total counter.
Sourcepub fn record_peer_send_closed(&self, peer_idx: u32, peer_dc: &str)
pub fn record_peer_send_closed(&self, peer_idx: u32, peer_dc: &str)
Increment the dispatch_peer_send_closed_total counter.
Sourcepub fn record_backend_send_full(&self)
pub fn record_backend_send_full(&self)
Increment the dispatch_backend_send_full_total counter.
Sourcepub fn record_backend_send_closed(&self)
pub fn record_backend_send_closed(&self)
Increment the dispatch_backend_send_closed_total
counter.
Sourcepub fn record_response_timeout(&self, consistency: ConsistencyLevel)
pub fn record_response_timeout(&self, consistency: ConsistencyLevel)
Increment the dispatch_response_timeout_total counter.
Used by the response coalescer when every per-target
sender drops without producing a reply (i.e. the request
timed out at the dispatch layer).
Sourcepub fn record_peer_state_transition(
&self,
peer_idx: u32,
dc: &str,
rack: &str,
from: PeerState,
to: PeerState,
)
pub fn record_peer_state_transition( &self, peer_idx: u32, dc: &str, rack: &str, from: PeerState, to: PeerState, )
Record a peer-state transition. Increments
peer_state_transitions_total by one and updates the
peer_state_current gauge to the new state.
Sourcepub fn observe_peer_state(
&self,
peer_idx: u32,
dc: &str,
rack: &str,
state: PeerState,
)
pub fn observe_peer_state( &self, peer_idx: u32, dc: &str, rack: &str, state: PeerState, )
Update the peer_state_current gauge without recording
a transition. Useful for the initial publish at startup
and when an evaluate tick observes a peer whose state
has not changed.
Sourcepub fn observe_phi(&self, peer_idx: u32, dc: &str, rack: &str, phi: f64)
pub fn observe_phi(&self, peer_idx: u32, dc: &str, rack: &str, phi: f64)
Update the gossip_phi_score gauge for a peer. The phi
value is rounded to thousandths and stored as an i64
(millis); the snapshot exposes a floating-point view
rebuilt from that integer.
Sourcepub fn snapshot(&self) -> FailureSnapshot
pub fn snapshot(&self) -> FailureSnapshot
Build an immutable snapshot of every counter and gauge.
The returned FailureSnapshot is Clone and Send, so
the stats aggregator can stash it in the snapshot cell
without holding the underlying lock.