Skip to content

Instantly share code, notes, and snippets.

@sftblw
Last active July 22, 2024 02:36
Show Gist options
  • Save sftblw/89423e6c7ee4e55de9f73bd582433a4a to your computer and use it in GitHub Desktop.
Save sftblw/89423e6c7ee4e55de9f73bd582433a4a to your computer and use it in GitHub Desktop.
CoroutineDebugConfig (ChatGPT's suggesstion)
import jakarta.annotation.PostConstruct
import jakarta.annotation.PreDestroy
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.debug.DebugProbes
import org.springframework.context.annotation.Configuration
// https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-debug/
@Configuration
class CoroutineDebugConfig {
@OptIn(ExperimentalCoroutinesApi::class)
@PostConstruct
fun setUp() {
DebugProbes.install()
}
@OptIn(ExperimentalCoroutinesApi::class)
@PreDestroy
fun tearDown() {
DebugProbes.uninstall()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment