From 5ee77c0b1fea79dbee69e291f6b084197801a785 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 27 Jan 2023 18:41:07 +0200 Subject: [PATCH] Fix holding tracing span guard over query execution. I added these spans to trace how long the queries take, but I didn't realize that there's a difference between: let _ = span.entered(); and let _guard = span.entered(); The former drops the guard immediately, while the latter holds it until the end of the scope. As a result, the span was ended immediately, and the query was executed outside the span. --- compute_tools/src/spec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compute_tools/src/spec.rs b/compute_tools/src/spec.rs index 8e249f3722..bbd0ec21ed 100644 --- a/compute_tools/src/spec.rs +++ b/compute_tools/src/spec.rs @@ -387,13 +387,13 @@ pub fn handle_databases(spec: &ComputeSpec, client: &mut Client) -> Result<()> { name.pg_quote(), db.owner.pg_quote() ); - let _ = info_span!("executing", query).entered(); + let _guard = info_span!("executing", query).entered(); client.execute(query.as_str(), &[])?; } DatabaseAction::Create => { let mut query: String = format!("CREATE DATABASE {} ", name.pg_quote()); query.push_str(&db.to_pg_options()); - let _ = info_span!("executing", query).entered(); + let _guard = info_span!("executing", query).entered(); client.execute(query.as_str(), &[])?; } };