Aspect around Kotlin suspended function

Viewed 617

What is the right way to create an aspect around Kotlin suspended function?

From my observation, Micrometer's @Timed aspect does work with them, but shows incorrect result - looks like it measures time between method invocation and suspension, not the full time spent in the method (which should include post-suspension period)

Example of what I'd like to achieve:

@CoroutineTimer
suspend fun dbCall() {
    repository.someQuery().awaitFirst() // suspension point
}

In this case I'd like to know the full time spent on dbCall function, marked with a custom @CoroutineTimer annotation. Is there a way do so?

0 Answers
Related