diff --git a/bottlecap/Cargo.lock b/bottlecap/Cargo.lock index 41a6272da..bb6f5d25d 100644 --- a/bottlecap/Cargo.lock +++ b/bottlecap/Cargo.lock @@ -525,7 +525,7 @@ dependencies = [ "tokio", "tokio-util", "tonic-types", - "tower 0.5.3", + "tower", "tower-http", "tracing", "tracing-core", diff --git a/bottlecap/src/lifecycle/invocation/processor.rs b/bottlecap/src/lifecycle/invocation/processor.rs index ccb9f497e..e369e5238 100644 --- a/bottlecap/src/lifecycle/invocation/processor.rs +++ b/bottlecap/src/lifecycle/invocation/processor.rs @@ -285,7 +285,10 @@ impl Processor { /// This is used to create a cold start span, since this telemetry event does not /// provide a `request_id`, we try to guess which invocation is the cold start. pub fn on_platform_init_start(&mut self, time: DateTime, runtime_version: Option) { - if runtime_version.as_deref().map_or(false, |rv| rv.contains("DurableFunction")) { + if runtime_version + .as_deref() + .is_some_and(|rv| rv.contains("DurableFunction")) + { self.enhanced_metrics.set_durable_function_tag(); } let start_time: i64 = SystemTime::from(time) diff --git a/bottlecap/src/logger.rs b/bottlecap/src/logger.rs index 56079b90b..b9a828fc7 100644 --- a/bottlecap/src/logger.rs +++ b/bottlecap/src/logger.rs @@ -79,7 +79,10 @@ where let message = format!("DD_EXTENSION | {level} | {span_prefix}{}", visitor.0); - write!(writer, "{{\"level\":\"{level}\",\"message\":\"")?; + // Setting specifically `status` as opposed to `level` since AWS + // filters out logs by the `level` field. This allows our logs to + // appear in CWL regardless of the log level. + write!(writer, "{{\"status\":\"{level}\",\"message\":\"")?; write_json_escaped(&mut writer, &message)?; writeln!(writer, "\"}}") } @@ -187,7 +190,7 @@ mod tests { let parsed: serde_json::Value = serde_json::from_str(output.trim()).expect("output should be valid JSON"); - assert_eq!(parsed["level"], "INFO"); + assert_eq!(parsed["status"], "INFO"); assert!( parsed["message"] .as_str() @@ -204,7 +207,7 @@ mod tests { let parsed: serde_json::Value = serde_json::from_str(output.trim()).expect("output should be valid JSON"); - assert_eq!(parsed["level"], "ERROR"); + assert_eq!(parsed["status"], "ERROR"); assert!( parsed["message"] .as_str() @@ -221,7 +224,7 @@ mod tests { let parsed: serde_json::Value = serde_json::from_str(output.trim()).expect("output should be valid JSON"); - assert_eq!(parsed["level"], "DEBUG"); + assert_eq!(parsed["status"], "DEBUG"); assert!( parsed["message"] .as_str()