Spray record response time

277 views
Skip to first unread message

robin nagpal

unread,
Nov 11, 2017, 7:31:25 PM11/11/17
to spray.io User List
I need to find the response time of a request and for that I wrote a directive


def timeD: Directive0 = mapRequestContext { ctx =>
    logger.info(s"Start logging Request ${System.currentTimeMillis}")
    val timeStampStart = System.currentTimeMillis

    mapHttpResponse { response =>
      logger.info(s"Stop logging Request ${System.currentTimeMillis}")
      logger.info(s"Time taken to serve Request: ${System.currentTimeMillis - timeStampStart} ms")
      response
    }
    ctx
  }

The log statement when I get the request i.e. "Start logging Request" is logged, but not the response logs.

Can someone please help.

Reply all
Reply to author
Forward
0 new messages