Struct kitsune_p2p::metrics::Metrics
source · pub struct Metrics { /* private fields */ }
Expand description
Metrics tracking for remote nodes to help choose which remote node to initiate the next round with.
Implementations§
source§impl Metrics
impl Metrics
sourcepub fn dump_historical(&self) -> Vec<MetricRecord>
pub fn dump_historical(&self) -> Vec<MetricRecord>
Dump historical metrics for recording to db.
sourcepub fn record_extrap_cov_event(&mut self, extrap_cov: f32)
pub fn record_extrap_cov_event(&mut self, extrap_cov: f32)
Record an individual extrapolated coverage event (either from us or a remote) and add it to our running aggregate extrapolated coverage metric.
sourcepub fn record_reachability_event<'a, T, I>(
&mut self,
success: bool,
remote_agent_list: I
)
pub fn record_reachability_event<'a, T, I>( &mut self, success: bool, remote_agent_list: I )
Sucessful and unsuccessful messages from the remote
can be combined to estimate a “reachability quotient”
between 1 (or 0 if empty) and 100. Errors are weighted
heavier because we retry less frequently.
Call this to register a reachability event.
Note, record_success
and record_error
below invoke this
function internally, you don’t need to call it again.
sourcepub fn record_latency_micros<'a, T, I, V>(
&mut self,
micros: V,
remote_agent_list: I
)
pub fn record_latency_micros<'a, T, I, V>( &mut self, micros: V, remote_agent_list: I )
Running average for latency microseconds for any direct request/response calls to remote agent.
sourcepub fn record_initiate<'a, T, I>(
&mut self,
remote_agent_list: I,
gossip_type: GossipModuleType
)
pub fn record_initiate<'a, T, I>( &mut self, remote_agent_list: I, gossip_type: GossipModuleType )
Record a gossip round has been initiated by us.
sourcepub fn record_accept<'a, T, I>(
&mut self,
remote_agent_list: I,
gossip_type: GossipModuleType
)
pub fn record_accept<'a, T, I>( &mut self, remote_agent_list: I, gossip_type: GossipModuleType )
Record a gossip round has been initiated by a peer.
sourcepub fn record_success<'a, T, I>(
&mut self,
remote_agent_list: I,
gossip_type: GossipModuleType
)
pub fn record_success<'a, T, I>( &mut self, remote_agent_list: I, gossip_type: GossipModuleType )
Record a gossip round has completed successfully.
sourcepub fn record_error<'a, T, I>(
&mut self,
remote_agent_list: I,
gossip_type: GossipModuleType
)
pub fn record_error<'a, T, I>( &mut self, remote_agent_list: I, gossip_type: GossipModuleType )
Record a gossip round has finished with an error.
sourcepub fn update_current_round(
&mut self,
peer: &NodeId,
gossip_type: GossipModuleType,
round_state: &RoundState
)
pub fn update_current_round( &mut self, peer: &NodeId, gossip_type: GossipModuleType, round_state: &RoundState )
Update node-level info about a current round, or create one if it doesn’t exist
sourcepub fn complete_current_round(&mut self, node: &NodeId, error: bool)
pub fn complete_current_round(&mut self, node: &NodeId, error: bool)
Remove the current round info once it’s complete, and put it into the history list
sourcepub fn record_force_initiate(&mut self)
pub fn record_force_initiate(&mut self)
Record that we should force initiate the next few rounds.
sourcepub fn last_success<'a, T, I>(
&self,
remote_agent_list: I
) -> Option<&RoundMetric>
pub fn last_success<'a, T, I>( &self, remote_agent_list: I ) -> Option<&RoundMetric>
Get the last successful round time.
sourcepub fn is_current_round<'a, T, I>(&self, remote_agent_list: I) -> bool
pub fn is_current_round<'a, T, I>(&self, remote_agent_list: I) -> bool
Is this node currently in an active round?
sourcepub fn last_outcome<'a, T, I>(
&self,
remote_agent_list: I
) -> Option<RoundOutcome>
pub fn last_outcome<'a, T, I>( &self, remote_agent_list: I ) -> Option<RoundOutcome>
What was the last outcome for this node’s gossip round?
sourcepub fn forced_initiate(&self) -> bool
pub fn forced_initiate(&self) -> bool
Should we force initiate the next round?
sourcepub fn reachability_quotient<'a, T, I>(&self, remote_agent_list: I) -> f32
pub fn reachability_quotient<'a, T, I>(&self, remote_agent_list: I) -> f32
Return the average (mean) reachability quotient for the supplied remote agents.
sourcepub fn latency_micros<'a, T, I>(&self, remote_agent_list: I) -> f32
pub fn latency_micros<'a, T, I>(&self, remote_agent_list: I) -> f32
Return the average (mean) latency microseconds for the supplied remote agents.
sourcepub fn peer_agent_histories(
&self
) -> &HashMap<Arc<KitsuneAgent>, PeerAgentHistory>
pub fn peer_agent_histories( &self ) -> &HashMap<Arc<KitsuneAgent>, PeerAgentHistory>
Getter
sourcepub fn peer_node_histories(&self) -> &HashMap<NodeId, PeerNodeHistory>
pub fn peer_node_histories(&self) -> &HashMap<NodeId, PeerNodeHistory>
Getter
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Metrics
impl RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl UnwindSafe for Metrics
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> 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.