orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Make interception of unhandled exceptions optional and non-static

Open sergeybykov opened this issue 9 years ago • 2 comments

Today, UnobservedExceptionsHandlerClass unconditionally intercept unhandled exceptions by adding itself to TaskScheduler.UnobservedTaskException. This interferes with application code if it intercepts those exceptions already and pollutes the logs. Need to make our interception optional (still on by default).

For logging unhandled exceptions, UnobservedExceptionsHandlerClass gets a logger instance via a static LogManager.GetLogger("UnobservedExceptionHandler") call. That likely has to change too, to align with the logging infra getting revamped.

sergeybykov avatar Aug 10 '17 16:08 sergeybykov

The way it gets its logger will be changing from LogManager.GetLogger to get a ILogger<UnobservedExceptionsHandlerClass> from DI, after we completely migrate to asp.net logging abstraction.

To make it optional, the class will need to at least remove its static constructor. But I would suggest the following:

  • make it non-static. Make it a singleton in DI if multiple classes in the same runtime need to access it. But based on my observation in code, that is not the case. So mostly it will just become a normal class .
  • add a config in ClusterConfiguration and ClientConfiguration for user to turn it on or off. By default turn it off.

what do you think?

xiazen avatar Aug 10 '17 18:08 xiazen

can close after #3829 is merged

xiazen avatar Jan 04 '18 21:01 xiazen