Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest Client metrics show real value in uri attribute instead of path parameter placeholders when used with @Url #44974

Closed
andrzejcyb opened this issue Dec 6, 2024 · 4 comments · Fixed by #45010

Comments

@andrzejcyb
Copy link

Describe the bug

When using Rest Client with the new @url annotation for dynamic url together with metrics quarkus-micrometer-registry-prometheus I can see that uri attribute of the metric shows values passed as path parameters instead of path parameters placeholders.

This is problematic as it creates one metric per each path parameter permutation.

I checked that Rest Client with base uri defined in configuration or via RestClientBuilder produces correct metrics. So it must be related to implementation of the new @url annotation.

Expected behavior

Metrics should show path parameter placeholder /example/{id} to reduce cardinality of the metrics

   http_client_requests_seconds_count{clientName="localhost",method="GET",outcome="SUCCESS",status="200",uri="/example/{id}",} 32.0
   http_client_requests_seconds_sum{clientName="localhost",method="GET",outcome="SUCCESS",status="200",uri="/example/{id}",} 0.0397333

Actual behavior

Metrics show /example/1 with real value 1 instead of path parameter placeholder {id}

http_client_requests_seconds_count{clientName="localhost",method="GET",outcome="SUCCESS",status="200",uri="/example/1",} 6.0
http_client_requests_seconds_sum{clientName="localhost",method="GET",outcome="SUCCESS",status="200",uri="/example/1",} 0.0097736

How to Reproduce?

Project dependencies

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-jackson</artifactId>
</dependency>

Test code using @url

@Path("/example")
public class ExampleResource {

    @RestClient
    ExampleClient exampleClient;


    @GET
    @Path("/{id}")
    @Produces(MediaType.TEXT_PLAIN)
    public String example() {
        return "Hello from Quarkus REST";
    }

    @GET
    @Path("/call")
    @Produces(MediaType.TEXT_PLAIN)
    public String call() {
        return exampleClient.getById("http://localhost:8080", "1");
    }

    @Path("/example")
    @RegisterRestClient(baseUri = "http://dummy")
    public interface ExampleClient  {

        @GET
        @Path("/{id}")
        String getById(@Url String baseUri, @PathParam("id") String id);
    }

}

Metrics endpoint

http://localhost:8080/q/metrics

Output of uname -a or ver

No response

Output of java -version

java 21.0.1 2023-10-17 LTS

Quarkus version or git rev

3.17.3

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Copy link

quarkus-bot bot commented Dec 6, 2024

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

@cescoffier
Copy link
Member

@brunobat Can you have a look? That can be a problem.

@geoand
Copy link
Contributor

geoand commented Dec 9, 2024

This is due to the new feature I added, I'll have a look soon

@brunobat
Copy link
Contributor

brunobat commented Dec 9, 2024

Yes, this is a problem. Will also have a look

geoand added a commit to brunobat/quarkus that referenced this issue Dec 10, 2024
geoand added a commit to brunobat/quarkus that referenced this issue Dec 10, 2024
geoand added a commit to brunobat/quarkus that referenced this issue Dec 10, 2024
geoand added a commit to brunobat/quarkus that referenced this issue Dec 11, 2024
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Dec 11, 2024
@gsmet gsmet modified the milestones: 3.18 - main, 3.17.5 Dec 17, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants