DispatcherMetrics

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

Link copied to clipboard

number of segments that finished by throwing (including cancellation).

Link copied to clipboard

number of TraceEvent.Finished events.

Link copied to clipboard

dispatcher label the events carried.

Link copied to clipboard

longest single segment observed.

Link copied to clipboard

highest number of segments observed running at the same time.

Link copied to clipboard

segments queued and not yet started: max(0, queued - started).

Link copied to clipboard

number of TraceEvent.Queued events.

Link copied to clipboard

distribution of the time blocks waited before starting.

Link copied to clipboard

segments currently running: started - finished, never negative.

Link copied to clipboard

distribution of how long each segment ran.

Link copied to clipboard

number of TraceEvent.Started events.

Link copied to clipboard

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

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Derives heuristic PoolSignals from these metrics using thresholds.

Link copied to clipboard
open override fun toString(): String