diff --git a/crates/ipx/src/db.rs b/crates/ipx/src/db.rs index 5e9532e..08a6a10 100644 --- a/crates/ipx/src/db.rs +++ b/crates/ipx/src/db.rs @@ -327,7 +327,13 @@ thread_local! { /// shortcut: half the queries, measured by difference; a wrapper on sqlx's pool would see all. fn waited(started: std::time::Instant) { if let Some(q) = LAST_QUERY.take() { - crate::metrics::DB_WAIT.observe("", started.elapsed().saturating_sub(q).as_secs_f64()); + let wait = started.elapsed().saturating_sub(q); + crate::metrics::DB_WAIT.observe("", wait.as_secs_f64()); + // On the step too, so a slow one in Tempo says whether it waited for a connection or for + // Postgres: the metric's spread could not say which of a page's queries it was. + let span = tracing::Span::current(); + span.record("wait_ms", wait.as_millis() as u64); + span.record("query_ms", q.as_millis() as u64); } } @@ -3074,7 +3080,11 @@ pub enum EntryFlag { /// A span for one step of a request or a scan, and none outside one: the healthcheck and the page's /// live updates run the same code, and every call there would be a trace of its own. pub fn step(of: &'static str) -> tracing::Span { - if tracing::Span::current().is_none() { tracing::Span::none() } else { tracing::info_span!("step", of) } + if tracing::Span::current().is_none() { + tracing::Span::none() + } else { + tracing::info_span!("step", of, wait_ms = tracing::field::Empty, query_ms = tracing::field::Empty) + } } /// A file on disk with no DeadAir copy made since it was downloaded (issue #171).