metricsReporter

fun <S : MVIState, I : MVIIntent, A : MVIAction> metricsReporter(metrics: Metrics, offloadScope: CoroutineScope, offloadContext: CoroutineContext = Dispatchers.Default, interval: Duration = 30.seconds, flushOnStop: Boolean = true, name: String? = DefaultName, sink: MetricsSink): StorePlugin<S, I, A>

A default Metrics collection plugin that periodically snapshots metrics and forwards them to sink, optionally flushing on stop.

This plugin supports backpressure. If the sink is slow, oldest snapshots will be dropped, reducing frequency of reporting until load normalizes.

Parameters

metrics

provider that exposes snapshots. A default provider is exposed via pro.respawn.flowmvi.metrics.dsl.metrics builder

offloadScope

scope used to launch flushing jobs AFTER store cancellation. This must NOT be the store's scope or scope that the store is launched in! See pro.respawn.flowmvi.metrics.dsl.metrics for details.

offloadContext

dispatcher for offloaded work

interval

how often to collect snapshots; set to Duration.INFINITE or 0 to disable periodic emission

flushOnStop

whether to emit one last snapshot during StorePlugin.onStop

name

optional plugin name

sink

destination pro.respawn.flowmvi.metrics.api.Sink for snapshots.


fun <S : MVIState, I : MVIIntent, A : MVIAction> metricsReporter(builder: DefaultMetrics<S, I, A>, interval: Duration = 30.seconds, flushOnStop: Boolean = true, name: String? = DefaultName, sink: MetricsSink): StorePlugin<S, I, A>

A default Metrics collection plugin that periodically snapshots metrics and forwards them to sink, optionally flushing on stop.

This plugin supports backpressure. If the sink is slow, oldest snapshots will be dropped, reducing frequency of reporting until load normalizes.

Parameters

metrics

provider that exposes snapshots. A default provider is exposed via pro.respawn.flowmvi.metrics.dsl.metrics builder

interval

how often to collect snapshots; set to Duration.INFINITE or 0 to disable periodic emission

flushOnStop

whether to emit one last snapshot during StorePlugin.onStop

name

optional plugin name

sink

destination pro.respawn.flowmvi.metrics.api.Sink for snapshots.