in geronimo-microprofile-reporter/src/main/java/org/apache/geronimo/microprofile/reporter/storage/plugins/metrics/MetricsService.java [56:99]
private void updateMetrics(final String type, final MetricRegistry registry) {
registry.getCounters().forEach((name, counter) -> {
final String virtualName = getMetricStorageName(type, name);
final long count = counter.getCount();
getDb(database.getCounters(), virtualName, registry, name).add(count);
});
registry.getGauges().forEach((name, gauge) -> {
final String virtualName = getMetricStorageName(type, name);
final Object value = gauge.getValue();
if (Number.class.isInstance(value)) {
try {
getDb(database.getGauges(), virtualName, registry, name).add(Number.class.cast(value).doubleValue());
} catch (final NullPointerException | NumberFormatException nfe) {
// ignore, we can't do much if the value is not a double
}
} // else ignore, will not be able to do anything of it anyway
});
registry.getHistograms().forEach((name, histogram) -> {
final String virtualName = getMetricStorageName(type, name);
final Snapshot snapshot = histogram.getSnapshot();
getDb(database.getHistograms(), virtualName, registry, name)
.add(new SnapshotStat(snapshot.size(), snapshot.getMedian(), snapshot.getMean(), snapshot.getMin(), snapshot.getMax(), snapshot.getStdDev(),
snapshot.get75thPercentile(), snapshot.get95thPercentile(), snapshot.get98thPercentile(), snapshot.get99thPercentile(), snapshot.get999thPercentile()));
});
registry.getMeters().forEach((name, meter) -> {
final String virtualName = getMetricStorageName(type, name);
final MeterSnapshot snapshot = new MeterSnapshot(
meter.getCount(), meter.getMeanRate(), meter.getOneMinuteRate(), meter.getFiveMinuteRate(), meter.getFifteenMinuteRate());
getDb(database.getMeters(), virtualName, registry, name).add(snapshot);
});
registry.getTimers().forEach((name, timer) -> {
final String virtualName = getMetricStorageName(type, name);
final Snapshot snapshot = timer.getSnapshot();
final TimerSnapshot timerSnapshot = new TimerSnapshot(new MeterSnapshot(
timer.getCount(), timer.getMeanRate(), timer.getOneMinuteRate(), timer.getFiveMinuteRate(), timer.getFifteenMinuteRate()),
new SnapshotStat(snapshot.size(), snapshot.getMedian(), snapshot.getMean(), snapshot.getMin(), snapshot.getMax(), snapshot.getStdDev(),
snapshot.get75thPercentile(), snapshot.get95thPercentile(), snapshot.get98thPercentile(), snapshot.get99thPercentile(), snapshot.get999thPercentile()));
getDb(database.getTimers(), virtualName, registry, name).add(timerSnapshot);
});
}