Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 206
CL Chang Avatar asked Jan 17 '26 09:01

CL Chang


1 Answers

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.

like image 177
Brian Clozel Avatar answered Jan 20 '26 03:01

Brian Clozel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!