@Test public void callsSupplierAgainAfterTimeElapses() { when(mockClock.getTick()).thenReturn(0L, CACHE_INTERVAL_NANOS - 1, CACHE_INTERVAL_NANOS + 1); AtomicLong timestampValue = new AtomicLong(0L); TimestampTracker.registerTimestampForTracking( mockClock, metricsManager, FAKE_METRIC, timestampValue::incrementAndGet); assertThat(getGauge(FAKE_METRIC).getValue()).isEqualTo(1L); assertThat(getGauge(FAKE_METRIC).getValue()).isEqualTo(1L); assertThat(getGauge(FAKE_METRIC).getValue()).isEqualTo(2L); }
@VisibleForTesting static void registerTimestampForTracking( Clock clock, MetricsManager metricsManager, String shortName, Supplier<Long> supplier) { metricsManager.registerMetric( TimestampTracker.class, shortName, TrackerUtils.createCachingMonotonicIncreasingGauge(log, clock, shortName, supplier)); }
TimestampTracker { @VisibleForTesting static void registerTimestampForTracking( Clock clock, MetricsManager metricsManager, String shortName, Supplier<Long> supplier) { metricsManager.registerMetric( TimestampTracker.class, shortName, TrackerUtils.createCachingMonotonicIncreasingGauge(log, clock, shortName, supplier)); } }
TimestampTracker { @VisibleForTesting static void registerTimestampForTracking( Clock clock, MetricsManager metricsManager, String shortName, Supplier<Long> supplier) { metricsManager.registerMetric( TimestampTracker.class, shortName, TrackerUtils.createCachingMonotonicIncreasingGauge(log, clock, shortName, supplier)); } private  TimestampTracker(); }
TimestampTracker { @VisibleForTesting static void registerTimestampForTracking( Clock clock, MetricsManager metricsManager, String shortName, Supplier<Long> supplier) { metricsManager.registerMetric( TimestampTracker.class, shortName, TrackerUtils.createCachingMonotonicIncreasingGauge(log, clock, shortName, supplier)); } private  TimestampTracker(); static void instrumentTimestamps(
            MetricsManager metricsManager, TimelockService timeLockService, Cleaner cleaner); }
TimestampTracker { @VisibleForTesting static void registerTimestampForTracking( Clock clock, MetricsManager metricsManager, String shortName, Supplier<Long> supplier) { metricsManager.registerMetric( TimestampTracker.class, shortName, TrackerUtils.createCachingMonotonicIncreasingGauge(log, clock, shortName, supplier)); } private  TimestampTracker(); static void instrumentTimestamps(
            MetricsManager metricsManager, TimelockService timeLockService, Cleaner cleaner);  }