recover

suspend fun recover()

Recover persisted span state from store. Call once at startup before any calls to export.

If no persisted state exists, the exporter starts with an empty set. The stored set is joined with whatever is already in memory, then evicted to maxSpans, so a recovery never drops a live span, nor a stored one beyond what the cap requires.

A refused read fails closed (#3390). A refused read includes a CancellationException the store mints at this live caller, from its own withTimeout, say; a cancellation of the caller's own job still propagates (#3388). It is recorded as a recovery failure, and until a read lands every write turn (export, merge, clear) makes the read first and, while it is still refused, returns ExportResult.Failure without writing, so it never replaces spans it could not see. Such a turn counts as a failed turn in health, resolved by the first write that lands. A refused export adds its span nowhere; a remote set merged meanwhile stays in memory, and the read that lands joins it with the stored set. An exporter nobody recovered reads on its first write turn the same way.

The turns' re-reads back off, counted in write turns (#3436): after k refused reads in a row, the next 2^k − 1 turns, k capped at 6 so at most 63, refuse as a refused read does, with its cause and as a failed turn, without touching the store. A long outage then costs one read of the whole span blob per 64 turns rather than one per turn, each paying the store's timeout. This call is an explicit request, so it always reads, window or not. A refusal here counts toward k like any other, and the read that lands, here or in a turn, ends the window for good, since a recovered exporter never reads again.

An undecodable entry is recorded as a recovery failure and starts the exporter fresh: no later read could do better, and the next write replaces it.