Search in sources :

Example 1 with MetricFilter

use of io.dropwizard.metrics5.MetricFilter in project instrumentation-java by census-instrumentation.

the class DropWizardMetricsTest method filter_GetMetrics.

@Test
public void filter_GetMetrics() {
    MetricFilter filter = new MetricFilter() {

        @Override
        public boolean matches(MetricName name, io.dropwizard.metrics5.Metric metric) {
            return name.getKey().startsWith("test");
        }
    };
    dropWizardMetrics = new DropWizardMetrics(Collections.singletonList(metricRegistry), filter);
    metricRegistry.timer("test_requests");
    metricRegistry.timer("requests");
    Collection<Metric> metrics = dropWizardMetrics.getMetrics();
    assertThat(metrics).hasSize(1);
    Metric value = metrics.iterator().next();
    assertThat(value.getMetricDescriptor().getName()).isEqualTo("dropwizard5_test_requests_timer");
}
Also used : MetricName(io.dropwizard.metrics5.MetricName) MetricFilter(io.dropwizard.metrics5.MetricFilter) Metric(io.opencensus.metrics.export.Metric) Test(org.junit.Test)

Aggregations

MetricFilter (io.dropwizard.metrics5.MetricFilter)1 MetricName (io.dropwizard.metrics5.MetricName)1 Metric (io.opencensus.metrics.export.Metric)1 Test (org.junit.Test)1