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");
}
Aggregations