PersistenceHealth

data class PersistenceHealth(val acknowledged: Long = 0, val failed: Long = 0, val outstandingFailures: Long = 0, val recoveryFailed: Boolean = false, val lastFailure: Throwable? = null)

Whether an exporter is managing to save its data locally.

Counts complete persistence turns, not records, series, bytes, or individual store calls. A turn is acknowledged only after all its writes return; a partial write is one failed turn.

For metrics a turn is one kind's write. WarpMetricExporter persists each of its five kinds under its own key, so a WarpMetricExporter.record batch counts one turn per kind it touched: five updates over three kinds is three turns, not one and not five. A batch the store partly refuses therefore moves both counters — acknowledged for each kind that landed, failed for each that did not — and a cancelled batch keeps the turns of the kinds already written. A single-point mutator is a one-kind batch, so it is still one turn.

For spans a turn's verdict is per work key too, once the causal clock's work fails. A WarpSpanExporter.export or WarpSpanExporter.clear whose writes all run is one turn over the span buffer and its clock together. One that skips the clock's write, because the clock's read has not landed, or an export that wanted a dot from a clock with none left (ClockTick.Exhausted) and saved its span unstamped, counts its span work by the span write and its clock work as one failed turn under the clock's key (#3426). So a clock refused forever stays in outstandingFailures however many spans land, until a turn lands the clock's write. An exhausted clock counts once per export that wanted a dot; a turn that wanted none (a clear, a span with its own stamp) is not counted, and its clock write resolves those failures. A refused clock write fails the whole turn, since the span write after it is never made. Metric WarpMetricExporter.clear counts its entire delete sequence as a separate turn. Reads, validation failures before persistence, and success without store IO do not count. These counters live only for this exporter instance; they do not measure backend delivery.

Samples

val telemetry = WarpTelemetry(ReplicaId("device"), InMemoryDurableStore())
telemetry.recover()
telemetry.metrics.incrementSum(MetricKey("requests", MetricKind.SUM))

val health = telemetry.health
check(health.metrics.acknowledged == 1L)
check(health.metrics.outstandingFailures == 0L)
check(!health.metrics.recoveryFailed)
// Logs keep record units. No log records have been admitted by this instance.
check(health.logs.accepted == 0L)
check(health.spans.acknowledged == 0L)

Constructors

Link copied to clipboard
constructor(acknowledged: Long = 0, failed: Long = 0, outstandingFailures: Long = 0, recoveryFailed: Boolean = false, lastFailure: Throwable? = null)

Properties

Link copied to clipboard

Successfully completed persistence turns, cumulative.

Link copied to clipboard

Failed persistence turns, cumulative. A span write turn that returns ExportResult.Failure without writing, because the store still refuses the read of the stored spans (WarpSpanExporter.recover), is a failed turn too, and the first span write that lands resolves it.

Link copied to clipboard

Most recent persistence or recovery cause, retained after success.

Link copied to clipboard

Failed turns whose persistence work has not subsequently succeeded. A metric write clears failures only for its own persisted kind (integer and double sums are separate); a metric clear clears only failed clears. A span-only merge cannot clear a failed turn that also required the causal clock, nor a failed clock turn; only a turn that lands the clock's write does. This is not a global consecutive-failure streak: unrelated success leaves these failures outstanding.

Link copied to clipboard

Whether a read or decode of persisted state failed: at recover(), or on a later retry of a read that had been refused, which a span write turn or a causal clock's stamp makes. Sticky, even after the read and writes succeed. The failed read does not itself increment failed or outstandingFailures; a write turn it stops does, as failed says.