Skip to content

Instantly share code, notes, and snippets.

@jjunqueira
jjunqueira / LogReqRespTimeWithTransportTime.scala
Created February 16, 2018 13:58
Log Akka Http Response time including transmission of bytes
def akkaResponseTimeLoggingFunction(loggingAdapter: LoggingAdapter,
requestTimestamp: Long,
level: LogLevel = Logging.InfoLevel)(req: HttpRequest)(res: RouteResult): Unit = {
res match {
case Complete(resp) =>
resp.entity.transformDataBytes(Flow[ByteString].watchTermination() {
case (_, f) =>
f.foreach { _ =>
val responseTimestamp: Long = System.nanoTime
val elapsedTime: Long = (responseTimestamp - requestTimestamp) / 1000000

Keybase proof

I hereby claim:

  • I am jjunqueira on github.
  • I am jjunqueira (https://keybase.io/jjunqueira) on keybase.
  • I have a public key ASDX_xvcVfaf-pA1BRIVzGeXzkb06de3ZNw_5kZJWthssgo

To claim this, I am signing this object:

@jjunqueira
jjunqueira / 0_reuse_code.js
Created April 5, 2014 19:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console