quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.49k stars 2.59k forks source link

Add correct uri value on REST Client metrics when using `RestClientBuilder` #41769

Open gian1200 opened 1 month ago

gian1200 commented 1 month ago

Description

Not sure if working as expected or a bug, so reporting it as an enhancement

Currently, when using quarkus-micrometer-registry-prometheus and RestClientBuilder.newBuilder(), metrics are exposed as uri="root"; even if dynamic URI has a defined path.

Small reproducer:

@RegisterRestClient
public interface MyRemoteService {

    @GET
    Object getStreams();

}
@Path("/hello")
public class GreetingResource {

    @GET
    public String hello() {
        MyRemoteService myRemoteService = RestClientBuilder.newBuilder()
                .baseUri(URI.create("https://code.quarkus.io/api/streams"))
                .build(MyRemoteService.class);

        return myRemoteService.getStreams().toString();
    }

}

Sample metrics:

# TYPE http_client_requests_seconds summary
# HELP http_client_requests_seconds  
http_client_requests_seconds_count{clientName="code.quarkus.io",method="GET",outcome="SUCCESS",status="200",uri="root"} 1.0
http_client_requests_seconds_sum{clientName="code.quarkus.io",method="GET",outcome="SUCCESS",status="200",uri="root"} 0.3211975
# TYPE http_client_requests_seconds_max gauge
# HELP http_client_requests_seconds_max  
http_client_requests_seconds_max{clientName="code.quarkus.io",method="GET",outcome="SUCCESS",status="200",uri="root"} 0.3211975

It shows the expected path/uri when @Path annotations are used instead of Programmatic client creation. Expected value: /api/streams

Implementation ideas

No response

quarkus-bot[bot] commented 1 month ago

/cc @cescoffier (rest-client), @ebullient (metrics), @geoand (rest-client), @jmartisk (metrics)