Log Ktor API response time

Hi,

I am working on a REST application using Ktor.

To monitor performance, I was trying to get Ktor to output the response time of each request to console, but I could not find any info.

Does anyone know how could I do it? Thanks!

Have a look at that: [[You will be redirected shortly]]

I found it but could not get it to work, for me it seems to expose data to integrate w/ grafana or stuff like that.

Have you used it? I want to print the response time to console

Did you try increasing the debug level, IIRC some of the engines log that kind of info.

1 Like

Try as below for android
in private val client = HttpClient(CIO) block

install(ResponseObserver) {
            onResponse { response ->
                Log.d("ApiService", "HTTP status: ${response.status.value}>>${response.responseTime.timestamp-response.requestTime.timestamp}ms")
            }
        }