diff options
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(), + }, }) } |
