From 76a56f5940bd44d9f51cd73b89b274c65ff2a081 Mon Sep 17 00:00:00 2001 From: Miguel Fernandez Date: Fri, 27 Jan 2023 14:03:28 +0100 Subject: [PATCH] Emit query log in quaint:query span, rather than in its parent --- src/connector/metrics.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/connector/metrics.rs b/src/connector/metrics.rs index 278f90f6a..6ea9ac349 100644 --- a/src/connector/metrics.rs +++ b/src/connector/metrics.rs @@ -14,8 +14,16 @@ where U: Future>, { let span = info_span!("quaint:query", "db.statement" = %query); + do_query(tag, query, params, f).instrument(span).await +} + +async fn do_query<'a, F, T, U>(tag: &'static str, query: &'a str, params: &'a [Value<'_>], f: F) -> crate::Result +where + F: FnOnce() -> U + 'a, + U: Future>, +{ let start = Instant::now(); - let res = f().instrument(span).await; + let res = f().await; let result = match res { Ok(_) => "success",