From 5db66f56764cfef61b30438198a7d503ee63e616 Mon Sep 17 00:00:00 2001 From: Miguel Fernandez Date: Fri, 30 Dec 2022 18:41:13 +0100 Subject: [PATCH] Revert "Output params key in events" This reverts commit 9278ba3b985646a1b0b9f4b6f664485cb66c8fd4. --- .../core/src/telemetry/capturing/capturer.rs | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/query-engine/core/src/telemetry/capturing/capturer.rs b/query-engine/core/src/telemetry/capturing/capturer.rs index 14b532c166ef..ed3a044db627 100644 --- a/query-engine/core/src/telemetry/capturing/capturer.rs +++ b/query-engine/core/src/telemetry/capturing/capturer.rs @@ -129,17 +129,13 @@ impl Candidate<'_, models::TraceSpan> { "unknown".to_string() }; - let mut attributes: HashMap = vec![( + let attributes = vec![( "duration_ms".to_owned(), serde_json::Value::Number(serde_json::Number::from_f64(duration_ms).unwrap()), )] .into_iter() .collect(); - if let Some(params) = span.attributes.get("params") { - attributes.insert("params".to_owned(), params.clone()); - }; - models::Event { span_id: Some(span.span_id.to_owned()), name: statement, @@ -171,12 +167,8 @@ impl Candidate<'_, models::LogEvent> { fn query_event(self) -> models::LogEvent { let mut attributes = self.value.attributes; let mut attrs = HashMap::new(); - if let Some(duration) = attributes.get("duration_ms") { - attrs.insert("duration_ms".to_owned(), duration.clone()); - } - - if let Some(params) = attributes.get("params") { - attrs.insert("params".to_owned(), params.clone()); + if let Some(dur) = attributes.get("duration_ms") { + attrs.insert("duration_ms".to_owned(), dur.clone()); } let mut name = "uknown".to_owned(); @@ -368,9 +360,14 @@ mod tests { level: "debug".to_owned(), timestamp: [101, 0], attributes: vec![ - ("target".to_owned(), serde_json::json!("mongodb_query_connector::query")), - ("query".to_owned(), serde_json::json!("db.Users.find()")), - ("params".to_owned(), serde_json::json!(vec![1])), + ( + "target".to_owned(), + serde_json::Value::String("mongodb_query_connector::query".to_owned()), + ), + ( + "query".to_owned(), + serde_json::Value::String("db.Users.find()".to_owned()), + ), ("duration_ms".to_owned(), serde_json::json!(100.0)), ] .into_iter() @@ -390,8 +387,7 @@ mod tests { Capture::LogEvent(event) => { assert_eq!(event.level, "query"); assert_eq!(event.name.to_string().as_str(), "db.Users.find()"); - assert!(event.attributes.contains_key("duration_ms")); - assert!(event.attributes.contains_key("params")) + assert_eq!(event.attributes.get("duration_ms").unwrap().to_string(), "100.0"); } _ => unreachable!(), }; @@ -427,10 +423,10 @@ mod tests { name: "prisma:engine:db_query".to_ascii_lowercase(), start_time: [101, 0], end_time: [101, 10000000], - attributes: vec![ - ("db.statement".to_owned(), serde_json::json!("SELECT ?")), - ("params".to_owned(), serde_json::json!([1])), - ] + attributes: vec![( + "db.statement".to_owned(), + serde_json::Value::String("SELECT 1".to_owned()), + )] .into_iter() .collect(), events: Default::default(), @@ -451,9 +447,8 @@ mod tests { match capture { Capture::LogEvent(event) => { assert_eq!(event.level, "query"); - assert_eq!(event.name.to_string().as_str(), "SELECT ?"); - assert!(event.attributes.contains_key("duration_ms")); - assert!(event.attributes.contains_key("params")); + assert_eq!(event.name.to_string().as_str(), "SELECT 1"); + assert_eq!(event.attributes.get("duration_ms").unwrap().to_string(), "10.0"); } _ => unreachable!(), };