Skip to content
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

Feature enhancement (Logger): automatically intercept Runtime exceptions, and log information #1527

Open
mriccia opened this issue Nov 22, 2023 · 7 comments
Assignees
Labels
good first issue Good for newcomers priority:3 Neutral - not a core feature or affects less than 40% of users status/staged-major-release This change will go with the next major release v2 Version 2
Milestone

Comments

@mriccia
Copy link
Contributor

mriccia commented Nov 22, 2023

Is your feature request related to a problem? Please describe.

When using the Powertools Logger, log lines are annotated with a number of useful fields such as function_request_id.
However, if a Runtime exception is thrown, Powertools Logger isn't used to log the exception. Instead the exception is printed using the System.err by the JVM, and the log lines do not contain any information relating to the function execution.

Describe the solution you'd like

I would like the RuntimeExceptions to be printed, so when exceptions are raised in my code, I can identify the function_request_id for further debugging

Describe alternatives you've considered

It is possible for Powertools users to define their own catching mechanism, however it would be nice if Powertools Logger printed this information by default

Additional context

@scottgerring
Copy link
Contributor

The logger aspect could:

  • Catch and log at an appropriate level in a structured fashion
  • Rethrow

We'll get the error twice in the logs - once structured once stdout, but i'd be hesitant to interfere with the runtime itself seeing the exception too.

@jeromevdl
Copy link
Contributor

we can't avoid the runtime to log, unless we catch the exception completely, but we cannot do that, if the function is in error the caller must be aware, so just catch / log (fatal) / rethrow

@jeromevdl
Copy link
Contributor

Do we add this to v1 or v2? While I'm working on logging v2, I can do it, but if we do in v1, I let @mriccia.

@scottgerring
Copy link
Contributor

@mriccia if you feel especially attached to it lets add it in v1, otherwise I don't think we should push new features there as discussed.

@scottgerring scottgerring added priority:3 Neutral - not a core feature or affects less than 40% of users and removed triage labels Nov 30, 2023
@scottgerring
Copy link
Contributor

@mriccia do you know what you want to do with this?

@mriccia
Copy link
Contributor Author

mriccia commented Nov 30, 2023

IMO we should add it in v2, as I only saw this request from customers once and does not appear to be a big issue

@scottgerring scottgerring added the v2 Version 2 label Dec 7, 2023
@scottgerring scottgerring added the good first issue Good for newcomers label Dec 15, 2023
@scottgerring
Copy link
Contributor

Completed for v2 as part of #1435

@scottgerring scottgerring added the status/staged-major-release This change will go with the next major release label Dec 15, 2023
@scottgerring scottgerring added this to the v2 milestone Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers priority:3 Neutral - not a core feature or affects less than 40% of users status/staged-major-release This change will go with the next major release v2 Version 2
Projects
Status: Triage
Development

No branches or pull requests

3 participants