Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

379
Visualizações
@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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda