Merge branch '2.7.x'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -82,6 +82,7 @@ public class WebMvcMetricsAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public FilterRegistrationBean<WebMvcMetricsFilter> webMvcMetricsFilter(MeterRegistry registry,
|
||||
WebMvcTagsProvider tagsProvider) {
|
||||
ServerRequest request = this.properties.getWeb().getServer().getRequest();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -121,6 +121,15 @@ class WebMvcMetricsAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void filterRegistrationBacksOff() {
|
||||
this.contextRunner.withUserConfiguration(TestWebMvcMetricsFilterConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(FilterRegistrationBean.class);
|
||||
assertThat(context.getBean(FilterRegistrationBean.class))
|
||||
.isSameAs(context.getBean("testWebMvcMetricsFilter"));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) {
|
||||
this.contextRunner.withUserConfiguration(TestController.class)
|
||||
@@ -248,4 +257,15 @@ class WebMvcMetricsAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class TestWebMvcMetricsFilterConfiguration {
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("unchecked")
|
||||
FilterRegistrationBean<WebMvcMetricsFilter> testWebMvcMetricsFilter() {
|
||||
return mock(FilterRegistrationBean.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -693,7 +693,7 @@ Metrics are tagged by the name of the executor, which is derived from the bean n
|
||||
==== Spring MVC Metrics
|
||||
Auto-configuration enables the instrumentation of all requests handled by Spring MVC controllers and functional handlers.
|
||||
By default, metrics are generated with the name, `http.server.requests`.
|
||||
You can customized the name by setting the configprop:management.metrics.web.server.request.metric-name[] property.
|
||||
You can customize the name by setting the configprop:management.metrics.web.server.request.metric-name[] property.
|
||||
|
||||
`@Timed` annotations are supported on `@Controller` classes and `@RequestMapping` methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
|
||||
If you do not want to record metrics for all Spring MVC requests, you can set configprop:management.metrics.web.server.request.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
|
||||
@@ -726,6 +726,9 @@ To replace the default tags, provide a `@Bean` that implements `WebMvcTagsProvid
|
||||
TIP: In some cases, exceptions handled in web controllers are not recorded as request metrics tags.
|
||||
Applications can opt in and record exceptions by <<web#web.servlet.spring-mvc.error-handling, setting handled exceptions as request attributes>>.
|
||||
|
||||
By default, all requests are handled.
|
||||
To customize the filter, provide a `@Bean` that implements `FilterRegistrationBean<WebMvcMetricsFilter>`.
|
||||
|
||||
|
||||
|
||||
[[actuator.metrics.supported.spring-webflux]]
|
||||
|
||||
Reference in New Issue
Block a user