awslabs / aws-lambda-rust-runtime

A Rust runtime for AWS Lambda
Apache License 2.0
3.29k stars 335 forks source link

how to log tracing::error with a custom message #865

Closed evbo closed 3 months ago

evbo commented 3 months ago

I only receive the following non-descript error logs, despite calling tracing::error! with more specifics:

{
    "time": "2024-04-26T23:09:32.311Z",
    "type": "platform.initRuntimeDone",
    "record": {
        "initializationType": "on-demand",
        "phase": "init",
        "status": "error",
        "errorType": "Runtime.ExitError"
    }
}

Example of how I call tracing:

let err_info = format!("Something very very bad happened");
tracing::error!(name: "invalid_input", "Invalid input: {}", err_info);
bnusunny commented 3 months ago

This is a Lambda system log. Your function crashed during init and didn't reach your logging code.

evbo commented 3 months ago

@bnusunny you're very right about that!

So I set the new "advanced" log level to Error thinking I would see errors... but only after setting it to Info did it finally print the problem:

/var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/bootstrap)

Why would that be an INFO log?!!! :)

Or is this an AWS bug I'm ranting about?

pbintcha commented 3 months ago

@bnusunny you're very right about that!

So I set the new "advanced" log level to Error thinking I would see errors... but only after setting it to Info did it finally print the problem:

/var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/bootstrap)

Why would that be an INFO log?!!! :)

Or is this an AWS bug I'm ranting about?

I fix this GLIBC_2.28 not found error by updating the lambda runtime to Amazon Linux 2023

evbo commented 3 months ago

@pbintcha I fixed it by switching to musl arm target during build (instead of using --arm64). Cool idea upgrading I'll try that.

bnusunny commented 3 months ago

Newer Lambda runtimes are based on Amazon Linux 2023 with glibc 2.34. Older Lambda runtimes are based on Amazon Linux 2 with glibc 2.26. You can find out the OS version for each runtime here.

github-actions[bot] commented 3 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one.