From 19781d3aeb23af28bb021aa7eee7b79a0240a354 Mon Sep 17 00:00:00 2001 From: Tianning Li Date: Tue, 24 Feb 2026 17:25:23 -0500 Subject: [PATCH] fix(traces): downgrade handle_proxy body-read failure from ERROR to WARN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Lambda freezes or terminates a function instance, the OS closes the TCP connection mid-request. The extension's proxy handler fails to buffer the body and logs at ERROR level, creating noise with no actionable signal. This is expected Lambda lifecycle behavior — the function completed successfully and nothing in the extension is broken. Introduce `warn_response` (mirroring `error_response`) and use it for this path so the log level correctly reflects an external event rather than an extension fault. Fixes https://github.com/DataDog/datadog-lambda-extension/issues/1000 --- bottlecap/src/traces/trace_agent.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bottlecap/src/traces/trace_agent.rs b/bottlecap/src/traces/trace_agent.rs index 4035e24e8..6ad5c00cc 100644 --- a/bottlecap/src/traces/trace_agent.rs +++ b/bottlecap/src/traces/trace_agent.rs @@ -659,7 +659,7 @@ impl TraceAgent { let (parts, body) = match extract_request_body(request).await { Ok(r) => r, Err(e) => { - return error_response( + return warn_response( StatusCode::INTERNAL_SERVER_ERROR, format!("TRACE_AGENT | handle_proxy | Error extracting request body: {e}"), ); @@ -721,6 +721,13 @@ fn error_response(status: StatusCode, error: E) -> Respons (status, error.to_string()).into_response() } +/// Like [`error_response`], but logs at WARN level. Use when the failure is caused by an +/// external event (e.g. client disconnected) rather than a bug in the extension itself. +fn warn_response(status: StatusCode, error: E) -> Response { + warn!("{}", error); + (status, error.to_string()).into_response() +} + fn success_response(message: &str) -> Response { debug!("{}", message); (StatusCode::OK, json!({"rate_by_service": {}}).to_string()).into_response()