DynamicTimer extends AbstractMonitor<Long> implements CompositeMonitor<Long>, SpectatorMonitor { @Override public Long getValue(int pollerIdx) { return (long) timers.size(); } private  DynamicTimer(); @Override void initializeSpectator(TagList tags); static Stopwatch start(MonitorConfig config, TimeUnit unit); static Stopwatch start(MonitorConfig config); static void record(MonitorConfig config, long duration); static void record(MonitorConfig config, long duration, TimeUnit unit); static void record(MonitorConfig config, TimeUnit reportUnit, long duration,
                            TimeUnit durationUnit); static Stopwatch start(String name, String... tags); static Stopwatch start(String name, TagList list); static Stopwatch start(String name, TagList list, TimeUnit unit); @Override @SuppressWarnings("unchecked") List<Monitor<?>> getMonitors(); @Override Long getValue(int pollerIdx); @Override String toString();  }
@Test public void testGetValue() throws Exception { Stopwatch s = DynamicTimer.start("test1", tagList); Timer c = getByName("test1"); s.stop(); assert c != null; assertEquals(c.getValue().longValue(), s.getDuration(TimeUnit.MILLISECONDS)); c.record(13, TimeUnit.MILLISECONDS); long expected = (13 + s.getDuration(TimeUnit.MILLISECONDS)) / 2; assertEquals(c.getValue().longValue(), expected); }