From 47333054fdc454a6ce206819af38a8fba4e3bbdf Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Tue, 8 Oct 2024 11:28:25 +0200 Subject: [PATCH] Build query_string on top --- .../mongodb-query-connector/src/root_queries/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/query-engine/connectors/mongodb-query-connector/src/root_queries/mod.rs b/query-engine/connectors/mongodb-query-connector/src/root_queries/mod.rs index 3e62c2cc6e8..7690bbf13a2 100644 --- a/query-engine/connectors/mongodb-query-connector/src/root_queries/mod.rs +++ b/query-engine/connectors/mongodb-query-connector/src/root_queries/mod.rs @@ -60,10 +60,15 @@ where F: FnOnce() -> U + 'a, U: Future>, { + // TODO: build the string lazily in the Display impl so it doesn't have to be built if neither + // logs nor traces are enabled. This is tricky because whatever we store in the span has to be + // 'static, and all `QueryString` implementations aren't, so this requires some refactoring. + let query_string = builder.build(); + let span = info_span!( "prisma:engine:db_query", user_facing = true, - "db.statement" = builder.build() + "db.statement" = query_string.clone() ); let start = Instant::now(); @@ -74,7 +79,6 @@ where increment_counter!(PRISMA_DATASOURCE_QUERIES_TOTAL); // TODO prisma/team-orm#136: fix log subscription. - let query_string = builder.build(); // NOTE: `params` is a part of the interface for query logs. debug!(target: "mongodb_query_connector::query", item_type = "query", is_query = true, query = %query_string, params = "[]", duration_ms = elapsed);