Description
I think that http.client.requests
metric has a wrong behaviour with query parameters. The query parameters should not be considered as part of the uri
tag.
If you have 2 calls to http://test123.io/api
and http://test123.io/api?q=1
I wouldn't expect them to be counted as different uris. Not only I think it is conceptually wrong, but also there is no way to group them later.
On top of that I can observe some inconsistencies on the result you get by using different approaches with either RestTemplate
and WebClient
.
Some examples:
- Will produce the tag
uri="/api/{pathParam}?queryParam={queryParam}"
webClient.get()
.uri("http://test123.io/api/{pathParam}?queryParam={queryParam}", "foobar", "xpto")
.retrieve()
.toEntity(Void.class)
.block();
- Will produce the tag
uri="/test123.io/api/foobar"
webClient.get()
.uri(uriBuilder -> uriBuilder.path("http://test123.io/api/{pathParam}")
.queryParam("queryParam", "xpto")
.build("foobar"))
.retrieve()
.toEntity(Void.class)
.block();
- Will produce the tag
uri="/api/foobar"
webClient.get()
.uri(uriBuilder -> uriBuilder.host("http://test123.io")
.path("/api/{pathParam}")
.queryParam("queryParam", "xpto")
.build("foobar"))
.retrieve()
.toEntity(Void.class)
.block();
- Will produce the tag
uri="/api/{pathParam}?queryParam={queryParam}"
restTemplate.getForObject("http://test123.io/api/{pathParam}?queryParam={queryParam}", Void.class, "foobar", "xpto");
- Will produce the tag
uri="/api/foobar?queryParam=xpto"
URI uri=UriComponentsBuilder.fromHttpUrl("http://test123.io/api/{pathParam}")
.queryParam("queryParam", "xpto")
.build("foobar");
restTemplate.getForObject(uri, Void.class);
In any of these cases I believe the correct value, for the tag, would be uri="/api/{pathParam}"
This was all tested using SB2.3.2
using the spring-boot-starter-webflux
and spring-boot-starter-web
.
I believe this is related to what is reported on this issue spring-projects/spring-framework#22371 , which was closed and marked as superseded, but references itself.