How to instrument akka-http full response time?

Viewed 182
path("foo" ~ Slash.?) {
      complete(HttpEntity(ContentTypes.`application/octet-stream`, ByteString(Files.readAllBytes(Paths.get("foo")))))
}

Say foo is a 1GB file. I added a watchTermination around the Flow of response, but I got notified before the response is sent, but in reality I would like to be notified after the full response is sent to the client.

Further investigation shows watchTermination is built on a GraphStage, which only supports onUpstreamFinish, and it's onDownstreamFinish is only called when there's an exception. See GraphStages.scala#L128

Here's the repo of my full code: https://github.com/ssgao/akka-http-quickstart-scala/tree/master/src/main/scala/com/example

0 Answers
Related