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

Enhance exception logging in MonitoredJob#handleExceptionSafely #391

Closed
sleberknight opened this issue Oct 26, 2023 · 0 comments · Fixed by #409
Closed

Enhance exception logging in MonitoredJob#handleExceptionSafely #391

sleberknight opened this issue Oct 26, 2023 · 0 comments · Fixed by #409
Assignees
Labels
enhancement A request for change or improvement to an existing feature
Milestone

Comments

@sleberknight
Copy link
Member

sleberknight commented Oct 26, 2023

MonitoredJob#handleExceptionSafely logs the fact that an exception occurred at WARN level. For a job named "MyJob", the log message looks like:

Encountered exception in job: MyJob

MonitoredJob implements kiwi's CatchingRunnable, which logs the actual exception. But, we should change the message so that it provides information about the exception type, message, and possibly cause and/or root cause so that it can be correlated with the error and exception stack trace logged by CatchingRunnable.

In a recent problem, I was debugging a job that threw an org.kiwiproject.concurrent.AsyncException, which was caused by a java.util.concurrent.ExecutionException, which had a root cause of java.lang.NullPointerException.

Instead of the above error message, it would have been more useful to see a message like:

Encountered org.kiwiproject.concurrent.AsyncException exception in job 'MyJob' with root
cause java.lang.NullPointerException (look for the exception and stack trace logged by
CatchingRunnable#runSafely)

So, this tells you at a glance what the exception and root cause were, and also that you can find the exception information and stack trace that was logged by CatchingRunnable.

@sleberknight sleberknight added the enhancement A request for change or improvement to an existing feature label Oct 26, 2023
@sleberknight sleberknight changed the title Log exceptions in MonitoredJob at DEBUG level Enhance exception logging in MonitoredJob#handleExceptionSafely Oct 26, 2023
@sleberknight sleberknight self-assigned this Nov 26, 2023
@sleberknight sleberknight added this to the 3.1.0 milestone Nov 26, 2023
sleberknight added a commit that referenced this issue Nov 26, 2023
* Enhance messages logged by handleExceptionSafely to include the
  exception type, and if present, the root cause. Also mention that
  the stack trace logged by CatchingRunnable will be ABOVE this
  log message.
* Add 'tests' which exercise the two causes - an Exception with
  a separate root cause, and one without one, i.e. such that
  the root cause is itself.

Closes #391
chrisrohr pushed a commit that referenced this issue Nov 26, 2023
* Enhance messages logged by handleExceptionSafely to include the
  exception type, and if present, the root cause. Also mention that
  the stack trace logged by CatchingRunnable will be ABOVE this
  log message.
* Add 'tests' which exercise the two causes - an Exception with
  a separate root cause, and one without one, i.e. such that
  the root cause is itself.

Closes #391
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A request for change or improvement to an existing feature
Projects
None yet
1 participant