Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

380
Vistas
@Around aspect and Kotlin suspended function

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?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I think you can solve your problem easily, if you want to measure, the execution time of function, you can do it using built-in functionality like this:

val time = measureTimeMillis {
    // yourSuperFunc()
}

Also, you can use measureNanoTime. For full reference look at here.

over 4 years ago · Santiago Trujillo Denunciar

0

This is tracked by https://github.com/spring-projects/spring-framework/issues/22462 and will most likely be fixed in 5.3

The same issue happens for @Transactional.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda