summaryrefslogtreecommitdiffstats
path: root/src/api/stats/prometheus.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/stats/prometheus.rs')
-rw-r--r--src/api/stats/prometheus.rs88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/api/stats/prometheus.rs b/src/api/stats/prometheus.rs
index 8e6fde7..9cbeff4 100644
--- a/src/api/stats/prometheus.rs
+++ b/src/api/stats/prometheus.rs
@@ -420,6 +420,94 @@ pub(super) async fn render(state: &AppState, stats: &StatsResponse) -> String {
);
}
+ out.family(
+ "document_lock_wait_seconds",
+ "histogram",
+ "Time waited for the document's lock, by mode (read, write).",
+ );
+ let lock_wait = &document.lock_wait;
+ for (mode, waits) in [("read", &lock_wait.read), ("write", &lock_wait.write)] {
+ let mut cumulative = 0;
+ for (le_us, count) in waits.buckets() {
+ cumulative += count;
+ let le = match le_us {
+ Some(us) => (us as f64 / 1e6).to_string(),
+ None => "+Inf".to_owned(),
+ };
+ out.sample(
+ "document_lock_wait_seconds_bucket",
+ &[("mode", mode), ("le", &le)],
+ cumulative as f64,
+ );
+ }
+ out.sample(
+ "document_lock_wait_seconds_sum",
+ &[("mode", mode)],
+ waits.sum_us as f64 / 1e6,
+ );
+ out.sample(
+ "document_lock_wait_seconds_count",
+ &[("mode", mode)],
+ waits.count as f64,
+ );
+ }
+ out.family(
+ "document_lock_wait_max_seconds",
+ "gauge",
+ "Longest wait for the document's lock since start, by mode.",
+ );
+ for (mode, waits) in [("read", &lock_wait.read), ("write", &lock_wait.write)] {
+ out.sample(
+ "document_lock_wait_max_seconds",
+ &[("mode", mode)],
+ waits.max_us as f64 / 1e6,
+ );
+ }
+
+ out.family(
+ "document_lock_wait_seconds",
+ "histogram",
+ "Time waited for the document's lock, by mode (read, write).",
+ );
+ let lock_wait = &document.lock_wait;
+ for (mode, waits) in [("read", &lock_wait.read), ("write", &lock_wait.write)] {
+ let mut cumulative = 0;
+ for (le_us, count) in waits.buckets() {
+ cumulative += count;
+ let le = match le_us {
+ Some(us) => (us as f64 / 1e6).to_string(),
+ None => "+Inf".to_owned(),
+ };
+ out.sample(
+ "document_lock_wait_seconds_bucket",
+ &[("mode", mode), ("le", &le)],
+ cumulative as f64,
+ );
+ }
+ out.sample(
+ "document_lock_wait_seconds_sum",
+ &[("mode", mode)],
+ waits.sum_us as f64 / 1e6,
+ );
+ out.sample(
+ "document_lock_wait_seconds_count",
+ &[("mode", mode)],
+ waits.count as f64,
+ );
+ }
+ out.family(
+ "document_lock_wait_max_seconds",
+ "gauge",
+ "Longest wait for the document's lock since start, by mode.",
+ );
+ for (mode, waits) in [("read", &lock_wait.read), ("write", &lock_wait.write)] {
+ out.sample(
+ "document_lock_wait_max_seconds",
+ &[("mode", mode)],
+ waits.max_us as f64 / 1e6,
+ );
+ }
+
let catch_up = &stats.catch_up;
out.single(
"catch_up_sources_total",