The stack-tracking-core-api module provides the basic building blocks for the Coroutine Call Tree Visualizer. It contains the annotations and interfaces used by both the compiler plugin and the runtime.
Use this annotation to mark functions that should not be instrumented by the compiler plugin.
@NonTracked
suspend fun doInternalWork() { ... }This is a CoroutineContext.Element that defines how function calls are tracked.
interface StackTrackingContext : CoroutineContext.Element {
override val key: CoroutineContext.Key<*> get() = StackTrackingContext
suspend fun <T> track(functionFqn: String, child: suspend () -> T): T
companion object Key : CoroutineContext.Key<StackTrackingContext>
}This is the low-level function that the compiler plugin injects into your code. It's usually not called manually.
suspend fun <T> stackTracked(functionFqn: String, body: suspend () -> T): TThis module is a Kotlin Multiplatform (KMP) library, supporting:
- JVM
- JS (Node.js)
- WASM (JS & WASI)
- Native (iOS, macOS, Linux, Windows, Android Native, etc.)
- WatchOS, TvOS
This allows you to instrument code across almost any Kotlin target.