feat(lambda-runtime): log non-2xx Lambda Runtime API responses with status and body#1109
Open
darklight3it wants to merge 4 commits intomainfrom
Open
feat(lambda-runtime): log non-2xx Lambda Runtime API responses with status and body#1109darklight3it wants to merge 4 commits intomainfrom
darklight3it wants to merge 4 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
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.
| @@ -0,0 +1,10 @@ | |||
| // Logs using tracing `error!` if a dispatcher is set, otherwise falls back to `eprintln!`. | |||
| macro_rules! log_or_print { | |||
Collaborator
There was a problem hiding this comment.
i like the new macro interface
| Ok(resp) if !resp.status().is_success() => { | ||
| let status = resp.status(); | ||
|
|
||
| log_or_print!( |
Collaborator
There was a problem hiding this comment.
minor: worth a TODO comment linking to the follow-up issue about the body?
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: