Skip to content

Commit

Permalink
Ignore known exceptions from logging (#1032)
Browse files Browse the repository at this point in the history
Motivation:

Central Dogma does not use Armeria's `LoggingClient`, so known exceptions handled by `HttpApiExceptionHandler` are logged in `DefaultUnloggedExceptionsReporter`.
```java
Observed 1 exception(s) that didn't reach a LoggingService in the last 10000ms(10000000000ns). Please consider adding a LoggingService as the outermost decorator to get detailed error logs. One of the thrown exceptions:

com.linecorp.centraldogma.common.RedundantChangeException: changes did not change anything in <project>/<repository> at revision <rev>: []
at com.linecorp.centraldogma.server.internal.storage.repository.git.GitRepository.commit0(GitRepository.java:964)
at com.linecorp.centraldogma.server.internal.storage.repository.git.GitRepository.blockingCommit(GitRepository.java:904)
at com.linecorp.centraldogma.server.internal.storage.repository.git.GitRepository.lambda$commit$6(GitRepository.java:875)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
at io.micrometer.core.instrument.internal.TimedRunnable.run(TimedRunnable.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) 
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
```

Moditications:

- Set `ctx.setShouldReportUnloggedExceptions(false)` to ignore known exceptions they don't need to be logged.

Result:

You no longer see warnings about ignorable exceptions.
  • Loading branch information
ikhoon authored Sep 10, 2024
1 parent a9a083e commit a4003a5
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,17 @@ public HttpResponse onServiceException(ServiceRequestContext ctx, Throwable caus
final BiFunction<ServiceRequestContext, Throwable, HttpResponse> func =
exceptionHandlers.get(peeledCause.getClass());
if (func != null) {
ctx.setShouldReportUnloggedExceptions(false);
return func.apply(ctx, peeledCause);
}

if (peeledCause instanceof IllegalArgumentException) {
ctx.setShouldReportUnloggedExceptions(false);
return newResponse(ctx, HttpStatus.BAD_REQUEST, peeledCause);
}

if (peeledCause instanceof RequestAlreadyTimedOutException) {
ctx.setShouldReportUnloggedExceptions(false);
return newResponse(ctx, HttpStatus.SERVICE_UNAVAILABLE, peeledCause);
}

Expand Down

0 comments on commit a4003a5

Please sign in to comment.