From 74ec10bf3a849e803ba5bb4e7baddd64f87ddcdb Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 2 Dec 2022 00:14:36 +0900 Subject: [PATCH] Polish Closes gh-29619 --- .../asciidoc/integration/observability.adoc | 30 +++++++++---------- .../docs/asciidoc/integration/scheduling.adoc | 2 +- ...tomServerRequestObservationConvention.java | 11 ++++--- ...dedServerRequestObservationConvention.java | 2 +- .../LocalValidatorFactoryBean.java | 2 +- .../aot/DeclarativeRuntimeHintsTests.java | 2 +- .../web/client/RestTemplate.java | 4 +-- 7 files changed, 26 insertions(+), 27 deletions(-) diff --git a/framework-docs/src/docs/asciidoc/integration/observability.adoc b/framework-docs/src/docs/asciidoc/integration/observability.adoc index 87c943c50e6f..dabca4a72ec3 100644 --- a/framework-docs/src/docs/asciidoc/integration/observability.adoc +++ b/framework-docs/src/docs/asciidoc/integration/observability.adoc @@ -17,11 +17,11 @@ If you are not familiar with Micrometer Observation, here's a quick summary of t * `Observation` is the actual recording of something happening in your application. This is processed by `ObservationHandler` implementations to produce metrics or traces. * Each observation has a corresponding `ObservationContext` implementation; this type holds all the relevant information for extracting metadata for it. In the case of an HTTP server observation, the context implementation could hold the HTTP request, the HTTP response, any Exception thrown during processing... -* Each `Observation` holds `KeyValues` metadata. In the case of an server HTTP observation, this could be the HTTP request method, the HTTP response status... +* Each `Observation` holds `KeyValues` metadata. In the case of a server HTTP observation, this could be the HTTP request method, the HTTP response status... This metadata is contributed by `ObservationConvention` implementations which should declare the type of `ObservationContext` they support. -* `KeyValues` are said to be "low cardinality" if there is a low, bounded number of possible values for the `KeyValue` tuple (HTTP methods is a good example). +* `KeyValues` are said to be "low cardinality" if there is a low, bounded number of possible values for the `KeyValue` tuple (HTTP method is a good example). Low cardinality values are contributed to metrics only. - "High cardinality" are on the other hand unbounded (for example, HTTP request URIs) and are only contributed to Traces. + High cardinality values are on the other hand unbounded (for example, HTTP request URIs) and are only contributed to Traces. * An `ObservationDocumentation` documents all observations in a particular domain, listing the expected key names and their meaning. @@ -48,7 +48,7 @@ If you want full control, you can then implement the entire convention contract include::code:CustomServerRequestObservationConvention[] -You can also similar goals using a custom `ObservationFilter` - adding or removing key values for an observation. +You can also achieve similar goals using a custom `ObservationFilter` - adding or removing key values for an observation. Filters do not replace the default convention and are used as a post-processing component. include::code:ServerRequestObservationFilter[] @@ -74,7 +74,7 @@ By default, the following `KeyValues` are created: |=== |Name | Description |`exception` _(required)_|Name of the exception thrown during the exchange, or `KeyValue#NONE_VALUE`} if no exception happened. -|`method` _(required)_|Name of HTTP request method or `KeyValue#NONE_VALUE` if the request was not received properly. +|`method` _(required)_|Name of HTTP request method or `"none"` if the request was not received properly. |`outcome` _(required)_|Outcome of the HTTP server exchange. |`status` _(required)_|HTTP response raw status code, or `"UNKNOWN"` if no response was created. |`uri` _(required)_|URI pattern for the matching handler if available, falling back to `REDIRECTION` for 3xx responses, `NOT_FOUND` for 404 responses, `root` for requests with no path info, and `UNKNOWN` for all other requests. @@ -100,8 +100,8 @@ By default, the following `KeyValues` are created: [cols="a,a"] |=== |Name | Description -|`exception` _(required)_|Name of the exception thrown during the exchange, or `KeyValue#NONE_VALUE` if no exception happened. -|`method` _(required)_|Name of HTTP request method or `KeyValue#NONE_VALUE` if the request was not received properly. +|`exception` _(required)_|Name of the exception thrown during the exchange, or `"none"` if no exception happened. +|`method` _(required)_|Name of HTTP request method or `"none"` if the request was not received properly. |`outcome` _(required)_|Outcome of the HTTP server exchange. |`status` _(required)_|HTTP response raw status code, or `"UNKNOWN"` if no response was created. |`uri` _(required)_|URI pattern for the matching handler if available, falling back to `REDIRECTION` for 3xx responses, `NOT_FOUND` for 404 responses, `root` for requests with no path info, and `UNKNOWN` for all other requests. @@ -122,7 +122,7 @@ By default, the following `KeyValues` are created: HTTP client exchanges observations are created with the name `"http.client.requests"` for blocking and reactive clients. Unlike their server counterparts, the instrumentation is implemented directly in the client so the only required step is to configure an `ObservationRegistry` on the client. -[[integration.observability.http-server.resttemplate]] +[[integration.observability.http-client.resttemplate]] === RestTemplate Instrumentation is using the `org.springframework.http.client.observation.ClientRequestObservationConvention` by default, backed by the `ClientRequestObservationContext`. @@ -131,11 +131,11 @@ Instrumentation is using the `org.springframework.http.client.observation.Client [cols="a,a"] |=== |Name | Description -|`exception` _(required)_|Name of the exception thrown during the exchange, or `KeyValue#NONE_VALUE` if no exception happened. -|`method` _(required)_|Name of HTTP request method or `KeyValue#NONE_VALUE` if the request could not be created. +|`exception` _(required)_|Name of the exception thrown during the exchange, or `"none"` if no exception happened. +|`method` _(required)_|Name of HTTP request method or `"none"` if the request could not be created. |`outcome` _(required)_|Outcome of the HTTP client exchange. |`status` _(required)_|HTTP response raw status code, or `"IO_ERROR"` in case of `IOException`, or `"CLIENT_ERROR"` if no response was received. -|`uri` _(required)_|URI template used for HTTP request, or `KeyValue#NONE_VALUE` if none was provided. +|`uri` _(required)_|URI template used for HTTP request, or `"none"` if none was provided. |=== .High cardinality Keys @@ -148,7 +148,7 @@ Instrumentation is using the `org.springframework.http.client.observation.Client -[[integration.observability.http-server.webclient]] +[[integration.observability.http-client.webclient]] === WebClient Instrumentation is using the `org.springframework.web.reactive.function.client.ClientRequestObservationConvention` by default, backed by the `ClientRequestObservationContext`. @@ -157,11 +157,11 @@ Instrumentation is using the `org.springframework.web.reactive.function.client.C [cols="a,a"] |=== |Name | Description -|`exception` _(required)_|Name of the exception thrown during the exchange, or `KeyValue#NONE_VALUE` if no exception happened. -|`method` _(required)_|Name of HTTP request method or `KeyValue#NONE_VALUE` if the request could not be created. +|`exception` _(required)_|Name of the exception thrown during the exchange, or `"none"` if no exception happened. +|`method` _(required)_|Name of HTTP request method or `"none"` if the request could not be created. |`outcome` _(required)_|Outcome of the HTTP client exchange. |`status` _(required)_|HTTP response raw status code, or `"IO_ERROR"` in case of `IOException`, or `"CLIENT_ERROR"` if no response was received. -|`uri` _(required)_|URI template used for HTTP request, or `KeyValue#NONE_VALUE` if none was provided. +|`uri` _(required)_|URI template used for HTTP request, or `"none"` if none was provided. |=== .High cardinality Keys diff --git a/framework-docs/src/docs/asciidoc/integration/scheduling.adoc b/framework-docs/src/docs/asciidoc/integration/scheduling.adoc index 0c71389c3488..4676ee140d14 100644 --- a/framework-docs/src/docs/asciidoc/integration/scheduling.adoc +++ b/framework-docs/src/docs/asciidoc/integration/scheduling.adoc @@ -724,7 +724,7 @@ The specified range is inclusive. * Following a range (or `*`) with `/` specifies the interval of the number's value through the range. * English names can also be used for the month and day-of-week fields. Use the first three letters of the particular day or month (case does not matter). -* The day-of-month and day-of-week fields can contain a `L` character, which has a different meaning +* The day-of-month and day-of-week fields can contain an `L` character, which has a different meaning. ** In the day-of-month field, `L` stands for _the last day of the month_. If followed by a negative offset (that is, `L-n`), it means _``n``th-to-last day of the month_. ** In the day-of-week field, `L` stands for _the last day of the week_. diff --git a/framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/CustomServerRequestObservationConvention.java b/framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/CustomServerRequestObservationConvention.java index 079a83099e1c..dc76cbc8395f 100644 --- a/framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/CustomServerRequestObservationConvention.java +++ b/framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/CustomServerRequestObservationConvention.java @@ -48,22 +48,21 @@ public KeyValues getHighCardinalityKeyValues(ServerRequestObservationContext con return KeyValues.of(httpUrl(context)); } - - protected KeyValue method(ServerRequestObservationContext context) { + private KeyValue method(ServerRequestObservationContext context) { // You should reuse as much as possible the corresponding ObservationDocumentation for key names return KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.METHOD, context.getCarrier().getMethod()); } // @fold:on // status(), exception(), httpUrl()... + private KeyValue status(ServerRequestObservationContext context) { + return KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.STATUS, String.valueOf(context.getResponse().getStatus())); + } + private KeyValue exception(ServerRequestObservationContext context) { String exception = (context.getError() != null) ? context.getError().getClass().getSimpleName() : KeyValue.NONE_VALUE; return KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.EXCEPTION, exception); } - private KeyValue status(ServerRequestObservationContext context) { - return KeyValue.of(ServerHttpObservationDocumentation.LowCardinalityKeyNames.STATUS, String.valueOf(context.getResponse().getStatus())); - } - private KeyValue httpUrl(ServerRequestObservationContext context) { return KeyValue.of(ServerHttpObservationDocumentation.HighCardinalityKeyNames.HTTP_URL, context.getCarrier().getRequestURI()); } diff --git a/framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/ExtendedServerRequestObservationConvention.java b/framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/ExtendedServerRequestObservationConvention.java index de24b8bf2865..48049a2c7552 100644 --- a/framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/ExtendedServerRequestObservationConvention.java +++ b/framework-docs/src/main/java/org/springframework/docs/integration/observability/config/conventions/ExtendedServerRequestObservationConvention.java @@ -30,7 +30,7 @@ public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext cont return super.getLowCardinalityKeyValues(context).and(custom(context)); } - protected KeyValue custom(ServerRequestObservationContext context) { + private KeyValue custom(ServerRequestObservationContext context) { return KeyValue.of("custom.method", context.getCarrier().getMethod()); } diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java index d6b164367f7e..827ee3fd893e 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java @@ -199,7 +199,7 @@ public void setConstraintValidatorFactory(ConstraintValidatorFactory constraintV *

Default is Hibernate Validator's own internal use of standard Java reflection, * with an additional {@link KotlinReflectionParameterNameDiscoverer} if Kotlin * is present. This may be overridden with a custom subclass or a Spring-controlled - * {@link org.springframework.core.DefaultParameterNameDiscoverer} if necessary, + * {@link org.springframework.core.DefaultParameterNameDiscoverer} if necessary. */ public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) { this.parameterNameDiscoverer = parameterNameDiscoverer; diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/DeclarativeRuntimeHintsTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/DeclarativeRuntimeHintsTests.java index 55981ba1aec5..e983a5fa9743 100644 --- a/spring-test/src/test/java/org/springframework/test/context/aot/DeclarativeRuntimeHintsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/aot/DeclarativeRuntimeHintsTests.java @@ -53,7 +53,7 @@ void declarativeRuntimeHints() { // @Reflective assertReflectionRegistered(testClass); - // @@RegisterReflectionForBinding + // @RegisterReflectionForBinding assertReflectionRegistered(SampleClassWithGetter.class); assertReflectionRegistered(String.class); assertThat(reflection().onMethod(SampleClassWithGetter.class, "getName")).accepts(this.runtimeHints); diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java index a6ddae025093..b1de2311feff 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -79,14 +79,14 @@ * method API over underlying HTTP client libraries such as the JDK * {@code HttpURLConnection}, Apache HttpComponents, and others. RestTemplate * offers templates for common scenarios by HTTP method, in addition to the - * generalized {@code exchange} and {@code execute} methods that support of + * generalized {@code exchange} and {@code execute} methods that support * less frequent cases. * *

RestTemplate is typically used as a shared component. However, its * configuration does not support concurrent modification, and as such its * configuration is typically prepared on startup. If necessary, you can create * multiple, differently configured RestTemplate instances on startup. Such - * instances may use the same the underlying {@link ClientHttpRequestFactory} + * instances may use the same underlying {@link ClientHttpRequestFactory} * if they need to share HTTP client resources. * *

NOTE: As of 5.0 this class is in maintenance mode, with