Trace Sink
Port that receives TraceEvents. Backends (logging, ring buffers, platform tracers) implement it.
Contract every sink must follow:
emit must not throw; callers also catch and drop, so a faulty sink never breaks dispatch.
emit must be cheap and must not suspend or block; heavy work goes behind the sink's own buffer.
emit can be called concurrently from many threads.
Ordering is guaranteed per thread only, not globally. Correlate the three lifecycle events of one dispatched runnable by their non-zero
dispatchId, not by adjacency or span id.A sink may ignore unknown event subtypes (new ones can be added in later releases).
isEnabled is consulted before an event is built, so a disabled level costs no allocation.
Example:
val sink = TraceSink { event -> println(event) }Requires opting in to ExperimentalStructuredCoroutines.