Trace

sealed class Trace(val tags: List<String>) : CoroutineContext.Element(source)

Models a curated call stack from some root, up to this Trace node. In practice, the root will be ModuleCheckRunner.run.

This class this leverages CoroutineContext.Element in order to avoid passing a 'TraceContext' around. Trace nodes are stored in the CoroutineContext. This means that traces can only be started or added to from within a coroutine.

The simplest way to add to a trace is to make the class implement HasTraceTags to provide static tags, then use one of the traced extensions at the trace site.

class SomeClass : HasTraceTags {
override val traceTags = listOf(SomeClass::class)

suspend fun doSomethingImportant(someArgument: String) {
traced(someArgument) { /* anything happening here is wrapped in the new Trace */}
}
}

Since

0.12.0

Inheritors

Constructors

Link copied to clipboard
protected constructor(tags: List<String>)

Types

Link copied to clipboard
private class Child(val parent: Trace, val depth: Int, val tags: List<String>, val args: List<String>) : Trace
Link copied to clipboard
Link copied to clipboard
private class Root(val tags: List<String>) : Trace

Properties

Link copied to clipboard
abstract val depth: Int
Link copied to clipboard
open override val key: CoroutineContext.Key<*>
Link copied to clipboard

Functions

Link copied to clipboard
abstract fun asString(): String
Link copied to clipboard
internal fun child(vararg tags: Any, args: Iterable<Any>): Trace
internal fun child(tags: Iterable<Any>, args: Iterable<Any>): Trace
Link copied to clipboard
open override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R
Link copied to clipboard
open operator override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E?
Link copied to clipboard
open override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext
Link copied to clipboard
open operator fun plus(context: CoroutineContext): CoroutineContext
Link copied to clipboard

Unsafe-ish extension for extracting a Trace from inside a coroutine.