如何在 spring boot 2 + webflux 中正确生成 URI 指标

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

我在使用 spring boot 2.0.3 + spring webflux(功能端点)+ 指标时遇到问题。根据 official doc:

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

这意味着生成的 URI 指标应该类似于 /api/person/{id},而不是 /api/person/123。但是,当我使用 link http://localhost:8080/actuator/metrics/http.server.requests 在我的 spring 启动应用程序上查询这些指标时,我得到了这些 URI:

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

为了重现这个问题,我在这里放了一个示例代码:https://gitlab.com/itsleon/demo

有人可以解释一下这个问题吗?提前致谢!

有一个 open issue for that in Spring Boot。 目前,SpringWebFlux fn 不提供有关与当前请求匹配的 URI 模式的信息,因此目前无法实现。

您的评估是正确的,目前收集了完整的请求 URI。