-
Notifications
You must be signed in to change notification settings - Fork 361
Logging error chains to CloudWatch #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
mlafeldt
added a commit
to mlafeldt/dilbert-feed
that referenced
this issue
Sep 23, 2021
Related to this, the error returned to the caller also misses any context:
|
@mlafeldt do you want to open a PR and change this? I think we'd be open to that improvement. |
mlafeldt
added a commit
to mlafeldt/aws-lambda-rust-runtime
that referenced
this issue
Feb 9, 2022
The anyhow crate will only include the error chain with {:?} or {:#}. Without this change, only the last error will be logged to CloudWatch and all underlying causes are lost when using with_context to augment errors. Fixes awslabs#348
mlafeldt
added a commit
to mlafeldt/aws-lambda-rust-runtime
that referenced
this issue
Feb 9, 2022
The anyhow crate will only include the error chain with {:?} or {:#}. Without this change, only the last error will be logged to CloudWatch and all underlying causes are lost when using with_context to augment errors. Fixes awslabs#348
mlafeldt
added a commit
to mlafeldt/aws-lambda-rust-runtime
that referenced
this issue
Feb 9, 2022
The anyhow crate will only include the error chain with {:?} or {:#}. Without this change, only the last error will be logged to CloudWatch and all underlying causes are lost when using with_context to augment errors. Fixes awslabs#348
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I noticed that the Rust runtime currently logs handler errors using
{}
as the format:aws-lambda-rust-runtime/lambda-runtime/src/lib.rs
Line 178 in 3871cb4
However, the widely used anyhow crate will only include the error chain with
{:?}
or{:#}
:https://github.com/dtolnay/anyhow/blob/71caf88b78cc3faf2b99ac3d7397a66a7da5a930/src/fmt.rs#L7-L40
Among other things, this means that only the last error will be logged to CloudWatch and that all underlying causes are lost when using with_context to augment errors.
My current solution/workaround is to add an additional log statement like this:
Of course, this duplicates error logging to some degree and would have to be done in every Lambda function. I wonder if there's a better way of telling the runtime how to log errors?
The text was updated successfully, but these errors were encountered: