Search in sources :

Example 1 with MetricFilter

use of com.kixeye.chassis.support.metrics.MetricFilter in project chassis by Kixeye.

the class MetricFilterTest method exactMatchSingleMetric.

@Test
public void exactMatchSingleMetric() {
    MetricFilter filter = new MetricFilter("MyMetric=com.kixeye.MyMetric");
    Assert.assertTrue(filter.matches("com.kixeye.MyMetric", new Metric() {
    }));
}
Also used : MetricFilter(com.kixeye.chassis.support.metrics.MetricFilter) Metric(com.codahale.metrics.Metric) Test(org.junit.Test)

Example 2 with MetricFilter

use of com.kixeye.chassis.support.metrics.MetricFilter in project chassis by Kixeye.

the class MetricFilterTest method multiplePatternMatches.

@Test
public void multiplePatternMatches() {
    MetricFilter filter = new MetricFilter("MyMetric1=com.kixeye.MyMetric[0-9]:5m,MyMetric2=com.[a-zA-Z0-9]*.MyMetric[0-9]:15m");
    Assert.assertTrue(filter.matches("com.kixeye.MyMetric1", new Metric() {
    }));
    Assert.assertTrue(filter.matches("com.foo.MyMetric1", new Metric() {
    }));
    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.RATE_5_MINUTE));
    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.RATE_15_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.foo.MyMetric1", Stat.RATE_5_MINUTE));
    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.foo.MyMetric1", Stat.RATE_15_MINUTE));
}
Also used : MetricFilter(com.kixeye.chassis.support.metrics.MetricFilter) Metric(com.codahale.metrics.Metric) Test(org.junit.Test)

Example 3 with MetricFilter

use of com.kixeye.chassis.support.metrics.MetricFilter in project chassis by Kixeye.

the class MetricFilterTest method exactMatchMultipleMetricsWithStatsFilter.

@Test
public void exactMatchMultipleMetricsWithStatsFilter() {
    MetricFilter filter = new MetricFilter("MyMetric1=com.kixeye.MyMetric1:5m,MyMetric2=com.kixeye.MyMetric2:5m");
    Assert.assertTrue(filter.matches("com.kixeye.MyMetric1", new Metric() {
    }));
    Assert.assertTrue(filter.matches("com.kixeye.MyMetric2", new Metric() {
    }));
    Assert.assertFalse(filter.matches("com.kixeye.MyMetric3", new Metric() {
    }));
    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.RATE_5_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.RATE_15_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric1", Stat.ALL));
    Assert.assertNotNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric2", Stat.RATE_5_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric2", Stat.RATE_15_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric2", Stat.ALL));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric3", Stat.RATE_5_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric3", Stat.RATE_15_MINUTE));
    Assert.assertNull(filter.getMatchingMetricDescriptor("com.kixeye.MyMetric3", Stat.ALL));
}
Also used : MetricFilter(com.kixeye.chassis.support.metrics.MetricFilter) Metric(com.codahale.metrics.Metric) Test(org.junit.Test)

Example 4 with MetricFilter

use of com.kixeye.chassis.support.metrics.MetricFilter in project chassis by Kixeye.

the class MetricFilterTest method matchesEmpty.

@Test
public void matchesEmpty() {
    MetricFilter filter = new MetricFilter("");
    Assert.assertTrue(filter.matches("mymetric", new Metric() {
    }));
}
Also used : MetricFilter(com.kixeye.chassis.support.metrics.MetricFilter) Metric(com.codahale.metrics.Metric) Test(org.junit.Test)

Example 5 with MetricFilter

use of com.kixeye.chassis.support.metrics.MetricFilter in project chassis by Kixeye.

the class MetricsGraphiteReporterLoader method createReporter.

private void createReporter(String metricFilter, String environment, String serviceName, String version, MetricRegistry metricRegistry) {
    // optionally filter metrics to send to graphite server
    MetricFilter filter = MetricFilter.FILTER_NONE;
    if (!(Strings.isNullOrEmpty(metricFilter) || "*".equals(metricFilter))) {
        filter = new MetricFilter(metricFilter);
    }
    this.filter = filter;
    this.graphiteReporter = GraphiteReporter.forRegistry(metricRegistry).prefixedWith(getPreFix(environment, serviceName, version)).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(filter).build(graphite);
}
Also used : MetricFilter(com.kixeye.chassis.support.metrics.MetricFilter)

Aggregations

MetricFilter (com.kixeye.chassis.support.metrics.MetricFilter)11 Test (org.junit.Test)10 Metric (com.codahale.metrics.Metric)8