Hi Shivani,
you could do something like this:
import scala.concurrent._
import scala.concurrent.duration._
import akka.actor.ActorSystem
import akka.stream.Materializer
import akka.http.scaladsl._
import akka.http.scaladsl.model._
def timed(req: HttpRequest)(implicit system: ActorSystem, mat:
Materializer): Future[(HttpResponse, Duration)] = {
import system.dispatcher
val startTime = System.currentTimeMillis
Http().singleRequest(req).map { resp =>
val endTime = System.currentTimeMillis
(resp, Duration(endTime - startTime, MILLISECONDS))
}
}
cheers,
Rafał
W dniu czwartek, 9 marca 2017 13:12:45 UTC+1 użytkownik Shivani Gupta
napisał:
>
> my code snippet is
>
> Future[HttpResponse] = Http().singleRequest(Post(httpUrl,
> HttpEntity(ContentType(MediaTypes.`application/json`), query)))
>
>
> want to log the response duration of this. How can i do that?
>
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.