Hello,
I try to understand how to create an @Around aspect for a Kotlin’s suspended function (for example, to measure time spent in this function, or for a custom @Transactional aspect):
@Timed("my-timer")
suspend fun test() {
println("before")
delay(50) // invokes ProceedingJoinPoint#proceed() before this line
println("after")
}
Since this function has a suspend function call, the @Around aspect’s proceed function will be invoked right before delay()
call. But obviously I’d like to measure full time spent in the function.
What is the right way to solve it? Maybe I can somehow subscribe on the last continuation in the method, or smth like that?