use of io.micrometer.core.instrument.config.MeterFilter in project spring-boot by spring-projects.
the class MetricsAutoConfigurationTests method configuresMeterRegistries.
@SuppressWarnings("unchecked")
@Test
void configuresMeterRegistries() {
this.contextRunner.withUserConfiguration(MeterRegistryConfiguration.class).run((context) -> {
MeterRegistry meterRegistry = context.getBean(MeterRegistry.class);
MeterFilter[] filters = (MeterFilter[]) ReflectionTestUtils.getField(meterRegistry, "filters");
assertThat(filters).hasSize(3);
assertThat(filters[0].accept((Meter.Id) null)).isEqualTo(MeterFilterReply.DENY);
assertThat(filters[1]).isInstanceOf(PropertiesMeterFilter.class);
assertThat(filters[2].accept((Meter.Id) null)).isEqualTo(MeterFilterReply.ACCEPT);
then((MeterBinder) context.getBean("meterBinder")).should().bindTo(meterRegistry);
then(context.getBean(MeterRegistryCustomizer.class)).should().customize(meterRegistry);
});
}
use of io.micrometer.core.instrument.config.MeterFilter in project spring-boot by spring-projects.
the class WebFluxMetricsAutoConfiguration method metricsHttpServerUriTagFilter.
@Bean
@Order(0)
public MeterFilter metricsHttpServerUriTagFilter() {
String metricName = this.properties.getWeb().getServer().getRequest().getMetricName();
MeterFilter filter = new OnlyOnceLoggingDenyMeterFilter(() -> String.format("Reached the maximum number of URI tags for '%s'.", metricName));
return MeterFilter.maximumAllowableTags(metricName, "uri", this.properties.getWeb().getServer().getMaxUriTags(), filter);
}
use of io.micrometer.core.instrument.config.MeterFilter in project micrometer by micrometer-metrics.
the class MeterFilterTest method renameTags.
@Test
@Issue("#329")
void renameTags() {
MeterFilter filter = MeterFilter.renameTag("hystrix", "group", "hystrixgroup");
Meter.Id id = new Meter.Id("hystrix.something", Tags.of("k", "v", "group", "mygroup"), null, null, Meter.Type.GAUGE);
assertThat(filter.map(id)).has(tag("hystrixgroup", "mygroup"));
Meter.Id id2 = new Meter.Id("something.else", Tags.of("group", "mygroup"), null, null, Meter.Type.GAUGE);
assertThat(filter.map(id2)).has(tag("group", "mygroup"));
}
use of io.micrometer.core.instrument.config.MeterFilter in project micrometer by micrometer-metrics.
the class MeterFilterTest method replaceTagValues.
@Test
void replaceTagValues() {
MeterFilter filter = MeterFilter.replaceTagValues("status", s -> s.charAt(0) + "xx", "200");
Meter.Id id = new Meter.Id("name", Tags.of("status", "400"), null, null, Meter.Type.COUNTER);
Meter.Id filteredId = filter.map(id);
assertThat(filteredId).has(tag("status", "4xx"));
id = new Meter.Id("name", Tags.of("status", "200"), null, null, Meter.Type.COUNTER);
filteredId = filter.map(id);
assertThat(filteredId).has(tag("status", "200"));
}
use of io.micrometer.core.instrument.config.MeterFilter in project micrometer by micrometer-metrics.
the class MeterFilterTest method minExpectedOnTimer.
@Test
void minExpectedOnTimer() {
MeterFilter filter = MeterFilter.minExpected("name", Duration.ofNanos(100));
Meter.Id timer = new Meter.Id("name", emptyList(), null, null, Meter.Type.TIMER);
assertThat(filter.configure(timer, DistributionStatisticConfig.DEFAULT)).satisfies(conf -> assertThat(conf.getMinimumExpectedValue()).isEqualTo(100));
}
Aggregations