jsancio commented on code in PR #13207:
URL: https://github.com/apache/kafka/pull/13207#discussion_r1105042885


##########
raft/src/test/java/org/apache/kafka/raft/internals/KafkaRaftMetricsTest.java:
##########
@@ -232,6 +232,32 @@ public void shouldRecordPollIdleRatio() {
         raftMetrics.updatePollEnd(time.milliseconds());
 
         assertEquals(0.5, getMetric(metrics, 
"poll-idle-ratio-avg").metricValue());
+
+        // Busy for 40ms
+        time.sleep(40);
+
+        // Idle for 60ms
+        raftMetrics.updatePollStart(time.milliseconds());
+        time.sleep(60);
+        raftMetrics.updatePollEnd(time.milliseconds());
+
+        // Busy for 10ms
+        time.sleep(10);
+
+        // Begin idle time for 5ms
+        raftMetrics.updatePollStart(time.milliseconds());
+        time.sleep(5);
+
+        // Measurement arrives before poll end

Review Comment:
   How about documenting that this measurement is for busy of 40ms and idle of 
60ms?



##########
raft/src/test/java/org/apache/kafka/raft/internals/KafkaRaftMetricsTest.java:
##########
@@ -232,6 +232,32 @@ public void shouldRecordPollIdleRatio() {
         raftMetrics.updatePollEnd(time.milliseconds());
 
         assertEquals(0.5, getMetric(metrics, 
"poll-idle-ratio-avg").metricValue());
+
+        // Busy for 40ms
+        time.sleep(40);
+
+        // Idle for 60ms
+        raftMetrics.updatePollStart(time.milliseconds());
+        time.sleep(60);
+        raftMetrics.updatePollEnd(time.milliseconds());
+
+        // Busy for 10ms
+        time.sleep(10);
+
+        // Begin idle time for 5ms
+        raftMetrics.updatePollStart(time.milliseconds());
+        time.sleep(5);
+
+        // Measurement arrives before poll end
+        assertEquals(0.6, getMetric(metrics, 
"poll-idle-ratio-avg").metricValue());
+
+        // More idle time for 5ms
+        time.sleep(5);
+        raftMetrics.updatePollEnd(time.milliseconds());
+
+        // The measurement includes the interval beginning at the last 
recording.
+        // This counts 10ms of busy time and 10ms of idle time.

Review Comment:
   How about this documenting this information: busy of 10ms and Idle of 5ms + 
5ms?



-- 
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

Reply via email to