Skip to content

Commit

Permalink
better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
LakshSingla committed Oct 27, 2023
1 parent 7c8e841 commit 474a51e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions server/src/main/java/org/apache/druid/rpc/ServiceClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 474a51e

Please sign in to comment.