MetricTapClient

class MetricTapClient(seam: Seam, parentScope: CoroutineScope, config: MetricTapConfig = MetricTapConfig(), admission: LogTapAdmission = LogTapAdmission.Open) : ScopedCloseable

The test/harness side of a metric tap: join a device and read its metrics out.

Given a Seam already woven onto the device's session (the harness joins the same us.tractat.kuilt.core.Loom the device hosts on), a client either takes a one-shot pull of everything recorded so far or tails the metrics live as they change. The underlying replication is a converging merge, so the reconstructed numbers match the device's, even across a reconnect.

Unlike the log tap's per-record LogTapClient.tail, metrics have no per-record identity — a counter grows, a gauge is overwritten, a sketch absorbs — so the live view here is the whole converged MetricSnapshot, re-emitted whenever it changes.

Close the client to release its replicator.

Parameters

admission

how this client is admitted by the host. The default LogTapAdmission.Open matches an ungated host; pass LogTapAdmission.Present with the shown code when the host was installed with LogTapAdmission.Verify.

Constructors

Link copied to clipboard
constructor(seam: Seam, parentScope: CoroutineScope, config: MetricTapConfig = MetricTapConfig(), admission: LogTapAdmission = LogTapAdmission.Open)

Functions

Link copied to clipboard
override fun close()
Link copied to clipboard
suspend fun pull(): MetricSnapshot

Pull a snapshot of the device's metrics: wait for the host's state to replicate in and settle, then collapse each CRDT to its reported value.

Link copied to clipboard
fun tail(): Flow<MetricSnapshot>

Tail the device's metrics live: emits the whole converged MetricSnapshot each time the replicated state changes (deduped by value). The flow replays the current state on collection, then continues until the collector is cancelled.