You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "clarkwtc (via GitHub)" <gi...@apache.org> on 2024/10/22 02:24:04 UTC

[PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

clarkwtc opened a new pull request, #17570:
URL: https://github.com/apache/kafka/pull/17570

   Reverse the condition to show log trace-level message
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "clarkwtc (via GitHub)" <gi...@apache.org>.
clarkwtc commented on code in PR #17570:
URL: https://github.com/apache/kafka/pull/17570#discussion_r1815245609


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java:
##########
@@ -337,35 +336,33 @@ public long timeToNextUpdate(long requestTimeoutMs) {
                     */
                     apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name;
                     timeMs = requestTimeoutMs;
-                    msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG);
+                    msg = 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 = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests";
+                    msg = "the terminating push is in progress, disabling telemetry for further requests";
                     break;
                 case TERMINATING_PUSH_NEEDED:
                     timeMs = 0;
-                    msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name);
+                    msg = 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 = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
+                        msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
                     } else {
                         timeMs = timeRemainingBeforeRequest;
-                        msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName);
+                        msg = String.format("the client will wait before submitting the next %s network API request", apiName);

Review Comment:
   Looks better.
   Thank you for this suggestion.
   I'm done.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "clarkwtc (via GitHub)" <gi...@apache.org>.
clarkwtc commented on code in PR #17570:
URL: https://github.com/apache/kafka/pull/17570#discussion_r1811037824


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java:
##########
@@ -337,33 +336,33 @@ public long timeToNextUpdate(long requestTimeoutMs) {
                     */
                     apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name;
                     timeMs = requestTimeoutMs;
-                    msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG);
+                    msg = 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 = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests";
+                    msg = "the terminating push is in progress, disabling telemetry for further requests";
                     break;
                 case TERMINATING_PUSH_NEEDED:
                     timeMs = 0;
-                    msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name);
+                    msg = 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 = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
+                        msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
                     } else {
                         timeMs = timeRemainingBeforeRequest;
-                        msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName);
+                        msg = String.format("the client will wait before submitting the next %s network API request", apiName);
                     }
                     break;
                 default:
                     throw new IllegalStateException("Unknown telemetry state: " + localState);
             }
 
-            if (isTraceEnabled) {
+            if (log.isTraceEnabled()) {

Review Comment:
   Remove this check? 
   Always trace the current state of the client telemetry.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #17570:
URL: https://github.com/apache/kafka/pull/17570#discussion_r1811150109


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java:
##########
@@ -337,33 +336,33 @@ public long timeToNextUpdate(long requestTimeoutMs) {
                     */
                     apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name;
                     timeMs = requestTimeoutMs;
-                    msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG);
+                    msg = 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 = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests";
+                    msg = "the terminating push is in progress, disabling telemetry for further requests";
                     break;
                 case TERMINATING_PUSH_NEEDED:
                     timeMs = 0;
-                    msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name);
+                    msg = 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 = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
+                        msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
                     } else {
                         timeMs = timeRemainingBeforeRequest;
-                        msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName);
+                        msg = String.format("the client will wait before submitting the next %s network API request", apiName);
                     }
                     break;
                 default:
                     throw new IllegalStateException("Unknown telemetry state: " + localState);
             }
 
-            if (isTraceEnabled) {
+            if (log.isTraceEnabled()) {

Review Comment:
   +1 to remove the check, as the trace-level log is cheaper due to the use of placeholders.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "clarkwtc (via GitHub)" <gi...@apache.org>.
clarkwtc commented on code in PR #17570:
URL: https://github.com/apache/kafka/pull/17570#discussion_r1811669532


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java:
##########
@@ -337,33 +336,33 @@ public long timeToNextUpdate(long requestTimeoutMs) {
                     */
                     apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name;
                     timeMs = requestTimeoutMs;
-                    msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG);
+                    msg = 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 = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests";
+                    msg = "the terminating push is in progress, disabling telemetry for further requests";
                     break;
                 case TERMINATING_PUSH_NEEDED:
                     timeMs = 0;
-                    msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name);
+                    msg = 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 = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
+                        msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
                     } else {
                         timeMs = timeRemainingBeforeRequest;
-                        msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName);
+                        msg = String.format("the client will wait before submitting the next %s network API request", apiName);
                     }
                     break;
                 default:
                     throw new IllegalStateException("Unknown telemetry state: " + localState);
             }
 
-            if (isTraceEnabled) {
+            if (log.isTraceEnabled()) {

Review Comment:
   @apoorvmittal10 You're right
   Thank you both for the kind suggestions, I have removed the check.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "apoorvmittal10 (via GitHub)" <gi...@apache.org>.
apoorvmittal10 commented on code in PR #17570:
URL: https://github.com/apache/kafka/pull/17570#discussion_r1813315518


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java:
##########
@@ -337,35 +336,33 @@ public long timeToNextUpdate(long requestTimeoutMs) {
                     */
                     apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name;
                     timeMs = requestTimeoutMs;
-                    msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG);
+                    msg = 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 = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests";
+                    msg = "the terminating push is in progress, disabling telemetry for further requests";
                     break;
                 case TERMINATING_PUSH_NEEDED:
                     timeMs = 0;
-                    msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name);
+                    msg = 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 = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
+                        msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
                     } else {
                         timeMs = timeRemainingBeforeRequest;
-                        msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName);
+                        msg = String.format("the client will wait before submitting the next %s network API request", apiName);

Review Comment:
   Yeah that ll be better else the Strings are created for msg.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #17570:
URL: https://github.com/apache/kafka/pull/17570


-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "clarkwtc (via GitHub)" <gi...@apache.org>.
clarkwtc commented on code in PR #17570:
URL: https://github.com/apache/kafka/pull/17570#discussion_r1815245609


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java:
##########
@@ -337,35 +336,33 @@ public long timeToNextUpdate(long requestTimeoutMs) {
                     */
                     apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name;
                     timeMs = requestTimeoutMs;
-                    msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG);
+                    msg = 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 = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests";
+                    msg = "the terminating push is in progress, disabling telemetry for further requests";
                     break;
                 case TERMINATING_PUSH_NEEDED:
                     timeMs = 0;
-                    msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name);
+                    msg = 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 = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
+                        msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
                     } else {
                         timeMs = timeRemainingBeforeRequest;
-                        msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName);
+                        msg = String.format("the client will wait before submitting the next %s network API request", apiName);

Review Comment:
   Looks better.
   Thank you for this suggestion.
   done.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "apoorvmittal10 (via GitHub)" <gi...@apache.org>.
apoorvmittal10 commented on code in PR #17570:
URL: https://github.com/apache/kafka/pull/17570#discussion_r1810607950


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java:
##########
@@ -337,33 +336,33 @@ public long timeToNextUpdate(long requestTimeoutMs) {
                     */
                     apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name;
                     timeMs = requestTimeoutMs;
-                    msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG);
+                    msg = 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 = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests";
+                    msg = "the terminating push is in progress, disabling telemetry for further requests";
                     break;
                 case TERMINATING_PUSH_NEEDED:
                     timeMs = 0;
-                    msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name);
+                    msg = 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 = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
+                        msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
                     } else {
                         timeMs = timeRemainingBeforeRequest;
-                        msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName);
+                        msg = String.format("the client will wait before submitting the next %s network API request", apiName);
                     }
                     break;
                 default:
                     throw new IllegalStateException("Unknown telemetry state: " + localState);
             }
 
-            if (isTraceEnabled) {
+            if (log.isTraceEnabled()) {

Review Comment:
   Do you think this check is also not adding any value?



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "apoorvmittal10 (via GitHub)" <gi...@apache.org>.
apoorvmittal10 commented on code in PR #17570:
URL: https://github.com/apache/kafka/pull/17570#discussion_r1811145523


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java:
##########
@@ -337,33 +336,33 @@ public long timeToNextUpdate(long requestTimeoutMs) {
                     */
                     apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name;
                     timeMs = requestTimeoutMs;
-                    msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG);
+                    msg = 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 = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests";
+                    msg = "the terminating push is in progress, disabling telemetry for further requests";
                     break;
                 case TERMINATING_PUSH_NEEDED:
                     timeMs = 0;
-                    msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name);
+                    msg = 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 = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
+                        msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
                     } else {
                         timeMs = timeRemainingBeforeRequest;
-                        msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName);
+                        msg = String.format("the client will wait before submitting the next %s network API request", apiName);
                     }
                     break;
                 default:
                     throw new IllegalStateException("Unknown telemetry state: " + localState);
             }
 
-            if (isTraceEnabled) {
+            if (log.isTraceEnabled()) {

Review Comment:
   So basically `log.trace` will anyways not log if trace is not enabled.
   The check `log.isTraceEnabled()` generally saves us creating extra strings with object defined as params but here we are using `format parameters` for log hence the extra strings will not be created. This check is not adding any value hence we can remove it.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #17570:
URL: https://github.com/apache/kafka/pull/17570#discussion_r1813301878


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/ClientTelemetryReporter.java:
##########
@@ -337,35 +336,33 @@ public long timeToNextUpdate(long requestTimeoutMs) {
                     */
                     apiName = (localState == ClientTelemetryState.SUBSCRIPTION_IN_PROGRESS) ? ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS.name : ApiKeys.PUSH_TELEMETRY.name;
                     timeMs = requestTimeoutMs;
-                    msg = isTraceEnabled ? "" : String.format("the remaining wait time for the %s network API request, as specified by %s", apiName, CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG);
+                    msg = 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 = isTraceEnabled ? "" : "the terminating push is in progress, disabling telemetry for further requests";
+                    msg = "the terminating push is in progress, disabling telemetry for further requests";
                     break;
                 case TERMINATING_PUSH_NEEDED:
                     timeMs = 0;
-                    msg = isTraceEnabled ? "" : String.format("the client should try to submit the final %s network API request ASAP before closing", ApiKeys.PUSH_TELEMETRY.name);
+                    msg = 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 = isTraceEnabled ? "" : String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
+                        msg = String.format("the wait time before submitting the next %s network API request has elapsed", apiName);
                     } else {
                         timeMs = timeRemainingBeforeRequest;
-                        msg = isTraceEnabled ? "" : String.format("the client will wait before submitting the next %s network API request", apiName);
+                        msg = String.format("the client will wait before submitting the next %s network API request", apiName);

Review Comment:
   I assumed the new style is to call `log.trace` directly :smile:  for example:
   ```java
   log.trace("For telemetry state {}, returning the value {} ms; the client will wait before submitting the next {} network API request", localState, timeMs, apiName);
   ```



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-17846: ClientTelemetryReporter does not log trace-level message [kafka]

Posted by "clarkwtc (via GitHub)" <gi...@apache.org>.
clarkwtc commented on PR #17570:
URL: https://github.com/apache/kafka/pull/17570#issuecomment-2428277324

   @chia7712 @apoorvmittal10 
   Could you review the PR, please?
   Your feedback would be good to me.
   


-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org