Dispatcher Metrics
Immutable snapshot of what a StatsSink observed for one dispatcher label. A plain final class with explicit equals/hashCode/toString so fields can be added later without breaking binary compatibility.
Counters are cumulative since the sink was created or last reset. pending is derived from queued - started: a dispatcher that swallows blocks (for example a wrapped Dispatchers.Unconfined on yield()) leaves dangling TraceEvent.Queued events, so pending can overcount.
Instances are produced by StatsSink.metrics; the constructor is internal. Requires opting in to ExperimentalStructuredCoroutines.
Example:
val io = stats.metrics("io")
println("running=${io?.running} pending=${io?.pending} p95=${io?.queueDelay?.percentile(0.95)}")Properties
number of TraceEvent.Finished events.
longest single segment observed.
highest number of segments observed running at the same time.
number of TraceEvent.Queued events.
distribution of the time blocks waited before starting.
distribution of how long each segment ran.
number of TraceEvent.Started events.
distinct thread ids seen on TraceEvent.Started. Only populated when events carry thread identity, that is with TraceLevel.Coroutine on a platform that has threads. Tracking stops growing at 4096 distinct ids, so the value never exceeds 4096.
Functions
Derives heuristic PoolSignals from these metrics using thresholds.