diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/annotation/Metric.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/annotation/Metric.java index 88fb070475b..516a3b8f3f3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/annotation/Metric.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/annotation/Metric.java @@ -67,4 +67,9 @@ public @interface Metric { * @return optional type (counter|gauge) of the metric */ Type type() default Type.DEFAULT; + + /** + * @return optional roll over interval in secs for MutableQuantiles + */ + int interval() default 10; } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java index 32099907fba..c415dd5a3da 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableMetricsFactory.java @@ -83,6 +83,10 @@ public class MutableMetricsFactory { return registry.newMutableRollingAverages(info.name(), annotation.valueName()); } + if (cls == MutableQuantiles.class) { + return registry.newQuantiles(info.name(), annotation.about(), + annotation.sampleName(), annotation.valueName(), annotation.interval()); + } throw new MetricsException("Unsupported metric field "+ field.getName() + " of type "+ field.getType().getName()); }