summaryrefslogtreecommitdiffstats
path: root/src/transport/stats.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-28 02:18:01 +0100
committertv <tv@krebsco.de>2026-10-28 02:19:50 +0100
commit24327be7e09c20a9820eac61ba3ac60fb7bdb424 (patch)
treef2a1b0b7321c4b1912297fb0725c3ee5800af948 /src/transport/stats.rs
parent3c56f0df5c23b5c8d4bc4cc748cbd18812910ffe (diff)
measure paths
Diffstat (limited to 'src/transport/stats.rs')
-rw-r--r--src/transport/stats.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/transport/stats.rs b/src/transport/stats.rs
index 35238f5..6b1a42f 100644
--- a/src/transport/stats.rs
+++ b/src/transport/stats.rs
@@ -11,6 +11,8 @@ use serde::Serialize;
pub(crate) struct TransportStats {
/// The identity layer's (`transport::identity`); absent without one.
pub(crate) identity: Option<IdentityStats>,
+ /// The paths layer's (`transport::paths`); absent without one.
+ pub(crate) paths: Option<PathsStats>,
/// The libp2p transport's; absent if it isn't one of this node's.
pub(crate) libp2p: Option<Libp2pStats>,
}
@@ -21,12 +23,53 @@ impl TransportStats {
if other.identity.is_some() {
self.identity = other.identity;
}
+ if other.paths.is_some() {
+ self.paths = other.paths;
+ }
if other.libp2p.is_some() {
self.libp2p = other.libp2p;
}
}
}
+/// How the paths to peers with several addresses do (`transport::paths`).
+#[derive(Debug, Clone, Default, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct PathsStats {
+ /// Every path measured: those of peers this node chose among lately.
+ pub(crate) paths: Vec<PathInfo>,
+ #[serde(flatten)]
+ pub(crate) counts: PathCounts,
+}
+
+/// One path, as `transport::paths` measures it.
+#[derive(Debug, Clone, PartialEq, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct PathInfo {
+ /// `<scheme>:<transport identity>`.
+ pub(crate) address: String,
+ /// Smoothed round-trip time of its PINGs; absent before an answer.
+ pub(crate) rtt_ms: Option<f64>,
+ /// Its PINGs went unanswered three times in a row, or a send there failed within a
+ /// minute: used only when no other path works.
+ pub(crate) down: bool,
+}
+
+/// Counts since start.
+#[derive(Debug, Clone, Copy, Default, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct PathCounts {
+ pub(crate) probes_sent: u64,
+ pub(crate) probes_answered: u64,
+ pub(crate) probes_unanswered: u64,
+ /// Sends that failed on a path (each tried at the next).
+ pub(crate) send_failures: u64,
+ /// Sends that went over another path after one failed.
+ pub(crate) failovers: u64,
+ /// Changes of the path in use for one faster.
+ pub(crate) switches: u64,
+}
+
/// Who is where (`transport::identity`): the books now, and counts since start.
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]