StatCollector { public Stats collect() { var stats = new Stats(); collectCPUUsage(stats); stats.put("thread_count", thread.getThreadCount()); collectMemoryUsage(stats); for (GCStat gcStat : gcStats) { long count = gcStat.count(); long elapsed = gcStat.elapsed(); stats.put("jvm_gc_" + gcStat.name + "_count", (double) count); stats.put("jvm_gc_" + gcStat.name + "_elapsed", (double) elapsed); } collectMetrics(stats); return stats; } StatCollector(); Stats collect(); final List<Metrics> metrics; public double highCPUUsageThreshold; public double highHeapUsageThreshold; }
@Test void collect() { Stats stats = collector.collect(); assertThat(stats.stats).containsKeys("cpu_usage", "thread_count", "jvm_heap_used", "jvm_heap_max", "jvm_non_heap_used"); }