From d661f9e001a5b7866d67756a24cb66885471195d Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 04:10:37 +0100 Subject: prometheus: build per-peer series from /peers --- src/api/peers.rs | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/api/peers.rs') diff --git a/src/api/peers.rs b/src/api/peers.rs index 2f93a43..b425ba6 100644 --- a/src/api/peers.rs +++ b/src/api/peers.rs @@ -32,9 +32,9 @@ pub(crate) enum PeerLivenessStatus { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct EpochInfo { - generation: u64, + pub(crate) generation: u64, /// Hex-encoded snapshot hash; all zeros for the genesis epoch. - id: String, + pub(crate) id: String, } impl From for EpochInfo { @@ -50,63 +50,63 @@ impl From for EpochInfo { #[serde(rename_all = "camelCase")] pub(crate) struct PeerStatus { /// The name the peer gave itself in the member list, if any (not unique). - alias: Option, + pub(crate) alias: Option, /// Where this node reaches it, or would (`Transport::addresses_of`). - addresses: Vec, + pub(crate) addresses: Vec, /// Where messages to it go now: the address, whether the peer proved itself there, /// and the connection there (libp2p: direct or relayed). Absent if nowhere. - destination: Option, - validated_swarm: Option, - status: PeerLivenessStatus, - handshake_complete: bool, - last_seen_secs_ago: Option, - dormant_for_secs: Option, + pub(crate) destination: Option, + pub(crate) validated_swarm: Option, + pub(crate) status: PeerLivenessStatus, + pub(crate) handshake_complete: bool, + pub(crate) last_seen_secs_ago: Option, + pub(crate) dormant_for_secs: Option, /// Since a sync message from it was applied (or the epoch changed). - last_sync_secs_ago: Option, + pub(crate) last_sync_secs_ago: Option, /// How long its heads have differed from ours with no sync message from it in /// between; absent while they match. - diverged_for_secs: Option, - has_pending_delivery: bool, + pub(crate) diverged_for_secs: Option, + pub(crate) has_pending_delivery: bool, /// Epoch the peer last advertised; absent until it has sent a message. - epoch: Option, + pub(crate) epoch: Option, /// Whether that epoch equals ours, i.e. whether we sync with this peer. - same_epoch: Option, + pub(crate) same_epoch: Option, /// Number of heads in its last keepalive; absent before one, or when it had more /// than 32 (then only their digest and some of them are sent). - heads: Option, + pub(crate) heads: Option, /// We keep it alive and sync with it on our own; other peers we only answer. - neighbour: bool, + pub(crate) neighbour: bool, /// Messages and payload bytes exchanged with it, by kind, since we started (or /// since it was last listed). - traffic: PeerTraffic, - incidents: Incidents, + pub(crate) traffic: PeerTraffic, + pub(crate) incidents: Incidents, /// Smoothed sync throughput (`swarm::throughput`); absent before the first large /// exchange. - sync_throughput: Option, + pub(crate) sync_throughput: Option, } #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct ThroughputInfo { - bytes_per_sec: f64, - samples: u32, + pub(crate) bytes_per_sec: f64, + pub(crate) samples: u32, /// Age of the last sample. - secs_ago: u64, + pub(crate) secs_ago: u64, } #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct PeerListResponse { /// Our own alias (`--alias`). - local_alias: Option, - local_epoch: EpochInfo, + pub(crate) local_alias: Option, + pub(crate) local_epoch: EpochInfo, /// Number of heads of our document. Several heads are concurrent changes no later /// change has merged yet. - local_heads: usize, + pub(crate) local_heads: usize, /// Where this node can be reached (`Transport::local_addresses`). - local_addresses: Vec, + pub(crate) local_addresses: Vec, /// By node ID. - peers: BTreeMap, + pub(crate) peers: BTreeMap, } #[derive(Debug, Deserialize)] -- cgit v1.3.1