MonitorRegistryMetricPoller implements MetricPoller { public List<Metric> poll(MetricFilter filter) { return poll(filter, false); } MonitorRegistryMetricPoller();  MonitorRegistryMetricPoller(MonitorRegistry registry);  MonitorRegistryMetricPoller(MonitorRegistry registry, long cacheTTL, TimeUnit unit);  MonitorRegistryMetricPoller(MonitorRegistry registry, long cacheTTL, TimeUnit unit,
                                     boolean useLimiter);  MonitorRegistryMetricPoller(
      MonitorRegistry registry, long cacheTTL, TimeUnit unit, boolean useLimiter,
      Clock clock); List<Metric> poll(MetricFilter filter); List<Metric> poll(MetricFilter filter, boolean reset); void shutdown();  }
@Test public void testBasic() throws Exception { MonitorRegistry registry = new BasicMonitorRegistry(); registry.register(Monitors.newCounter("test")); MetricPoller poller = new MonitorRegistryMetricPoller(registry); Metric metric = poller.poll(MATCH_ALL).get(0); MonitorConfig expected = MonitorConfig.builder("test") .withTag(DataSourceType.COUNTER) .build(); assertEquals(metric.getConfig(), expected); }
@Test public void testSlowMonitor() throws Exception { MonitorRegistry registry = new BasicMonitorRegistry(); registry.register(new SlowCounter("slow")); registry.register(Monitors.newCounter("test")); MetricPoller poller = new MonitorRegistryMetricPoller(registry); long start = System.currentTimeMillis(); Metric metric = poller.poll(MATCH_ALL).get(0); long end = System.currentTimeMillis(); assertTrue(end - start < TEN_SECONDS); MonitorConfig expected = MonitorConfig.builder("test") .withTag(DataSourceType.COUNTER) .build(); assertEquals(metric.getConfig(), expected); }