use of com.google.gerrit.metrics.Description in project gerrit by GerritCodeReview.
the class ProcMetricModule method procJvmGc.
private void procJvmGc(MetricMaker metrics) {
CallbackMetric1<String, Long> gcCount = metrics.newCallbackMetric("proc/jvm/gc/count", Long.class, new Description("Number of GCs").setCumulative(), Field.ofString("gc_name", "The name of the garbage collector"));
CallbackMetric1<String, Long> gcTime = metrics.newCallbackMetric("proc/jvm/gc/time", Long.class, new Description("Approximate accumulated GC elapsed time").setCumulative().setUnit(Units.MILLISECONDS), Field.ofString("gc_name", "The name of the garbage collector"));
metrics.newTrigger(gcCount, gcTime, () -> {
for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
long count = gc.getCollectionCount();
if (count != -1) {
gcCount.set(gc.getName(), count);
}
long time = gc.getCollectionTime();
if (time != -1) {
gcTime.set(gc.getName(), time);
}
}
});
}
Aggregations