mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-23 16:10:37 +00:00
## Problem We don't have metrics to exactly quantify the end user impact of on-demand downloads. Perf tracing is underway (#11140) to supply us with high-resolution *samples*. But it will also be useful to have some aggregate per-timeline and per-instance metrics that definitively contain all observations. ## Summary of changes This PR consists of independent commits that should be reviewed independently. However, for convenience, we're going to merge them together. - refactor(metrics): measure_remote_op can use async traits - impr(pageserver metrics): task_kind dimension for remote_timeline_client latency histo - implements https://github.com/neondatabase/cloud/issues/26800 - refs https://github.com/neondatabase/cloud/issues/26193#issuecomment-2769705793 - use the opportunity to rename the metric and add a _global suffix; checked grafana export, it's only used in two personal dashboards, one of them mine, the other by Heikki - log on-demand download latency for expensive-to-query but precise ground truth - metric for wall clock time spent waiting for on-demand downloads ## Refs - refs https://github.com/neondatabase/cloud/issues/26800 - a bunch of minor investigations / incidents into latency outliers
27 lines
565 B
Rust
27 lines
565 B
Rust
use std::time::{Duration, Instant};
|
|
|
|
#[derive(Default)]
|
|
pub struct ElapsedAccum {
|
|
accum: Duration,
|
|
}
|
|
|
|
impl ElapsedAccum {
|
|
pub fn get(&self) -> Duration {
|
|
self.accum
|
|
}
|
|
pub fn guard(&mut self) -> impl Drop + '_ {
|
|
let start = Instant::now();
|
|
scopeguard::guard(start, |last_wait_at| {
|
|
self.accum += Instant::now() - last_wait_at;
|
|
})
|
|
}
|
|
|
|
pub async fn measure<Fut, O>(&mut self, fut: Fut) -> O
|
|
where
|
|
Fut: Future<Output = O>,
|
|
{
|
|
let _guard = self.guard();
|
|
fut.await
|
|
}
|
|
}
|