feat(lambda-runtime): log non-2xx Lambda Runtime API responses with status and body#1109
Merged
darklight3it merged 6 commits intomainfrom Feb 26, 2026
Merged
feat(lambda-runtime): log non-2xx Lambda Runtime API responses with status and body#1109darklight3it merged 6 commits intomainfrom
darklight3it merged 6 commits intomainfrom
Conversation
added 2 commits
February 25, 2026 16:55
…useful for the customer for timeouts
added 2 commits
February 25, 2026 17:29
…e a separate tracing_subscriber
Contributor
Author
|
Added an issue explaining the problem |
jlizen
approved these changes
Feb 26, 2026
Collaborator
jlizen
left a comment
There was a problem hiding this comment.
This approach looks good to me. It should keep the worker id span intact if using tracing, which is nice.
rarepolz
approved these changes
Feb 26, 2026
FullyTyped
reviewed
Mar 3, 2026
Collaborator
FullyTyped
left a comment
There was a problem hiding this comment.
exactly what i had in mind!
Comment on lines
+96
to
+127
| RuntimeApiClientFutureProj::Second(fut) => match ready!(fut.poll(cx)) { | ||
| Ok(resp) if !resp.status().is_success() => { | ||
| let status = resp.status(); | ||
|
|
||
| // TODO | ||
| // we should consume the response body of the call in order to give a more specific message. | ||
| // https://github.com/aws/aws-lambda-rust-runtime/issues/1110 | ||
|
|
||
| log_or_print!( | ||
| tracing: tracing::error!(status = %status, "Lambda Runtime API returned non-200 response"), | ||
| fallback: eprintln!("Lambda Runtime API returned non-200 response: status={status}") | ||
| ); | ||
|
|
||
| // Adding more information on top of 410 Gone, to make it more clear since we cannot access the body of the message | ||
| if status == 410 { | ||
| log_or_print!( | ||
| tracing: tracing::error!("Lambda function timeout!"), | ||
| fallback: eprintln!("Lambda function timeout!") | ||
| ); | ||
| } | ||
|
|
||
| // Return Ok to maintain existing contract - runtime continues despite API errors | ||
| break Ok(()); | ||
| } | ||
| Ok(_) => break Ok(()), | ||
| Err(err) => { | ||
| log_or_print!( | ||
| tracing: tracing::error!(error = ?err, "Lambda Runtime API request failed"), | ||
| fallback: eprintln!("Lambda Runtime API request failed: {err:?}") | ||
| ); | ||
| break Err(err); | ||
| } |
Collaborator
There was a problem hiding this comment.
Exactly what I had in mind.
Comment on lines
+145
to
+148
| async fn start_mock_server(status: StatusCode) -> String { | ||
| let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); | ||
| let addr = listener.local_addr().unwrap(); | ||
| let url = format!("http://{}", addr); |
Collaborator
There was a problem hiding this comment.
Much easier than harness tests ;)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the Lambda Runtime API returns a non-2xx response (e.g., HTTP 410 for timeout, 500 for internal errors), the runtime previously provided no visibility into these failures. Customers had no way to diagnose why their Lambda invocations were failing at the runtime API level.
Solution
Add comprehensive error logging for all non-2xx responses from the Lambda Runtime API, while maintaining backward compatibility by preserving the existing behavior of returning
Ok(())and avoiding backward compatibility issue withRuntimeApiClientFuturewhich is unfortunately public.Changes
1. Created
log_or_print!macro (lambda-runtime/src/macros.rs)tracing::error!when a tracing dispatcher is seteprintln!when no tracing subscriber is configured2. Enhanced error logging in
RuntimeApiClientFuture(lambda-runtime/src/layers/api_client.rs)Ok(())for non-2xx responses to avoid breaking existing runtime behavior3. Added comprehensive test coverage
tracing-testdev dependency for testing logging behavior#[traced_test]4. Updated
lambda-runtime/src/runtime.rslog_or_print!macro to existing concurrency warning for consistencyExample log output
Backward Compatibility
This change is fully backward compatible:
RuntimeApiClientFuturestill returnsOk(())for non-2xx responses (preserving existing behavior)Testing
Run tests with: