简体   繁体   English

如何在Play中衡量完整的响应时间(请求客户收到的响应)! 框架?

[英]How to measure complete response time (request in to response received by client ) in Play! framework?

I'm a new user of playframework. 我是playframework的新用户。 In a project of mine, I want to measure how long it takes from when a HTTP request comes in until the last byte of the response has been received by the client. 在我的一个项目中,我想测量从发出HTTP请求到客户端收到响应的最后一个字节要花费多长时间。 I'm calling this period of time "response time". 我称这段时间为“响应时间”。 In a netty log, I can see: 在网络日志中,我可以看到:

2016-11-17 10:32:00,712 [DEBUG] from io.netty.handler.logging.LoggingHandler in netty-event-loop-3 - [id: 0xb4fb943a, L:/127.0.0.1:9001 - R:/127.0.0.1:50871] WRITE: DefaultFullHttpResponse(decodeResult: success, version: HTTP/1.1, content: ReadOnlyByteBufferBuf(ridx: 0, widx: 655, cap: 655/655))

2016-11-17 10:32:00,713 [DEBUG] from io.netty.handler.logging.LoggingHandler in netty-event-loop-3 - [id: 0xb4fb943a, L:/127.0.0.1:9001 - R:/127.0.0.1:50871] FLUSH

2016-11-17 10:32:00,713 [DEBUG] from io.netty.handler.logging.LoggingHandler in netty-event-loop-3 - [id: 0xb4fb943a, L:/127.0.0.1:9001 - R:/127.0.0.1:50871] FLUSH

2016-11-17 10:37:19,311 [DEBUG] from io.netty.handler.logging.LoggingHandler in netty-event-loop-3 - [id: 0xb4fb943a, L:/127.0.0.1:9001 ! R:/127.0.0.1:50871] INACTIVE

2016-11-17 10:37:19,312 [DEBUG] from io.netty.handler.logging.LoggingHandler in netty-event-loop-3 - [id: 0xb4fb943a, L:/127.0.0.1:9001 ! R:/127.0.0.1:50871] UNREGISTERED

I can get the response time from the log (from WRITE to FLUSH?), but is there any way to get the "response time" more easily? 我可以从日志中获取响应时间(从WRITE到FLUSH?),但是有什么方法可以更轻松地获取“响应时间”吗? What I need is to measure the "response time" as a metric and log it or send it to Grafana. 我需要的是将“响应时间”作为度量标准进行度量并将其记录或发送给Grafana。

Thanks everyone! 感谢大家!

You can either: 您可以:

  • use a library that will collect the metrics from the framework and push them to a metric backend. 使用一个将从框架中收集指标并将其推送到指标后端的库。 Kamon is a nice library with a play integration Kamon是一个很好的库,具有播放功能
  • write your own code to record the metric. 编写自己的代码来记录指标。 For this you will need to look into play filters 为此,您需要研究播放过滤器

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

相关问题 如何记录aws api网关rest api的完整请求/响应? - How to log complete Request /Response of aws api gateway rest api? 如何在 Java 应用程序的 Vertx 框架中记录请求和响应 - How to log request and response in Vertx framework for Java Application 记录客户端中WCF请求的请求和响应值 - Logging Request and Response values for a WCF request in client 请求和响应时的 Haproxy 日志记录 - Haproxy Logging At Time of Request & Time of Response 如何在Suo逻辑中找到HTTP请求的响应时间 - How to find out the response time in sumo logic for a http request 记录客户端请求而无需等待服务器响应 - Log client request without waiting for server response 使用CXF动态客户端记录请求/响应 - Logging request/response with CXF dynamic client Feign 客户端请求和响应以及 URL 日志记录 - Feign Client request and response and URL Logging 如何在 Django Rest Framework 中记录 4XX Http 状态的请求和响应? - How to log request and response for 4XX Http status in Django Rest Framework? 如何读取HTTP分块响应并在Elixir中向客户端发送分块响应? - How to read an HTTP chunked response and send chunked response to client in Elixir?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM