Exemplo n.º 1
0
  @Test
  public void testPrefixFilterOnName() throws Exception {
    TreeMap<String, MetricFilter> filters = Maps.newTreeMap();
    filters.put("m", MATCH_ALL);
    MetricFilter filter = new PrefixMetricFilter(null, MATCH_NONE, filters);
    MetricPoller poller = newPoller();

    List<Metric> metrics = poller.poll(filter);
    assertEquals(metrics.size(), 5);
  }
  @Test
  public void testBasic() throws Exception {
    Map<String, MetricPoller> pollers = Maps.newHashMap();
    pollers.put("p1", newPoller(0));

    ExecutorService exec = Executors.newFixedThreadPool(1);
    MetricPoller poller = new CompositeMetricPoller(pollers, exec, 10000);

    assertEquals(poller.poll(MATCH_ALL), mkList());
  }
  @Test
  public void testMultiple() throws Exception {
    Map<String, MetricPoller> pollers = Maps.newHashMap();
    pollers.put("p1", newPoller(0));
    pollers.put("p2", newPoller(0));

    ExecutorService exec = Executors.newFixedThreadPool(1);
    MetricPoller poller = new CompositeMetricPoller(pollers, exec, 10000);

    assertEquals(
        poller.poll(MATCH_ALL), ImmutableList.copyOf(Iterables.concat(mkList(), mkList())));
  }
  @Test
  public void testBasic() throws Exception {
    MonitorRegistry registry = new BasicMonitorRegistry();
    registry.registerObject(new BasicCounter("foo"));

    MetricPoller poller = new MonitorRegistryMetricPoller(registry);
    Metric metric = poller.poll(MATCH_ALL).get(0);
    TagList tags =
        BasicTagList.copyOf(
            new BasicTag("MonitorId", "foo"),
            new BasicTag("ClassName", "com.netflix.servo.util.BasicCounter"),
            DataSourceType.COUNTER);
    assertEquals(metric.getConfig(), new MetricConfig("Count", tags));
  }