instrumented

Wraps this provider's main, io and default dispatchers in InstrumentedDispatchers with those labels; unconfined is returned as is (see InstrumentedDispatcherProvider). Wrapping is lazy: nothing (including Dispatchers.Main) is read until the corresponding property is accessed.

Diagnostic tool, opt-in, not meant for production. Wrapping Dispatchers.IO loses its elasticity and limitedParallelism hints.

Example:

val dispatchers = DefaultDispatcherProvider.instrumented()
val repo = UserRepository(dispatchers)
repo.load()
dispatchers.stats().forEach(::println)

Rules: DISPATCH_005. See docs/BEST_PRACTICES_COROUTINES.md section 3.5.

Requires opting in to ExperimentalStructuredCoroutines.

Receiver

the provider whose dispatchers are wrapped.

Return

a provider whose main, io and default dispatchers are InstrumentedDispatchers.

See also