Align WebClient uri metric tag with RestTemplate

Prior to this commit, the `WebClientExchangeTags`, when given a request
without a string template, would only get the request path to create the
"uri" tag for metrics. This is inconsistent with the
`RestTemplateExchangeTags`, which are taking the full request URI minus
the protocol+host+port.

This commit aligns the `WebClientExchangeTags` behavior in this case.

Closes gh-22832
This commit is contained in:
Brian Clozel
2020-09-09 13:33:48 +02:00
parent 9c408babfa
commit d2e67ab84d
2 changed files with 9 additions and 1 deletions

View File

@@ -78,6 +78,14 @@ class WebClientExchangeTagsTests {
assertThat(WebClientExchangeTags.uri(this.request)).isEqualTo(Tag.of("uri", "/projects/spring-boot"));
}
@Test
void uriWhenTemplateIsMissingShouldReturnPathWithQueryParams() {
this.request = ClientRequest
.create(HttpMethod.GET, URI.create("https://example.org/projects/spring-boot?section=docs")).build();
assertThat(WebClientExchangeTags.uri(this.request))
.isEqualTo(Tag.of("uri", "/projects/spring-boot?section=docs"));
}
@Test
void clientName() {
assertThat(WebClientExchangeTags.clientName(this.request)).isEqualTo(Tag.of("clientName", "example.org"));