Search in sources :

Example 6 with MetricFilter

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

the class MetricFilterTest method patternMatchMultipleMetricsWithStatsFilter.

@Test
public void patternMatchMultipleMetricsWithStatsFilter() {
    MetricFilter filter = new MetricFilter("MyMetric1=com.[a-zA-Z0-9]*.MyMetric1:5m,MyMetric2=com.[a-zA-Z0-9]*.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 7 with MetricFilter

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

the class MetricFilterTest method matchesAsterix.

@Test
public void matchesAsterix() {
    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 8 with MetricFilter

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

the class MetricFilterTest method patternMatchSingleMetric.

@Test
public void patternMatchSingleMetric() {
    MetricFilter filter = new MetricFilter("MyMetric=com.[a-zA-Z0-9]*.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 9 with MetricFilter

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

the class MetricFilterTest method exactMatchMultipleMetrics.

@Test
public void exactMatchMultipleMetrics() {
    MetricFilter filter = new MetricFilter("MyMetric1=com.kixeye.MyMetric1,MyMetric2=com.kixeye.MyMetric2");
    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() {
    }));
}
Also used : MetricFilter(com.kixeye.chassis.support.metrics.MetricFilter) Metric(com.codahale.metrics.Metric) Test(org.junit.Test)

Example 10 with MetricFilter

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

the class MetricsCloudWatchConfigurationTest method testUpdateFilter.

@Test
public void testUpdateFilter() {
    MetricFilter filter = metricsCloudWatchConfiguration.getReporter().getFilter();
    Assert.assertEquals("foo=bar", filter.getStringValue());
    ConfigurationManager.getConfigInstance().setProperty(removePlaceholder(MetricsCloudWatchReporter.METRICS_AWS_FILTER_PROPERTY_NAME), "foo=baz");
    Assert.assertNotEquals(filter, metricsCloudWatchConfiguration.getReporter().getFilter());
    Assert.assertEquals("foo=baz", metricsCloudWatchConfiguration.getReporter().getFilter().getStringValue());
}
Also used : MetricFilter(com.kixeye.chassis.support.metrics.MetricFilter) Test(org.junit.Test)

Aggregations

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