Github user d2r commented on a diff in the pull request: https://github.com/apache/storm/pull/881#discussion_r45077073 --- Diff: storm-core/src/jvm/backtype/storm/metric/internal/LatencyStatAndMetric.java --- @@ -242,7 +248,7 @@ private synchronized void rotate(long lat, long count, long timeSpent, long targ totalCount += countBuckets[i]; timeNeeded -= bucketTime[i]; } - return ((double)totalLat)/totalCount; + return totalCount > 0 ? ((double)totalLat)/totalCount : 0.0; --- End diff -- Yes we should do this. In fact, while reading the documentation again, it seems we must guard against both values of `NaN` and `Infinity`. ``` user=> (/ 0. 0.) NaN user=> (/ 1. 0.) Infinity ``` We have only seen the NaN case recently, but it would not hurt to handle both cases, since the dividend and divisor could be 0 independently, especially since the metrics are sampled independently. I will update the code to refactor and to check both.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---