api失败时丰富Prometheus Response

时间:2019-05-15 19:20:04

标签: spring-boot prometheus

在Spring Boot中,我有一个带有控制器“ / my”的Rest api。在“我的控制器中,我正在调用3个api:/ a,/ b,c

当任何api关闭时,我将抛出LocalHttpClientErrorException。

现在,当我公开普罗米修斯指标时,它显示的计数很好..但是我可以丰富一下以显示哪个api实际上引发异常

获得答复

  

http_server_requests_seconds_sum {exception =“ LocalHttpClientErrorException”,method =“ GET”,outcome =“ CLIENT_ERROR”,status =“ 404”,uri =“ / my”,}   3.032826704

预期响应

  

http_server_requests_seconds_sum {exception =“ LocalHttpClientErrorException   在Api   A“,method =” GET“,outcome =” CLIENT_ERROR“,status =” 404“,uri =” / my / a“,}   3.032826704

1 个答案:

答案 0 :(得分:0)

是的,您可以使用自己的标签来丰富指标。您没有共享代码,因此我无法为您的问题写出确切的答案,但是您应该查看 WebFluxTagsProvider MeterFilter

一旦您更新问题,我将对此进行更新。