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.
Trait Implementations§
Source§impl Debug for FailureMetrics
impl Debug for FailureMetrics
Source§impl Default for FailureMetrics
impl Default for FailureMetrics
Source§fn default() -> FailureMetrics
fn default() -> FailureMetrics
Auto Trait Implementations§
impl !Freeze for FailureMetrics
impl !RefUnwindSafe for FailureMetrics
impl Send for FailureMetrics
impl Sync for FailureMetrics
impl Unpin for FailureMetrics
impl UnsafeUnpin for FailureMetrics
impl UnwindSafe for FailureMetrics
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.