From c59f213282517e3ab6fb631a7d8e3f9b91a1c5eb Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 06:35:11 +0200 Subject: add propagation stats --- src/api/stats.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/api/stats.rs') 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, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +struct PropagationBucket { + le_ms: Option, + count: u64, } #[derive(Debug, Serialize)] @@ -139,5 +160,15 @@ pub(crate) async fn get_stats(State(state): State) -> Json