question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ObserverExceptionHandler for non async observers

See original GitHub issue

Description

I am facing a production issue right now, where all my log says is:

Failure occurred while notifying a transational Observer [method=observerMethod()] for event of type CustomType
- please enable debug logging to see the full stack trace

(I removed the FQCN, and replaced them with placeholders).

The above log is obiously not enough to figure out what the original exception was. Was it a TimeoutException while publishing to RabbitMQ, or was it a LazyInitException from some hibernate entity? The range of possibilities is simply to wide figure it out with this limited information.

I am not going to activate debug logging on the production system every time I face this issue. I need a solution which I configure once, and it just works. Also, how it is implemented right now, this would lead to 2 lines logged. One error (the one above), and one debug. The debug logs are not going into our usual monitoring solution - I would need to see the logs on the prod system.

This is where the logging is happening: https://github.com/quarkusio/quarkus/blob/ef43e2a95e48828fee2cf5f1990ebca48ea7a96d/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/EventImpl.java#L473-L480

For Async Observers, I found AsyncObserverExceptionHandler, which allows to modify how their exceptions are logged: https://quarkus.io/guides/cdi-reference#exceptions-thrown-by-an-asynchronous-observer-method

For normal Observers, can either:

  • the exception always be logged. Because what is someone going to do without it?
  • or an ObserverExceptionHandler be added, which would allow me to configure logging to my needs?

Implementation ideas

No response

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
manovotncommented, Nov 23, 2022

Looking some more into the original issue, I think the reason might have been to reduce the noise from observer methods that can (deliberately?) sometimes throw an exception. It looks like @famod and @gsmet both commented in favor of that, see https://github.com/quarkusio/quarkus/pull/23944.

I don’t remember but we should at least log the exception cause as Weld does.

I agree. I wouldn’t even mind showing the whole error but due to the above, I don’t think I’ll get by with that 😃 Anyhow, I’ll send a PR that at least improves it.

0reactions
mkoubacommented, Nov 23, 2022

I agree. I wouldn’t even mind showing the whole error but due to the above, I don’t think I’ll get by with that 😃

The root cause class and exception message should be enough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle exceptions thrown by observer's onNext in ...
How to handle exceptions thrown by observer's onNext in RxJava? ... Consider the following example: Observable.range(1, 10).subscribe(i -> { System.out.println(i); ...
Read more >
What if an exception is thrown by the observer in OnNext?
It seems to be the case that it is the observer's responsability not to throw, but as you can see, it is very...
Read more >
Exceptions of @ObservesAsync methods are not logged #11525
Describe the bug. I have an @ObservesAsync observer method. If it throws an exception, it is not logged anywhere.
Read more >
Chapter 7. Error handling with RxJS - RxJS in Action
This chapter covers. The issues with imperative error–handling schemes; Using functional data types to abstract exception handling; Using observable operators ...
Read more >
CDI Events – Synchronous x Asynchronous - William Markito
Let's assume you have multiple @Observers for the same event. In this case, all the work done by the @Observers will occur on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found