diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index 4052b2a93c..ec03cf3bef 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -412,8 +412,8 @@ to Spring MVC and Spring WebFlux server endpoints. === Web MVC and Annotation-Based WebFlux -Spring Boot 2.+ autoconfigures these interceptors. If you are using Spring Boot 1.x, simply add `@Import(WebMetricsConfiguration.class)` -to your `@SpringBootApplication` class. +Adding `@EnableMetrics` to your `@SpringBootApplication` class autoconfigures these +interceptors. The interceptors need to be enabled for every request handler or controller that you want to time. Add `@Timed` to: @@ -431,7 +431,7 @@ public class MyController { ``` The `Timer` is registered with a name of `http_server_requests` by default. This can be changed by setting -`spring.metrics.web.name`. +`spring.metrics.web.server_requests.name`. The `Timer` contains a set of dimensions for every request, governed by the primary bean `WebMetricsTagProvider` registered in your application context. If you don't provide such a bean, a default implementation is selected which adds the following dimensions: @@ -464,6 +464,15 @@ RouterFunction routes = RouterFunctions The filter applies to all routes defined by this router function. +=== `RestTemplate` Timing + +Adding `@EnableMetrics` to your `@SpringBootApplication` class autoconfigures a `BeanPostProcessor` for `RestTemplate`, +so every instance you create via the application context will be instrumented. + +A timer is recorded for each invocation that includes tags for URI (before parameter substitution), host, and status. +The name of this timer is `http_client_requests`, and can be changed via the `spring.metrics.web.client_requests.name` +property. + == Prometheus === Quickstart for Prometheus-based monitoring @@ -479,8 +488,8 @@ Register the Prometheus registry and enable Prometheus scraping: ```java @SpringBootApplication +@EnableMetrics @EnablePrometheusScraping -@Import(WebMetricsConfiguration.class) // to enable automatic timing of Web MVC endpoints public class MyApp { @Bean public MeterRegistry prometheusRegistry() {