summaryrefslogtreecommitdiffstats
path: root/src/api/stats.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/stats.rs')
-rw-r--r--src/api/stats.rs30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/api/stats.rs b/src/api/stats.rs
index 6c5e172..8899421 100644
--- a/src/api/stats.rs
+++ b/src/api/stats.rs
@@ -9,6 +9,8 @@ use axum::{
http::{HeaderMap, header},
response::{IntoResponse, Response},
};
+use std::collections::BTreeMap;
+
use serde::Serialize;
use super::peers::EpochInfo;
@@ -35,11 +37,11 @@ pub(crate) struct StatsResponse {
/// The peers listed in /peers together (a forgotten peer's are gone).
incidents: Incidents,
propagation: PropagationStats,
- disk: DiskStats,
+ /// This node's own files (`files`), by kind.
+ disk: BTreeMap<&'static str, DiskStats>,
}
-/// Files this node reads and writes for itself (the state file, a backup to recover
-/// from), since it started.
+/// Reads and writes of one kind of file, since the node started.
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
struct DiskStats {
@@ -47,6 +49,7 @@ struct DiskStats {
read_bytes: u64,
writes: u64,
written_bytes: u64,
+ errors: u64,
}
/// How long changes written elsewhere took from their commit there until applied here,
@@ -207,11 +210,20 @@ async fn collect(state: &AppState) -> StatsResponse {
.map(|(le_ms, count)| PropagationBucket { le_ms, count })
.collect(),
},
- disk: DiskStats {
- reads: node.disk.reads,
- read_bytes: node.disk.read_bytes,
- writes: node.disk.writes,
- written_bytes: node.disk.written_bytes,
- },
+ disk: state
+ .files
+ .counts()
+ .into_iter()
+ .map(|(kind, counts)| {
+ let stats = DiskStats {
+ reads: counts.reads,
+ read_bytes: counts.read_bytes,
+ writes: counts.writes,
+ written_bytes: counts.written_bytes,
+ errors: counts.errors,
+ };
+ (kind.as_str(), stats)
+ })
+ .collect(),
}
}