HADOOP-15657 Registering MutableQuantiles via Metric annotation. Contributed by Sushil Ks

This commit is contained in:
Vrushali C 2018-09-05 21:09:16 -07:00
parent 0468b6e736
commit f6e4b13d5f
2 changed files with 9 additions and 0 deletions

View File

@ -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;
}

View File

@ -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());
}