/** * Returns true if this metric is idle and should be skipped. * * @param name * @param counting * @return true if the metric should be skipped */ protected boolean canSkipMetric(String name, Counting counting) { boolean isIdle = calculateDelta(name, counting.getCount()) == 0L; if (skipIdleMetrics && !isIdle) { previousValues.put(name, counting.getCount()); } return skipIdleMetrics && isIdle; }
@Test public void shouldUpdateMonitorValueWhenUpdateMonitorsIsCalled() { final long newValue = INITIAL_VALUE + 5; when(counter.getCount()).thenReturn(newValue); CountingAdapter countingAdapter = metricAdapter; countingAdapter.updateMonitorables(); assertThat(getFirstMonitorable(countingAdapter).get(), Matchers.<Object>is(newValue)); }
@Before public void setUp() { when(counter.getCount()).thenReturn(INITIAL_VALUE); metricAdapter = new CountingAdapter(counter, NAME, DESCRIPTION, ValueSemantics.FREE_RUNNING); }