-
Notifications
You must be signed in to change notification settings - Fork 359
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
Match error handling to other runtimes #241
Comments
I have an even simpler suggestion, use |
We had a similar set up in the past but required muuuch more machinery and was a bit onerous on the user end. There might still.be a way to have the best of both worlds with fancy downcasting. I'd propose some unit tests here. Might have caught the usability issue sooner |
+1 |
I'll attempt a PR in a few days. |
Actually, this is a breaking change. The existing code will compile, but may output nothing or some dummy text. |
You are fortunately afforded the luxury of timing here here. The current state of code has evolved much beyond what's been released in a breaking change sort of way. If there was a good time to make a change to improve usability but might be considered a breaking change, now is that time. |
Logging errors from inside
and an init statement somewhere before
I'm inclined to make the loggers an optional feature, disabled by default. |
Thanks for opening this issue! I'm personally inclined to use |
One is an interface and the other should be a user choice. When you bind simple logger you remove a user choice. Please try to avoid removing user choice for logging! An alternative is opting for your simple logger in the mains where you want the extra logging and set that to error or what have you. I'm a fan of tracing is nice but also feels like it should be a user choice |
Thanks for the reference. I'm worried that we might limited in what information we can send to Lambda, but I'll need to dig into this: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html.
+1. @nmoutschen and I are working on finishing up a tracing-xray integration that already works in this runtime. That might be another option here.
+1
For sure! One of the things we've put a lot of effort into |
Sorry for accidentally closing this issue! Didn't mean to. |
This snippet is from Cargo.toml (https://github.com/awslabs/aws-lambda-rust-runtime/blob/master/lambda/Cargo.toml#L9):
which doesn't make sense to me.
Shall we remove simulated from the list of features while I am at it? |
@davidbarsky David, does It works fine with
It all compiles and runs on AWS Lambda, but no log entries are written into CloudWatch via I could not get any logging via Here is the full snippet ...
|
I'm assuming you're using You can also add additional |
I'm just using |
Just wanted to echo the voice of a minimal runtime again so something can ship soon. The problem to be solved here is to log an error, correct?
|
It makes sense; I wrote a decent portion of those docs!
tracing's spans will be a different target in |
Yup on both counts. Wanted to provide support where I could. Plus, had an off-day/break today, so the README changes didn't get posted.
Nothing wrong with it! You can write the exact same thing in |
What do all those extra brackets and characters mean? The CloudWatch log looks cleaner, but I don't get what those 2m, 34m and other prefixes mean.
which took me a while to dig out from tracing examples. It is not even documented (not that I noticed). Initializing the logger via a different crate has no effect on tracing. So this one will work, but the runtime with tracing won't log anything:
Proposal
Here is an example of log output at the same level for the same call, but without tracing. This line was logged by the runtime in response to a handler error, which was the whole point of my quest :)
|
They're ansi escape codes that can be disabled using using this method: https://docs.rs/tracing-subscriber/0.2.8/tracing_subscriber/fmt/struct.Layer.html#method.with_ansi.
Yeah, we went down a wild goose chase. Sorry about that!
I'd normally agree with this approach, but I think we can resolve this quickly. In your PR, try replacing |
I understand |
This is where I disagree and regret mentioning With that being said—and please correct me if I'm wrong—this issue was opened to resolve how this runtime should report errors to the Invocation error endpoint. The current implementation has lots of room for improvement—I'll accept ownership and blame for that. I've personally found lambda::set_hook(Box::new(|e: Box<dyn std::error::Error + Send + Sync + 'static>| {
if let Some(e) = e.downcast_ref::<std::io::Error>() {
Diagnostic {
error_message: format!("{}", e),
error_type: "std::io::Error"
}
}
// handle any other variant you care to report, falling back to the `type_name`-based approach as a default.
// I didn't write a fallback, but let's assume this closure _must_ return a `lambda::Diagnostic`.
})); As @Veetaha mentioned in #243 (comment), we're between a rock (the current AWS APIs) and a hard place (the lack of stable specialization in Rust). This downcasting-based approach feels like the least bad approach to me, but what do you think? Additionally, free to ping me directly over Discord or even setup a call. I'd be happy to walk through and discuss my thinking, which might be lossy over text. |
David, can you give me a quick example how to init tracing so that it produces a clean output, preferably identical to that of |
@rimutaka Take a look at there examples I just pushed: https://github.com/awslabs/aws-lambda-rust-runtime/tree/davidbarsky/update-readme/lambda/examples. The example |
Don't worry about undoing your PR; rebasing your very helpful documentation changes atop of that branch would be the most helpful. |
I had
I think that disabling the ANSI color codes would solve that for most the "output will look different" part. Now, I hear @softprops and @rimutaka when it comes to adding more (unnecessary?) deps: I'm biased towards AWS-managed ways. Having X-Rays is a big plus on my book. OTOH, if that introduces several MB on the final release lambda bin, then that's not cool and I would rather prefer leaner bins for lambdas. What does the release binsize delta look like? I think that OT-ish: I can PR |
@davidbarsky , I got it about Also, when I tried to init the logger via |
Yup, here's how: https://github.com/awslabs/aws-lambda-rust-runtime/blob/davidbarsky/update-readme/lambda/examples/hello-without-macro-tracing.rs#L16.
Kinda. That'll enable
Hrm, I'm unable to reproduce this. The first example below makes use of I think using cargo bloat is a good idea, but I'd hold off on making a PR. |
@davidbarsky, I applied my changes on top of your branch, kept tracing and your examples. Both lambda-http/examples failed to compile. It complained about a missing trait. Nothing to do with my changes. Do you know what needs to be fixed? Shall I commit as-is or attempt to fix it? |
Commit as is to your PR; we can dig into those issues as needed. |
Further to the discussion on the bloat and the size of the binaries. Compiled with
|
I'm wondering if it helps to move things forward. can we separate how the error name is derived from how it is logged? there's lots of ways to log an error but I assume there's like one pretty good way to format the name of the error type. On picking a log impl and size and all that. cargo feature flags can help with that! |
I agree with @softprops that we should deal with the |
I keep accidentally closing this issue; sorry about that. |
* rimutaka/master: (26 commits) Removed unnecessary + Sync on handler's future Added docs and missing _vars to reduce warnings Enforced Send+Sync for http Handler impl. Added some tracing!() to lib.rs. Fixed "Process exited" error in lib.rs. client.rs formatting fix Log panic as Debug+Display, improved examples Added err logging to lib.rs, consolidated examples Added error handling for awslabs#241, interim, broken. Removed unused refs from basic.rs disable time on `tracing_subscriber` Add log and tracing examples; fix `tracing` dependency features. Upper-cased and edited examples/readme.md Corrected handler_fn interface misconception in basic.rs Fixed comment in lib.rs Formatting fix in error-handling.rs. Fixed headers in examples readme. Tidied up examples readme. Added basic.rs example, comments to other examples Log handler errors in runtime. Issue awslabs#241 ...
* reorg * Replace `genawaiter` with `async-stream` (#240) * don't depend on serde_derive directly * Add Cargo.lock to gitignore; whoops. * Cleanup docs; handle panics in lambda functions correctly. * Create a reusable runtime struct + builder * Log handler errors in runtime. Issue #241 * Added basic.rs example, comments to other examples * Tidied up examples readme. * Fixed headers in examples readme. * Formatting fix in error-handling.rs. * Fixed comment in lib.rs * Corrected handler_fn interface misconception in basic.rs Co-authored-by: Veetaha <veetaha2@gmail.com> * Upper-cased and edited examples/readme.md * Add log and tracing examples; fix `tracing` dependency features. * disable time on `tracing_subscriber` * Removed unused refs from basic.rs * Added error handling for #241, interim, broken. * Added err logging to lib.rs, consolidated examples * Log panic as Debug+Display, improved examples * client.rs formatting fix * Fixed "Process exited" error in lib.rs. * Added some tracing!() to lib.rs. * Enforced Send+Sync for http Handler impl. * Added docs and missing _vars to reduce warnings * Removed unnecessary + Sync on handler's future * All tests passing * Remove deprecated simple_logger calls * Remove Cargo.lock * cargo fmt changes Co-authored-by: David Barsky <me@davidbarsky.com> Co-authored-by: Lucio Franco <luciofranco14@gmail.com> Co-authored-by: Ubuntu <ubuntu@ip-172-31-47-28.ap-southeast-2.compute.internal> Co-authored-by: rimutaka <max@onebro.me> Co-authored-by: Veetaha <veetaha2@gmail.com>
This change was merged with #284. Closing this issue. |
The format of error messages returned by the runtime is hard to work with at the client end.
Example:
It is produced by this code in
aws-lambda-rust-runtime/lambda/src/lib.rs
Line 216 in f404617
with help from
Proposed change
error!
so that it appears in CloudWatch.e
into JSON instead of Debug output ({:?}).std::any::type_name
if none was provided.Here are examples of what other runtimes are producing:
Discussion
I'm not 100% sure how it all can be implemented yet. Just wondering if this is a problem that impacts others and is worth looking into.
The text was updated successfully, but these errors were encountered: