首页 > 解决方案 > 在 Spring Boot 指标中计算 AsyncResponse 调用

问题描述

我有一个用 Spring boot 2 编写的 JAX-RS 服务后端,并使用千分尺进行度量。默认情况下,这些指标包含非常好的 http 指标,如 http_server_requests_seconds_count。

这些对于正常的 GET 和 PUT 请求非常有用。不过,我的服务中的一种方法使用 JAX-RS AsyncRequest。

@GET
@Produces(APPLICATION_JSON)
@Path("next/{position}")
public void getNext(
        @PathParam("position") Long position,
        @Suspended final AsyncResponse response) throws InterruptedException {
...
// Somewhere in the code in another thread I invoke
response.resume(entity);
... 
}

这些电话似乎根本没有被计算在内。有没有办法让他们计数?如果不是,我应该简单地从我的代码中手动输入相同的计数器吗?

标签: spring-bootjax-rsmicrometer

解决方案


推荐阅读