After migrate from spring boot 2.7.5 to spring boot 3.0.1.
The tag URI on the metric http.client.requests have the value none in all cases.
We build the URI of the restTemplate like
URI uri = UriComponentsBuilder.fromUri(restTemplate.getUriTemplateHandler().expand("/hello"))
.build()
.toUri();
return restTemplate.getForObject(uri, String.class);
I'm used to do it this way since to add query params, I think it's more easy to read and to manage.
To reproduce it I created two small application in this repository one on spring boot 2.7.7 and an other one on 3.0.1
I figure out it's linked to the new Observability on spring 6 and linked to this issue on spring boot.
And Spring boot 2 customise the UriTemplateHandler and store the urlTemplate in ThreadLocal<Deque>. And use this deque for the tag uri.
From the documentation I know I could enhance the tag by providing a new @Bean ClientRequestObservationConvention.
I could also use org.springframework.web.client.RestTemplate#getForObject(java.lang.String, java.lang.Class, java.util.Map<java.lang.String,?>). like
return restTemplate.getForObject("/hello", String.class);
But I wonder if there is a way to get the previous behaviour and still used org.springframework.web.client.RestTemplate#getForEntity(java.net.URI, java.lang.Class).