ijuma commented on code in PR #15402: URL: https://github.com/apache/kafka/pull/15402#discussion_r1518649290
########## clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java: ########## @@ -336,33 +337,35 @@ public long timeToNextUpdate(long requestTimeoutMs) { */ apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name; timeMs = requestTimeoutMs; - msg = String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG); + msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG); break; case TERMINATING_PUSH_IN_PROGRESS: timeMs = Long.MAX_VALUE; - msg = String.format("the terminating push is in progress, disabling telemetry for further requests"); + msg = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests"; break; case TERMINATING_PUSH_NEEDED: timeMs = 0; - msg = String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name); + msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name); break; case SUBSCRIPTION_NEEDED: case PUSH_NEEDED: apiName = (localState == ClientTelemetryState.SUBSCRIPTION_NEEDED) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name; long timeRemainingBeforeRequest = localLastRequestMs + localIntervalMs - nowMs; if (timeRemainingBeforeRequest <= 0) { timeMs = 0; - msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName); + msg = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName); } else { timeMs = timeRemainingBeforeRequest; - msg = String.format("the client will wait before submitting the next %s network API request", apiName); + msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName); } break; default: throw new IllegalStateException("Unknown telemetry state: " + localState); } - log.trace("For telemetry state {}, returning the value {} ms; {}", localState, timeMs, msg); Review Comment: Hmm, unlike what the PR says, there is no string generated if the log is disabled. The only allocation is the array for passing the parameters. No harm in this change, but I wanted to clarify. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org