Skip to content

Commit 50b1fb0

Browse files
Mattias-Sehlstedtbclozel
authored andcommitted
Change the description for the uri client request observation
This commit describes what parts that are removed from the URI template keyvalue. Closes: gh-34116 Signed-off-by: Mattias-Sehlstedt <[email protected]>
1 parent a985b73 commit 50b1fb0

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

framework-docs/modules/ROOT/pages/integration/observability.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Instrumentation uses the `org.springframework.http.client.observation.ClientRequ
285285
|===
286286
|Name | Description
287287
|`method` _(required)_|Name of the HTTP request method or `"none"` if not a well-known method.
288-
|`uri` _(required)_|URI template used for HTTP request, or `"none"` if none was provided. Only the path part of the URI is considered.
288+
|`uri` _(required)_|URI template used for HTTP request, or `"none"` if none was provided. The protocol, host and port part of the URI are not considered.
289289
|`client.name` _(required)_|Client name derived from the request URI host.
290290
|`status` _(required)_|HTTP response raw status code, or `"IO_ERROR"` in case of `IOException`, or `"CLIENT_ERROR"` if no response was received.
291291
|`outcome` _(required)_|Outcome of the HTTP client exchange.
@@ -313,7 +313,7 @@ Instrumentation uses the `org.springframework.http.client.observation.ClientRequ
313313
|===
314314
|Name | Description
315315
|`method` _(required)_|Name of the HTTP request method or `"none"` if the request could not be created.
316-
|`uri` _(required)_|URI template used for HTTP request, or `"none"` if none was provided. Only the path part of the URI is considered.
316+
|`uri` _(required)_|URI template used for HTTP request, or `"none"` if none was provided. The protocol, host and port part of the URI are not considered.
317317
|`client.name` _(required)_|Client name derived from the request URI host.
318318
|`status` _(required)_|HTTP response raw status code, or `"IO_ERROR"` in case of `IOException`, or `"CLIENT_ERROR"` if no response was received.
319319
|`outcome` _(required)_|Outcome of the HTTP client exchange.
@@ -342,7 +342,7 @@ Instrumentation uses the `org.springframework.web.reactive.function.client.Clien
342342
|===
343343
|Name | Description
344344
|`method` _(required)_|Name of the HTTP request method or `"none"` if not a well-known method.
345-
|`uri` _(required)_|URI template used for HTTP request, or `"none"` if none was provided. Only the path part of the URI is considered.
345+
|`uri` _(required)_|URI template used for HTTP request, or `"none"` if none was provided. The protocol, host and port part of the URI are not considered.
346346
|`client.name` _(required)_|Client name derived from the request URI host.
347347
|`status` _(required)_|HTTP response raw status code, or `"IO_ERROR"` in case of `IOException`, or `"CLIENT_ERROR"` if no response was received.
348348
|`outcome` _(required)_|Outcome of the HTTP client exchange.

spring-web/src/main/java/org/springframework/http/client/observation/ClientHttpObservationDocumentation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public String asString() {
7474
/**
7575
* URI template used for HTTP request, or {@value KeyValue#NONE_VALUE} if
7676
* none was provided.
77-
* <p>Only the path part of the URI is considered.
77+
* <p>The protocol, host and port part of the URI are not considered.
7878
*/
7979
URI {
8080
@Override

spring-web/src/test/java/org/springframework/http/client/observation/DefaultClientRequestObservationConventionTests.java

+11
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ void addsKeyValuesForRequestWithUriTemplateWithHost() {
8888
assertThat(this.observationConvention.getHighCardinalityKeyValues(context)).contains(KeyValue.of("http.url", "https://example.org/resource/42"));
8989
}
9090

91+
@Test
92+
void addsKeyValuesForRequestWithUriTemplateWithHostAndQuery() {
93+
ClientRequestObservationContext context = createContext(
94+
new MockClientHttpRequest(HttpMethod.GET, "https://example.org/resource/{id}?queryKey={queryValue}", 42, "Query"), response);
95+
context.setUriTemplate("https://example.org/resource/{id}?queryKey={queryValue}");
96+
assertThat(this.observationConvention.getLowCardinalityKeyValues(context))
97+
.contains(KeyValue.of("exception", "none"), KeyValue.of("method", "GET"), KeyValue.of("uri", "/resource/{id}?queryKey={queryValue}"),
98+
KeyValue.of("status", "200"), KeyValue.of("client.name", "example.org"), KeyValue.of("outcome", "SUCCESS"));
99+
assertThat(this.observationConvention.getHighCardinalityKeyValues(context)).contains(KeyValue.of("http.url", "https://example.org/resource/42?queryKey=Query"));
100+
}
101+
91102
@Test
92103
void addsKeyValuesForRequestWithUriTemplateWithoutPath() {
93104
ClientRequestObservationContext context = createContext(

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientHttpObservationDocumentation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public String asString() {
7171
/**
7272
* URI template used for HTTP request, or {@value KeyValue#NONE_VALUE} if
7373
* none was provided.
74-
* <p>Only the path part of the URI is considered.
74+
* <p>The protocol, host and port part of the URI are not considered.
7575
*/
7676
URI {
7777
@Override

spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientRequestObservationConventionTests.java

+7
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ void shouldOnlyConsiderPathForUriKeyValue() {
131131
assertThat(this.observationConvention.getLowCardinalityKeyValues(context)).contains(KeyValue.of("uri", "/resource/{id}"));
132132
}
133133

134+
@Test
135+
void shouldKeepQueryParameterForUriKeyValue() {
136+
ClientRequestObservationContext context = createContext(ClientRequest.create(HttpMethod.GET, URI.create("https://example.org/resource/42?queryKey=Query")));
137+
context.setUriTemplate("https://example.org/resource/{id}?queryKey={queryValue}");
138+
assertThat(this.observationConvention.getLowCardinalityKeyValues(context)).contains(KeyValue.of("uri", "/resource/{id}?queryKey={queryValue}"));
139+
}
140+
134141
private ClientRequestObservationContext createContext(ClientRequest.Builder request) {
135142
ClientRequestObservationContext context = new ClientRequestObservationContext(request);
136143
context.setResponse(ClientResponse.create(HttpStatus.OK).build());

0 commit comments

Comments
 (0)