Polish "Allow configuration of auto-timed metrics"
This commit makes sure the "auto-time-requests" property is still available in a deprecated fashion. See gh-15988
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user