Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
Closes gh-29619
  • Loading branch information
izeye authored and bclozel committed Dec 1, 2022
1 parent dd6cb1b commit 74ec10b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
30 changes: 15 additions & 15 deletions framework-docs/src/docs/asciidoc/integration/observability.adoc
Expand Up @@ -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.


Expand All @@ -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[]
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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`.
Expand All @@ -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
Expand All @@ -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`.
Expand All @@ -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
Expand Down
Expand Up @@ -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_.
Expand Down
Expand Up @@ -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());
}
Expand Down
Expand Up @@ -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());
}

Expand Down
Expand Up @@ -199,7 +199,7 @@ public void setConstraintValidatorFactory(ConstraintValidatorFactory constraintV
* <p>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;
Expand Down
Expand Up @@ -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);
Expand Down
Expand Up @@ -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.
*
* <p>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.
*
* <p><strong>NOTE:</strong> As of 5.0 this class is in maintenance mode, with
Expand Down

0 comments on commit 74ec10b

Please sign in to comment.