divijvaidya commented on code in PR #12045: URL: https://github.com/apache/kafka/pull/12045#discussion_r897724922
########## clients/src/main/java/org/apache/kafka/common/metrics/stats/Rate.java: ########## @@ -68,24 +68,55 @@ public double measure(MetricConfig config, long now) { } public long windowSize(MetricConfig config, long now) { - // purge old samples before we compute the window size + // Purge obsolete samples. Obsolete samples are the ones which are not relevant to the current calculation + // because their creation time is outside (before) the duration of time window used to calculate rate. stat.purgeObsoleteSamples(config, now); /* * Here we check the total amount of time elapsed since the oldest non-obsolete window. - * This give the total windowSize of the batch which is the time used for Rate computation. - * However, there is an issue if we do not have sufficient data for e.g. if only 1 second has elapsed in a 30 second - * window, the measured rate will be very high. - * Hence we assume that the elapsed time is always N-1 complete windows plus whatever fraction of the final window is complete. + * This gives the duration of computation time window which used to calculate Rate. Review Comment: Thanks for catching this. I have fixed this in the latest revision. -- 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