From 7739dffbcf16b65138498d77615e687a28d1e713 Mon Sep 17 00:00:00 2001 From: AJ Stuyvenberg Date: Tue, 2 Jul 2024 22:39:27 -0400 Subject: [PATCH] fix: Don't send duplicate logs during orphan processing --- bottlecap/src/logs/lambda/processor.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bottlecap/src/logs/lambda/processor.rs b/bottlecap/src/logs/lambda/processor.rs index e73e4bf55..8ce89e8a7 100644 --- a/bottlecap/src/logs/lambda/processor.rs +++ b/bottlecap/src/logs/lambda/processor.rs @@ -235,6 +235,9 @@ impl LambdaProcessor { LambdaProcessor::apply_rules(&self.rules, &mut log.message.message); if should_send_log { if let Ok(serialized_log) = serde_json::to_string(&log) { + // explicitly drop log so we don't accidentally re-use it and push + // duplicate logs to the aggregator + drop(log); to_send.push(serialized_log); } } @@ -244,7 +247,8 @@ impl LambdaProcessor { orphan_log.message.lambda.request_id = Some(self.invocation_context.request_id.clone()); if should_send_log { - if let Ok(serialized_log) = serde_json::to_string(&log) { + if let Ok(serialized_log) = serde_json::to_string(&orphan_log) { + drop(orphan_log); to_send.push(serialized_log); } }