PoolMetrics implements Metrics { @Override public void collect(Stats stats) { stats.put(statName("total_count"), pool.totalCount()); stats.put(statName("active_count"), pool.activeCount()); } PoolMetrics(Pool<?> pool); @Override void collect(Stats stats);  }
@Test void collect() { pool.borrowItem(); pool.returnItem(pool.borrowItem()); var stats = new Stats(); metrics.collect(stats); assertThat(stats.stats) .containsEntry("pool_test_active_count", 1.0d) .containsEntry("pool_test_total_count", 2.0d); }