简体   繁体   English

如何测量 javax.ws.rs.client.Client 建立连接所用的时间?

[英]How to measure the time taken for javax.ws.rs.client.Client to establish a connection?

we noticed that some of our requests to Azure are taking too long.我们注意到我们对 Azure 的一些请求花费的时间太长。

They told us that they don't appear to receive a request until much after we start the request.他们告诉我们,直到我们开始请求之后,他们似乎才收到请求。 Given that, it would be good for us to be able to log how long it took to establish a connection to the remote host.鉴于此,我们最好能够记录与远程主机建立连接所花费的时间。

We are using javax.ws.rs.client.Client.我们正在使用 javax.ws.rs.client.Client。

Does anyone know if there is a way to enable debug logging which would capture this metric or if we can get the metrics in some other way?有谁知道是否有一种方法可以启用调试日志记录来捕获此指标,或者我们是否可以通过其他方式获取这些指标?

You can add interceptors in your request which will log the request and the response to the console and the time taken in that request will be logged in those requests.您可以在请求中添加拦截器,它将记录请求和对控制台的响应,并且该请求中花费的时间将记录在这些请求中。 how to add interceptors you can find the given post on stack over flow to see how you can do that. 如何添加拦截器您可以在堆栈溢出中找到给定的帖子,以了解如何执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM