diff options
| author | tv <tv@krebsco.de> | 2026-10-24 06:35:11 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 06:35:11 +0200 |
| commit | c59f213282517e3ab6fb631a7d8e3f9b91a1c5eb (patch) | |
| tree | 09924d630140527f18ef7ba5b7f60fc28fc8a89b /src/api/stats.rs | |
| parent | 19bc0fbf4e148430064bd040bfe0db25ab137555 (diff) | |
add propagation stats
Diffstat (limited to 'src/api/stats.rs')
| -rw-r--r-- | src/api/stats.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/api/stats.rs b/src/api/stats.rs index e426c7a..3822b5f 100644 --- a/src/api/stats.rs +++ b/src/api/stats.rs @@ -24,6 +24,27 @@ pub(crate) struct StatsResponse { traffic: PeerTraffic, /// The peers listed in /peers together (a forgotten peer's are gone). incidents: Incidents, + propagation: PropagationStats, +} + +/// How long changes written elsewhere took from their commit there until applied here, +/// once caught up. Includes the clock skew between the writer and us. +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +struct PropagationStats { + count: u64, + sum_ms: u64, + /// Changes stamped later than our clock on arrival (writer's clock ahead). + ahead: u64, + /// Not cumulative; the last bucket has no bound. + buckets: Vec<PropagationBucket>, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +struct PropagationBucket { + le_ms: Option<u64>, + count: u64, } #[derive(Debug, Serialize)] @@ -139,5 +160,15 @@ pub(crate) async fn get_stats(State(state): State<AppState>) -> Json<StatsRespon stale_hello_replies: node.stale_hello_replies, traffic: state.traffic.total(), incidents, + propagation: PropagationStats { + count: node.propagation.count, + sum_ms: node.propagation.sum_ms, + ahead: node.propagation.ahead, + buckets: node + .propagation + .buckets() + .map(|(le_ms, count)| PropagationBucket { le_ms, count }) + .collect(), + }, }) } |
