diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java index ec9a83758a..889f7c8a17 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java @@ -184,6 +184,29 @@ public class MetricsProperties { return this.request; } + /** + * Return whether server requests should be automatically timed. + * @return {@code true} if server request should be automatically timed + * @deprecated since 2.2.0 in favor of {@link Autotime#isEnabled()} + */ + @DeprecatedConfigurationProperty( + replacement = "management.metrics.web.server.request.autotime.enabled") + @Deprecated + public boolean isAutoTimeRequests() { + return this.request.getAutotime().isEnabled(); + } + + /** + * Set whether server requests should be automatically timed. + * @param autoTimeRequests whether server requests should be automatically + * timed + * @deprecated since 2.2.0 in favor of {@link Autotime#isEnabled()} + */ + @Deprecated + public void setAutoTimeRequests(boolean autoTimeRequests) { + this.request.getAutotime().setEnabled(autoTimeRequests); + } + /** * Return name of the metric for server requests. * @return request metric name @@ -191,6 +214,7 @@ public class MetricsProperties { */ @DeprecatedConfigurationProperty( replacement = "management.metrics.web.server.request.metric-name") + @Deprecated public String getRequestsMetricName() { return this.request.getMetricName(); } @@ -201,6 +225,7 @@ public class MetricsProperties { * @deprecated since 2.2.0 in favor of * {@link ServerRequest#setMetricName(String)} */ + @Deprecated public void setRequestsMetricName(String requestsMetricName) { this.request.setMetricName(requestsMetricName); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java index cd156e70f7..b603f56c7f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java @@ -109,6 +109,20 @@ public class WebFluxMetricsAutoConfigurationTests { }); } + @Test + @Deprecated + public void metricsAreNotRecordedIfAutoTimeRequestsIsDisabledWithDeprecatedProperty() { + this.contextRunner + .withConfiguration(AutoConfigurations.of(WebFluxAutoConfiguration.class)) + .withUserConfiguration(TestController.class) + .withPropertyValues( + "management.metrics.web.server.auto-time-requests=false") + .run((context) -> { + MeterRegistry registry = getInitializedMeterRegistry(context); + assertThat(registry.find("http.server.requests").meter()).isNull(); + }); + } + private MeterRegistry getInitializedMeterRegistry( AssertableReactiveWebApplicationContext context) { WebTestClient webTestClient = WebTestClient.bindToApplicationContext(context)