summaryrefslogtreecommitdiffstats
path: root/simplemetrics/src/main/java/com/yahoo/metrics/simple
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2019-05-16 09:10:18 +0000
committerArne Juul <arnej@yahoo-inc.com>2019-05-16 09:20:36 +0000
commit9688d52721ac2e9244ef9c1ac8a5cf8fb99e45b2 (patch)
tree6a00e2144b33b68a17dc246dc36b44ae3db3567f /simplemetrics/src/main/java/com/yahoo/metrics/simple
parent8c88782c16e527ab79a6b39857a96db96f209211 (diff)
fix merge bug
* avoid using empty metric's value as input to max() and min()
Diffstat (limited to 'simplemetrics/src/main/java/com/yahoo/metrics/simple')
-rw-r--r--simplemetrics/src/main/java/com/yahoo/metrics/simple/UntypedMetric.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/simplemetrics/src/main/java/com/yahoo/metrics/simple/UntypedMetric.java b/simplemetrics/src/main/java/com/yahoo/metrics/simple/UntypedMetric.java
index 3a9f71b932c..f6762434275 100644
--- a/simplemetrics/src/main/java/com/yahoo/metrics/simple/UntypedMetric.java
+++ b/simplemetrics/src/main/java/com/yahoo/metrics/simple/UntypedMetric.java
@@ -74,12 +74,20 @@ public class UntypedMetric {
if (outputFormat != other.outputFormat) {
throw new IllegalArgumentException("Mismatching output formats: " + outputFormat + " and " + other.outputFormat + ".");
}
- count += other.count;
- if (otherIsNewer) {
+ if (count > 0) {
+ if (other.count > 0) {
+ max = Math.max(other.max, max);
+ min = Math.min(other.min, min);
+ if (otherIsNewer) {
+ current = other.current;
+ }
+ }
+ } else {
+ max = other.max;
+ min = other.min;
current = other.current;
}
- max = Math.max(other.max, max);
- min = Math.min(other.min, min);
+ count += other.count;
sum += other.sum;
if (histogram != null) {
// some config scenarios may lead to differing histogram settings,