From ada91b2097c7d4ec4dff3a5264dffb07fd818a68 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Fri, 29 Nov 2024 20:10:32 +0100 Subject: [PATCH] open time spent throttled --- pageserver/src/metrics.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pageserver/src/metrics.rs b/pageserver/src/metrics.rs index 33b494f618..48a2c5f941 100644 --- a/pageserver/src/metrics.rs +++ b/pageserver/src/metrics.rs @@ -1427,6 +1427,25 @@ impl SmgrQueryTimePerTimeline { ) -> GlobalAndPerTimelineHistogramTimer<'c> { self.global_started[op as usize].inc(); + // We subtract time spent throttled from the observed latency. + match ctx.micros_spent_throttled.open() { + Ok(()) => (), + Err(error) => { + use utils::rate_limit::RateLimit; + static LOGGED: Lazy>> = + Lazy::new(|| { + Mutex::new(enum_map::EnumMap::from_array(std::array::from_fn(|_| { + RateLimit::new(Duration::from_secs(10)) + }))) + }); + let mut guard = LOGGED.lock().unwrap(); + let rate_limit = &mut guard[op]; + rate_limit.call(|| { + warn!(?op, error, "error opening micros_spent_throttled; this message is logged at a global rate limit"); + }); + } + } + let per_timeline_latency_histo = if matches!(op, SmgrQueryType::GetPageAtLsn) { self.per_timeline_getpage_started.inc(); Some(self.per_timeline_getpage_latency.clone())