Search code examples
spring-bootmetricsspring-webflux

How to produce metrics of URI correctly in spring boot 2 + webflux


I have a problem using spring boot 2.0.3 + spring webflux (functional endpoints) + metrics. According to the official doc:

The generated metrics of uri should be the request’s URI template prior to variable substitution

Which means instead of /api/person/123, the generated metrics of URI should be something like /api/person/{id}. However, when I query those metrics on my spring boot app with this link http://localhost:8080/actuator/metrics/http.server.requests, I got these URIs:

/api/person/2
/api/person/33
/api/person/12

To reproduce this issue, I put a sample code here: https://gitlab.com/itsleon/demo

Can someone please shed some light on this issue? Thanks in advance!


Solution

  • There's an open issue for that in Spring Boot. Currently, Spring WebFlux fn doesn't provide the information about the URI pattern that matched for the current request, so there's no way to achieve that currently.

    Your assessment is correct, currently the full request URIs are collected.