BasicDistributionSummary extends AbstractMonitor<Long> implements CompositeMonitor<Long>, SpectatorMonitor { @Override public Long getValue(int pollerIndex) { final long cnt = count.getCurrentCount(pollerIndex); final long total = totalAmount.getCurrentCount(pollerIndex); final long value = (long) ((double) total / cnt); return (cnt == 0) ? 0L : value; } BasicDistributionSummary(MonitorConfig config); @Override List<Monitor<?>> getMonitors(); void record(long amount); @Override Long getValue(int pollerIndex); Long getTotalAmount(); Long getCount(); Long getMin(); Long getMax(); @Override void initializeSpectator(TagList tags); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testGetValue() throws Exception { BasicDistributionSummary m = newInstance("foo"); assertEquals(m.getValue().longValue(), 0L); assertEquals(m.getCount().longValue(), 0L); assertEquals(m.getTotalAmount().longValue(), 0L); assertEquals(m.getMax().longValue(), 0L); assertEquals(m.getMin().longValue(), 0L); m.record(42); assertEquals(m.getValue().longValue(), 42L); assertEquals(m.getTotalAmount().longValue(), 42L); assertEquals(m.getCount().longValue(), 1L); assertEquals(m.getMax().longValue(), 42L); assertEquals(m.getMin().longValue(), 42L); m.record(21); assertEquals(m.getValue().longValue(), 31L); assertEquals(m.getTotalAmount().longValue(), 63L); assertEquals(m.getCount().longValue(), 2L); assertEquals(m.getMax().longValue(), 42L); assertEquals(m.getMin().longValue(), 21L); }