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

This commit is contained in:
Vrushali C 2018-09-05 20:53:21 -07:00
parent 8286bf2d1f
commit 962089ab59
2 changed files with 9 additions and 0 deletions

View File

@ -68,4 +68,9 @@ public enum Type {
* @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 @@ MutableMetric newForField(Field field, Metric annotation,
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());
}