如何计算akka-http的完整响应时间?

问题描述 投票:0回答:1
path("foo" ~ Slash.?) {
      complete(HttpEntity(ContentTypes.`application/octet-stream`, ByteString(Files.readAllBytes(Paths.get("foo")))))
}

foo是1GB的文件。我在响应的watchTermination周围添加了一个Flow,但在发送响应之前得到了通知,但实际上我想在将完整响应发送给客户端之后]收到通知。 。

[进一步调查显示,watchTermination建立在仅支持GraphStageonUpstreamFinish之上,并且只有在出现异常时才调用onDownstreamFinish。参见GraphStages.scala#L128

这是我完整代码的回购:https://github.com/ssgao/akka-http-quickstart-scala/tree/master/src/main/scala/com/example

path(“ foo”〜Slash。?){complete(HttpEntity(ContentTypes.`application / octet-stream`,ByteString(Files.readAllBytes(Paths.get(“ foo”)))))}说foo是一个1GB文件。我添加了watchTermination ...

scala akka akka-stream akka-http reactive
1个回答
0
投票

[SoftwareMill的共同创始人亚当·沃斯基(Adam Warski)写了一篇名为"Measuring response time in akka-http,"的博客文章,其中提供了Akka HTTP指令和随附的方法,它们可以一起记录响应时间。发送完整响应(可能包含数据流)后,将发生帖子中所述的日志记录。

© www.soinside.com 2019 - 2024. All rights reserved.