Skip to content

Commit c96c15c

Browse files
fix(traces): downgrade handle_proxy body-read failure from ERROR to WARN (#1046)
JIRA: https://datadoghq.atlassian.net/browse/SLES-2729 Issue: #1000 **Overview** When AWS Lambda freezes or terminates a function instance, the OS immediately closes all TCP sockets. The extension's proxy HTTP handler (handle_proxy) was mid-read on the request body — this read fails with error reading a body from connection and was logged at ERROR level, generating noise with no actionable signal. This is expected Lambda lifecycle behaviour: the Lambda function completed successfully and nothing in the extension is broken. The ERROR level implies an extension fault, which misleads operators. **Change** Introduce a warn_response helper (mirroring the existing error_response / success_response trio) and use it for body-read failures in handle_proxy. The log message content is unchanged — only the severity is downgraded from ERROR to WARN. Testing - unit tests
1 parent 12703d9 commit c96c15c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

bottlecap/src/traces/trace_agent.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl TraceAgent {
659659
let (parts, body) = match extract_request_body(request).await {
660660
Ok(r) => r,
661661
Err(e) => {
662-
return error_response(
662+
return warn_response(
663663
StatusCode::INTERNAL_SERVER_ERROR,
664664
format!("TRACE_AGENT | handle_proxy | Error extracting request body: {e}"),
665665
);
@@ -721,6 +721,13 @@ fn error_response<E: std::fmt::Display>(status: StatusCode, error: E) -> Respons
721721
(status, error.to_string()).into_response()
722722
}
723723

724+
/// Like [`error_response`], but logs at WARN level. Use when the failure is caused by an
725+
/// external event (e.g. client disconnected) rather than a bug in the extension itself.
726+
fn warn_response<E: std::fmt::Display>(status: StatusCode, error: E) -> Response {
727+
warn!("{}", error);
728+
(status, error.to_string()).into_response()
729+
}
730+
724731
fn success_response(message: &str) -> Response {
725732
debug!("{}", message);
726733
(StatusCode::OK, json!({"rate_by_service": {}}).to_string()).into_response()

0 commit comments

Comments
 (0)