use of org.wildfly.swarm.microprofile.metrics.runtime.app.ExponentiallyDecayingReservoir in project wildfly-swarm by wildfly-swarm.
the class MetricsRegistryImpl method get.
private <T extends Metric> T get(Metadata metadata, MetricType type) {
String name = metadata.getName();
LOGGER.debugf("Get metric [name: %s, type: %s]", name, type);
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Name must not be null or empty");
}
if (!metadataMap.containsKey(name)) {
Metric m;
switch(type) {
case COUNTER:
m = new CounterImpl();
break;
case GAUGE:
throw new IllegalArgumentException("Gauge " + name + " was not registered, this should not happen");
case METERED:
m = new MeterImpl();
break;
case HISTOGRAM:
m = new HistogramImpl(new ExponentiallyDecayingReservoir());
break;
case TIMER:
m = new TimerImpl(new ExponentiallyDecayingReservoir());
break;
case INVALID:
default:
throw new IllegalStateException("Must not happen");
}
LOGGER.infof("Register metric [name: %s, type: %s]", name, type);
register(metadata, m);
} else if (!metadataMap.get(name).getTypeRaw().equals(metadata.getTypeRaw())) {
throw new IllegalArgumentException("Type of existing previously registered metric " + name + " does not " + "match passed type");
}
return (T) metricMap.get(name);
}
Aggregations