Skip to content

Micrometer-Extension writes wrong URI-Tag when Path-Variables defined at Interface-Level #30843

@lostiniceland

Description

@lostiniceland

Describe the bug

We are currently seing wrong metric-uri-tags for incoming requests when using the Micrometer-Prometheus extension.

Instead of placeholders for the path-variables, a metric for each path-variable-instance is created.
The issue is caused when placing the JAX-RS annotations on an interface, rather than the actual resource-class.

As a workaround, we have to duplicate @Path (and probably also @PathParam) to the implementing class, which is quite error-prone.

Unfortunatly using quarkus.micrometer.binder.http-server.match-patterns only work as workaround for the first appearance like /<id> but it fails for sub-queries like /<id>/do

Expected behavior

Metric is tagged with proper uri, replacing path-variables with a placeholder
http_server_requests_seconds_count{... uri="/{id}"} 1.0

Path annotation should be recognized regardless of location on interface or class

Actual behavior

A unique metric is written for each path-parameter accessing the endpoint

http_server_requests_seconds_count{... uri="/eae3806d-141c-46ed-a067-6f4b81f36062"} 2.0
http_server_requests_seconds_count{... uri="/eae3806d-141c-yyyy-xxxx-6f4b81f36062"} 1.0

How to Reproduce?

Enable dependency quarkus-micrometer-registry-prometheus

Create a endpoint consisting of interface and impl.

Path("/")
public interface SomeApi {
   @GET
   @Path("{id}")
   Response load(@PathParam("id) String id);
}

@RequestScoped
public class SomeResource implements SomeApi {
   public Response load(String id){
   ...do
   }
}

Access App with /someid to trigger metrics and check /q/metrics for http_server_requests_count

Output of uname -a or ver

No response

Output of java -version

17

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.15.3

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

Maven 3.8.3

Additional information

Our main motivation for splitting interface and implementation is to avoid the annotation-hell due to swagger and jax-rs. The implementation in our case then has the meaningfull stuff like access-control, custom interceptors.
Furthermore the split is needed when doing contract first with OpenApi-Generators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions