Do Ktor plugins have a way to log how long it took to install? Currently I am using the next solution, but I wonder if there is something already built-in for it.
Copy code
fun <B : Any, F : Any> Application.installWithTiming(
plugin: Plugin<Application, B, F>,
configure: B.() -> Unit = {}
): F {
<http://this.log.info|this.log.info>("Installing plugin: ${plugin.key.name}.")
val timeTaken: Long = measureTimeMillis {
install(plugin = plugin, configure = configure)
}
<http://this.log.info|this.log.info>("Installed plugin: ${plugin.key.name}. Time taken: $timeTaken ms")
return plugin(plugin = plugin)
}
a
Aleksei Tirman [JB]
03/07/2024, 11:31 AM
Unfortunately, there is no built-in way to do that. Can you please describe your use case?
f
Fernando Sanchez (Perraco Labs)
03/07/2024, 11:47 AM
Very simple use case, the server was taking longer than usual to start, so I created this extension function and replaced all the plugin "installs" with it. This showed me that the problem was with the GraphQL library I was using, and a custom plugin I created for RBAC. Now with this extension function I have a clear view of installation times for each plugin. But, if ktor had something built-in then better.