use of io.micrometer.core.instrument.config.MeterFilter in project micrometer by micrometer-metrics.
the class MeterFilterTest method maxExpectedOnSummary.
@Test
void maxExpectedOnSummary() {
MeterFilter filter = MeterFilter.maxExpected("name", 100);
Meter.Id timer = new Meter.Id("name", emptyList(), null, null, Meter.Type.DISTRIBUTION_SUMMARY);
assertThat(filter.configure(timer, DistributionStatisticConfig.DEFAULT)).satisfies(conf -> assertThat(conf.getMaximumExpectedValue()).isEqualTo(100));
}
use of io.micrometer.core.instrument.config.MeterFilter in project micrometer by micrometer-metrics.
the class MeterFilterTest method denyUnless.
@Test
void denyUnless() {
Meter.Id id1 = new Meter.Id("my.counter", emptyList(), null, null, Meter.Type.COUNTER);
Meter.Id id2 = new Meter.Id("other.counter", emptyList(), null, null, Meter.Type.COUNTER);
MeterFilter filter = MeterFilter.denyUnless(id -> id.getName().startsWith("my"));
assertThat(filter.accept(id1)).isEqualTo(MeterFilterReply.NEUTRAL);
assertThat(filter.accept(id2)).isEqualTo(MeterFilterReply.DENY);
}
use of io.micrometer.core.instrument.config.MeterFilter in project zipkin by openzipkin.
the class ZipkinUiConfiguration method uiServerConfigurator.
@Bean
ArmeriaServerConfigurator uiServerConfigurator(HttpService indexService, Optional<MeterRegistry> meterRegistry) throws IOException {
ServerCacheControl maxAgeYear = ServerCacheControl.builder().maxAgeSeconds(TimeUnit.DAYS.toSeconds(365)).build();
HttpService uiFileService = FileService.builder(getClass().getClassLoader(), "zipkin-lens").cacheControl(maxAgeYear).build();
String config = writeConfig(ui);
return sb -> {
sb.service("/zipkin/config.json", HttpFile.builder(HttpData.ofUtf8(config)).cacheControl(ServerCacheControl.builder().maxAgeSeconds(600).build()).contentType(MediaType.JSON_UTF_8).build().asService());
sb.serviceUnder("/zipkin/", uiFileService);
// TODO This approach requires maintenance when new UI routes are added. Change to the following:
// If the path is a a file w/an extension, treat normally.
// Otherwise instead of returning 404, forward to the index.
// See https://github.com/twitter/finatra/blob/458c6b639c3afb4e29873d123125eeeb2b02e2cd/http/src/main/scala/com/twitter/finatra/http/response/ResponseBuilder.scala#L321
sb.service("/zipkin/", indexService).service("/zipkin/index.html", indexService).service("/zipkin/traces/{id}", indexService).service("/zipkin/dependency", indexService).service("/zipkin/traceViewer", indexService);
sb.service("/favicon.ico", new RedirectService(HttpStatus.FOUND, "/zipkin/favicon.ico")).service("/", new RedirectService(HttpStatus.FOUND, "/zipkin/")).service("/zipkin", new RedirectService(HttpStatus.FOUND, "/zipkin/"));
// don't add metrics for favicon
meterRegistry.ifPresent(m -> m.config().meterFilter(MeterFilter.deny(id -> {
String uri = id.getTag("uri");
return uri != null && uri.startsWith("/favicon.ico");
})));
};
}
use of io.micrometer.core.instrument.config.MeterFilter in project spring-boot by spring-projects.
the class HttpClientMetricsAutoConfiguration method metricsHttpClientUriTagFilter.
@Bean
@Order(0)
public MeterFilter metricsHttpClientUriTagFilter(MetricsProperties properties) {
String metricName = properties.getWeb().getClient().getRequest().getMetricName();
MeterFilter denyFilter = new OnlyOnceLoggingDenyMeterFilter(() -> String.format("Reached the maximum number of URI tags for '%s'. Are you using 'uriVariables'?", metricName));
return MeterFilter.maximumAllowableTags(metricName, "uri", properties.getWeb().getClient().getMaxUriTags(), denyFilter);
}
use of io.micrometer.core.instrument.config.MeterFilter in project spring-boot by spring-projects.
the class WebMvcMetricsAutoConfiguration 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);
}
Aggregations