clear

suspend fun clear(): ExportResult

Empty every signal's buffer and its persisted state — the supported reset (#2208).

Callable on a live instance: no restart, no per-platform directory delete. The same instance keeps exporting into the cleared store afterwards.

Best-effort across signals, and not atomic. Every signal is attempted even if an earlier one failed, and the first failure is returned — unlike WarpOtlpBridge.drain, which tolerates a partial success, because a half-cleared store is a result the caller has to see rather than one to paper over.

The three signals differ in what a clear guarantees against a peer, and the difference is structural rather than an omission:

  • logs and spans suppress what they drop, so a peer holding the pre-clear ops cannot push them back through a merge.

  • metrics can only forget locally — a monotonic join has no merge-safe forget, so a merge restores the old values. See WarpMetricExporter.clear.

The causal clock's frontier is emptied and its seq left alone — by WarpSpanExporter.clear, which owns the clock, so a caller reaching that exporter directly gets the same treatment. This facade adds nothing there.

Samples

val telemetry = WarpTelemetry(
    replica = ReplicaId("device-uuid-here"),
    store = InMemoryDurableStore(),
)
telemetry.recover()

when (val result = telemetry.clear()) {
    is ExportResult.Success -> println("store emptied; the same instance keeps exporting")
    is ExportResult.Failure -> println("clear failed: ${result.cause}; retry converges")
}