zentol commented on a change in pull request #7165: [FLINK-10990][Metric]Pre-check timespan in meterview to avoid NAN URL: https://github.com/apache/flink/pull/7165#discussion_r236018806
########## File path: flink-metrics/flink-metrics-core/src/main/java/org/apache/flink/metrics/MeterView.java ########## @@ -44,12 +47,19 @@ /** The last rate we computed. */ private double currentRate = 0; + private static Logger logger = LoggerFactory.getLogger(MeterView.class); + public MeterView(int timeSpanInSeconds) { this(new SimpleCounter(), timeSpanInSeconds); } public MeterView(Counter counter, int timeSpanInSeconds) { this.counter = counter; + // timeSpanInSeconds should at least bigger than update interval + if (timeSpanInSeconds < UPDATE_INTERVAL_SECONDS) { + logger.warn("TimeSpan in meterview should not lower than update interval: {} and is set to {} by default", UPDATE_INTERVAL_SECONDS, UPDATE_INTERVAL_SECONDS); Review comment: I don't think we need this message. It's not like there are repercussions or anything. We can then simply do ``` this.timeSpanInSeconds = Math.max( timeSpanInSeconds - (timeSpanInSeconds % UPDATE_INTERVAL_SECONDS), UPDATE_INTERVAL_SECONDS); ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services