From 474a51e0b08ff1812fbb7ac82d8690e5a64800c7 Mon Sep 17 00:00:00 2001 From: Laksh Singla Date: Fri, 27 Oct 2023 11:08:18 +0530 Subject: [PATCH] better logging --- .../apache/druid/rpc/ServiceClientImpl.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/apache/druid/rpc/ServiceClientImpl.java b/server/src/main/java/org/apache/druid/rpc/ServiceClientImpl.java index 2146ed5d5be9..d84a77a0ae69 100644 --- a/server/src/main/java/org/apache/druid/rpc/ServiceClientImpl.java +++ b/server/src/main/java/org/apache/druid/rpc/ServiceClientImpl.java @@ -220,7 +220,16 @@ public void onFailure(final Throwable t) if (shouldTry(nextAttemptNumber) && retryPolicy.retryThrowable(t)) { final long backoffMs = computeBackoffMs(retryPolicy, attemptNumber); - log.noStackTrace().info(t, buildErrorMessage(request, null, backoffMs, nextAttemptNumber)); + if (log.isDebugEnabled()) { + log.debug(t, buildErrorMessage(request, null, backoffMs, nextAttemptNumber)); + } else { + // We don't really need to log every retry attempt as the request handler might be starting up. + // Also, we might be retrying for the same exception, and therefore we can omit the cause of retry + // per retry while logging + if (nextAttemptNumber > 0 && nextAttemptNumber % 10 == 0) { + log.noStackTrace().info(t, buildErrorMessage(request, null, backoffMs, nextAttemptNumber)); + } + } connectExec.schedule( () -> tryRequest(requestBuilder, handler, retVal, nextAttemptNumber, ImmutableSet.of()), @@ -272,7 +281,14 @@ private void handleRetryableErrorResponse(final StringFullResponseHolder errorHo // Retryable server response (or null errorHolder, which means null result, which can happen // if the HttpClient encounters an exception in the midst of response processing). final long backoffMs = computeBackoffMs(retryPolicy, attemptNumber); - log.info(buildErrorMessage(request, errorHolder, backoffMs, nextAttemptNumber)); + if (log.isDebugEnabled()) { + log.debug(buildErrorMessage(request, errorHolder, backoffMs, nextAttemptNumber)); + } else { + // If we are retrying the connection, then we can omit the reason for retrying per retry + if (nextAttemptNumber > 0 && nextAttemptNumber % 10 == 0) { + log.info(buildErrorMessage(request, errorHolder, backoffMs, nextAttemptNumber)); + } + } connectExec.schedule( () -> tryRequest(requestBuilder, handler, retVal, nextAttemptNumber, ImmutableSet.of()), backoffMs,