DispatchInstrumentation
The seam through which tooling observes a Store without core depending on any tooling artifact.
Core emits neutral events here and holds no tracer, no timing and no event types of its own. Implementations live outside core, map these callbacks onto whatever they record, and are installed with Store.setDispatchInstrumentation. A store with nothing installed pays one null check per dispatch.
Two families of callbacks share the interface. The onDispatch* methods cover work inside the dispatch pipeline and are driven by the store itself. The onEvaluation* methods cover suspending work that happens outside the pipeline and still deserves a span, such as navigation guards and dynamic entry selectors, and are driven by whichever module performs that work after reading Store.activeDispatchInstrumentation.
Usage:
class LoggingInstrumentation : DispatchInstrumentation {
override suspend fun onDispatchStarted(
action: ModuleAction,
queueWaitMs: Long,
queueDepth: Long
): String {
println("dispatch ${action::class.simpleName} waited ${queueWaitMs}ms")
return action.toString()
}
override fun onDispatchCompleted(token: String, applied: Boolean, durationMs: Long) {
println("$token ${if (applied) "applied" else "blocked"} in ${durationMs}ms")
}
override fun onDispatchFailed(token: String, error: Throwable, durationMs: Long) {
println("$token failed: ${error.message}")
}
override suspend fun onDispatchDropped(action: ModuleAction, reason: DispatchDropReason) = Unit
override suspend fun onExternalControlChanged(enabled: Boolean) = Unit
}
store.setDispatchInstrumentation(LoggingInstrumentation())See also
to install an implementation
to read the installed one
Properties
Functions
Supplies a decorator for wrapping individual dispatch chain steps, or null to leave the chain untouched.
Called when a dispatch finishes, whether or not it changed state.
Older form of onDispatchDropped that cannot say why the action was dropped.
Called when an action is discarded without processing.
Called when a dispatch throws.
Called when the store begins processing an action.
Called when an evaluation returns normally.
Called when an evaluation throws.
Called when a remote publisher takes over authoring this store's state, or hands it back.