/** * Adds JVM MetricSets to this engine. By default JVM metrics are not placed in the Registry */ public CodahaleMetricsEngine reportJvmMetrics() { // add JVM metrics if (!jvmMetricsAdded) { metricsCollector.registerAll("JVM-gc", new GarbageCollectorMetricSet()); metricsCollector .registerAll("JVM-buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); metricsCollector.registerAll("JVM-memory", new MemoryUsageGaugeSet()); metricsCollector.registerAll("JVM-threads", new ThreadStatesGaugeSet()); jvmMetricsAdded = true; } return this; }
public CodahaleMetricsCollector registerAll(String prefix, MetricSet metricSet) { for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) { if (entry.getValue() instanceof MetricSet) { registerAll(prefix + "." + entry.getKey(), (MetricSet) entry.getValue()); } else { registerNamedMetric(prefix + "." + entry.getKey(), entry.getValue()); } } return this; }