-
Notifications
You must be signed in to change notification settings - Fork 918
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
No uncaught service exceptions are logged out of the box. #4324
Comments
Overall it is a useful feature. That being said, as an error of a client request is propagated via the returned |
This uncaught exception log can be setup as a periodic task that logs summary of the uncaught exceptions, something like
Or, if we'd like to generalize this even more - we could have a log message that returns multiple stats like that
In my experience periodic summaries like that are super useful for debugging because they can store detailed internal state summary for the service, easy to find, provides insight even when other metrics (e.g. Prometheus) are missing. |
If we log the counter message, we could uncount the uncaught exceptions whose Given logging every uncaught exceptions can be very spammy, we could:
|
Hi, I've few questions while trying to solve this issue.
|
|
#4687) Motivation: If `LoggingService` is not added to services, exceptions(without appropriate exception handlers) thrown by those services are not caught. This default behavior can be confusing for users because, even though exceptions are being thrown, there are no logs to indicate that anything is wrong. The purpose of this feature is to enable the reporting of unhandled exceptions by default, so that users can be alerted to any issues and take appropriate action. Modifications: - `com.linecorp.armeria.defaultUnhandledExceptionsReportIntervalMillis` vm option can be used to configure intervals between reporting unhandled exceptions in milliseconds. - Add `shouldReportUnhandledExceptions` to `DefaultServiceRequestContext` which determines whether to log unhandled exceptions. - Add `ExceptionReportingServerErrorHandler` to report unhandled exceptions. Result: - [Closes #<4324>](#4324). (If this resolves the issue.) - User will be able to check the number of uncaught exceptions and thrown exception periodically by default. - If multiple servers with same `MeterRegistry` exist, `armeria.server.exceptions.unhandled` metrics will be the sum of all the number of unhandled exceptions on those servers. However, individual servers will be reported with logs that include total number of unhandled exceptions specific to that server only. <b>Example</b> - User can change default settings by using `ServerBuilder` ``` final ServerBuilder sb = Server.builder(); sb.http(port); sb.unhandledExceptionsReportIntervalMillis(1000L); configureServices(sb); return sb.build(); ``` - Result ``` [armeria-common-worker-nio-2-1] WARN com.linecorp.armeria.server.ExceptionReportingServerErrorHandler - Observed 1 unhandled exceptions in last 1000ms(1000000000ns). Please consider adding the LoggingService decorator to get detailed error logs. One of the thrown exceptions: example.armeria.server.annotated.ExceptionHandlerService$LocallySpecificException at example.armeria.server.annotated.ExceptionHandlerService.exception1(ExceptionHandlerService.java:36) at com.linecorp.armeria.internal.server.annotation.AnnotatedService.invoke(AnnotatedService.java:355) at com.linecorp.armeria.internal.server.annotation.AnnotatedService.lambda$serve0$8(AnnotatedService.java:324) at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:684) ... ``` Closes #4324
When a new user writes an Armeria server, the user often doesn't realize they have to add
LoggingService
to see the actual exception in the log. This default behavior can be very confusing. It would be nice if we can log the uncaught service exceptions by default somehow without worrying too much about double notification.One idea:
RequestContext.shouldLogUncaughtException
which is true by default.LoggingClient
andLoggingService
to setfalse
toshouldLogUncaughtException
.Thoughts?
The text was updated successfully, but these errors were encountered: