From a4003a56dc93ad5fd27e5127396f86fe59709f7b Mon Sep 17 00:00:00 2001 From: Ikhun Um Date: Tue, 10 Sep 2024 16:07:13 +0900 Subject: [PATCH] Ignore known exceptions from logging (#1032) 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 / at revision : [] 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. --- .../server/internal/api/HttpApiExceptionHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/main/java/com/linecorp/centraldogma/server/internal/api/HttpApiExceptionHandler.java b/server/src/main/java/com/linecorp/centraldogma/server/internal/api/HttpApiExceptionHandler.java index f889ba46f7..5528e14f57 100644 --- a/server/src/main/java/com/linecorp/centraldogma/server/internal/api/HttpApiExceptionHandler.java +++ b/server/src/main/java/com/linecorp/centraldogma/server/internal/api/HttpApiExceptionHandler.java @@ -127,14 +127,17 @@ public HttpResponse onServiceException(ServiceRequestContext ctx, Throwable caus final BiFunction 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); }