Package-level declarations

Types

Link copied to clipboard
fun interface AppliedOpSink

Where WarpLogRecordExporter publishes the operations it applied.

Link copied to clipboard

Controls what happens when the in-memory CRDT buffer reaches maxSpans.

Link copied to clipboard
@Serializable
data class CausalStamp(val dot: Dot, val predecessors: Set<Dot>)

A span's position in kuilt's happens-before relation.

Link copied to clipboard
sealed interface ClockPersist
Link copied to clipboard
sealed interface ClockRecovery
Link copied to clipboard
sealed interface ClockTick
Link copied to clipboard
sealed interface DrainResult

The result of a WarpOtlpBridge.drain call.

Link copied to clipboard
data class ExporterHealth(val accepted: Long = 0, val failed: Long = 0, val consecutiveFailures: Int = 0, val lastFailure: Throwable? = null, val recoveryFailed: Boolean = false, val dropped: Long = 0, val refused: Long = 0)

An out-of-band health signal for a durable exporter.

Link copied to clipboard
sealed interface ExportResult
Link copied to clipboard
class LogDigest(val recordIds: Set<ByteString>)

Which log records the producer has already delivered to an OtlpEdge, keyed by LogRecord.recordId.

Link copied to clipboard
@Serializable
data class LogRecord(val recordId: ByteString, val severityNumber: Int? = null, val severityText: String? = null, val body: String? = null, val attributes: Map<String, String> = emptyMap(), val timestampEpochNanos: Long? = null, val observedEpochNanos: Long? = null, val traceId: ByteString? = null, val spanId: ByteString? = null)

A single log-record shaped to round-trip through OTLP.

Link copied to clipboard

Controls what happens when the number of distinct metric series in WarpMetricExporter reaches maxMetrics.

Link copied to clipboard
@Serializable
class MetricCatalog(val sums: Map<MetricKey, GCounter> = emptyMap(), val doubleSums: Map<MetricKey, GCounterDouble> = emptyMap(), val gauges: Map<MetricKey, LWWRegister<Double>> = emptyMap(), val cardinalities: Map<MetricKey, HyperLogLog> = emptyMap(), val histograms: Map<MetricKey, DDSketch> = emptyMap()) : Quilted<MetricCatalog>

A converged snapshot of every metric series a device holds — counters, gauges, distinct-count estimates, and quantile sketches — bundled into one value that replicates as a whole.

Link copied to clipboard
class MetricDigest(val versions: Map<MetricKey, Long>)

The value-version this producer last delivered for each metric series.

Link copied to clipboard
sealed interface MetricExportResult

The result of WarpMetricExporter.record and of the single-point mutators built on it. Each arm says what a retry may send: counting an update twice is as wrong as dropping it.

Link copied to clipboard

A MetricOverflowException for a histogram: a MetricUpdate.RecordHistogram or MetricUpdate.AddExponentialHistogram would carry the series' total count past Long.MAX_VALUE (#3403), counting the batch's own earlier updates to it. The total is summed over every replica's slots, both signs' buckets and the zero counter, and is the count the OTLP bridge exports, so a series past it is one the bridge could not export. That includes the narrower cases of #3354: this replica's slot in a bucket, or in the zero or overflow counter, passing Long.MAX_VALUE, and counts that each fit but fold onto one bucket past it.

Link copied to clipboard
@Serializable
data class MetricKey(val name: String, val kind: MetricKind, val attributes: Map<String, String> = emptyMap())

The identity of a single metric time series.

Link copied to clipboard
@Serializable
enum class MetricKind : Enum<MetricKind>

The kind of measurement a metric tracks.

Link copied to clipboard

A kind of metric whose persisted series no read has joined into memory yet, because the store refused the read (#3390). Nothing of that kind was applied, and its store key storeKey was not written. The store's refusal is cause. It arrives in a MetricExportResult.Partial's causes or as a MetricWriteResult.Failure's cause; only the exporter constructs one.

Link copied to clipboard

Why a WarpMetricExporter.record was refused: an update would carry the series key's total over every replica past Long.MAX_VALUE. The total is what the OTLP bridge exports, so a series past it is one the bridge skips. The narrower case, this replica's own slot passing Long.MAX_VALUE, is part of it: a wrapped slot would be negative, and a counter's merge, a max, would drop it, so the update would be lost everywhere with nothing to say so. It arrives as a MetricExportResult.Refused, and the batch that carried it applied nothing.

Link copied to clipboard
sealed interface MetricPoint

A single metric data point, rendered from a WarpMetricExporter CRDT (via MetricCatalog) into the shape OTLP puts on the wire. The bridge produces these; an OtlpEdge serializes them — the edge never reaches into the CRDTs directly.

Link copied to clipboard

A MetricOverflowException for a sum: an increment would carry the sum series key's total past Long.MAX_VALUE (#3445), counting the batch's own earlier increments to it. The total is summed over every replica's slot, a peer's merged in included, and is the value the OTLP bridge exports, so a series past it is one the bridge could not export. That includes the narrower case of #3318, this replica's own slot passing Long.MAX_VALUE.

Link copied to clipboard
sealed interface MetricUpdate

One local change to a WarpMetricExporter series, as a value — the element of a batch handed to WarpMetricExporter.record.

Link copied to clipboard
sealed interface MetricWriteResult

The result of a merge* on WarpMetricExporter, or of WarpMetricExporter.clear. A merge is a lattice join and a clear is a delete, so either may always be called again: a second merge of the same state changes nothing, and a second clear deletes what the first could not.

Link copied to clipboard
interface OtlpEdge

An OTLP-capable edge that WarpOtlpBridge drains converged CRDTs into.

Link copied to clipboard
enum class OtlpSignal : Enum<OtlpSignal>

One of the three OTLP signals WarpOtlpBridge drains.

Link copied to clipboard
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.

Link copied to clipboard
data class SignalFailure(val signal: OtlpSignal, val cause: Throwable)

One signal's failure within a WarpOtlpBridge.drain.

Link copied to clipboard
class SpanDigest(val spanIds: Set<ByteString>)

A compact summary of which spans this producer has already delivered to an OtlpEdge, keyed by span id.

Link copied to clipboard
@Serializable
enum class SpanKind : Enum<SpanKind>

OTLP span kind values.

Link copied to clipboard
data class SpanLink(val fromSpanId: ByteString, val linkedTraceId: ByteString, val linkedSpanId: ByteString, val attributes: Map<String, String> = mapOf("kuilt.causality" to "potential"))

A derived causal edge: span fromSpanId could have been caused by the predecessor span identified by linkedTraceId / linkedSpanId.

Link copied to clipboard
@Serializable
data class SpanRecord(val traceId: ByteString, val spanId: ByteString, val parentSpanId: ByteString?, val name: String, val kind: SpanKind, val startEpochNanos: Long, val endEpochNanos: Long, val attributes: Map<String, String> = emptyMap(), val status: SpanStatus = SpanStatus.Unset, val causalStamp: CausalStamp? = null)

A completed span record, shaped to round-trip through OTLP.

Link copied to clipboard
@Serializable
sealed interface SpanStatus

OTLP span status.

Link copied to clipboard
data class TelemetryHealth(val spans: PersistenceHealth, val metrics: PersistenceHealth, val logs: ExporterHealth)

Health of the local telemetry buffers, in each signal's own units.

Link copied to clipboard
class WarpCausalClock(replica: ReplicaId)

Mints causal Dots for spans and tracks the current happens-before frontier.

Link copied to clipboard
class WarpLogRecordExporter(replica: ReplicaId, store: DurableStore, maxRecords: Int = DEFAULT_MAX_LOG_RECORDS, bufferPolicy: BufferPolicy = BufferPolicy.DROP_OLDEST, segmentOps: Int = DEFAULT_LOG_SEGMENT_OPS, appliedOps: AppliedOpSink = AppliedOpSink.Discarding)

A CRDT-backed log-record exporter.

Link copied to clipboard
class WarpMetricExporter(replica: ReplicaId, store: DurableStore, maxMetrics: Int = DEFAULT_MAX_METRICS, bufferPolicy: MetricBufferPolicy = MetricBufferPolicy.DROP_OLDEST, histogramPrototype: DDSketch = DDSketch.empty(relativeAccuracy = alphaForOtlpScale(DEFAULT_OTLP_HISTOGRAM_SCALE)))

A CRDT-backed metric exporter for cumulative sums, gauges, cardinality estimates, and exponential histograms.

Link copied to clipboard
class WarpOtlpBridge(telemetry: WarpTelemetry, clock: Clock)

Drains converged CRDTs — spans, logs, and metrics — to an OTLP-capable OtlpEdge, reconciling each signal by its own producer-local digest so a re-drain sends only records absent from that digest.

Link copied to clipboard
class WarpSpanExporter(replica: ReplicaId, store: DurableStore, maxSpans: Int = DEFAULT_MAX_SPANS, bufferPolicy: BufferPolicy = BufferPolicy.DROP_OLDEST, causalClock: WarpCausalClock? = null)

A CRDT-backed span exporter.

Link copied to clipboard
class WarpTelemetry(replica: ReplicaId, store: DurableStore, maxSpans: Int = DEFAULT_MAX_SPANS, maxLogRecords: Int = DEFAULT_MAX_LOG_RECORDS, bufferPolicy: BufferPolicy = BufferPolicy.DROP_OLDEST, maxMetrics: Int = DEFAULT_MAX_METRICS, metricBufferPolicy: MetricBufferPolicy = MetricBufferPolicy.DROP_OLDEST)

A CRDT-backed, offline-first telemetry surface for Kotlin Multiplatform.

Properties

Link copied to clipboard
const val DEFAULT_LOG_SEGMENT_OPS: Int = 256

Default operations per persisted log segment — the ceiling on how many bytes one WarpLogRecordExporter.export rewrites, outside the one whole-log adopt an export owes after a refused merge.

Link copied to clipboard

Maximum number of LogRecords buffered in memory before eviction.

Link copied to clipboard

Default maximum number of distinct metric series buffered in memory.

Link copied to clipboard

Maximum number of SpanRecords buffered in memory before eviction.

Link copied to clipboard

The default OTLP scale for WarpMetricExporter histograms. Scale 5 gives α ≈ 1.083% — the closest OTLP-aligned accuracy to DDSketch.DEFAULT_RELATIVE_ACCURACY (1%), at ≈32 buckets per power of two.

Link copied to clipboard

Largest OTLP exponential-histogram scale (base 2^(2^−20) — ~0.000033% relative accuracy).

Link copied to clipboard

Smallest supported OTLP exponential-histogram scale (base 2^32, α ≈ 1 − 4.7·10⁻¹⁰). OTLP itself permits scales down to −10, but below −5 the equivalent DDSketch α rounds to 1.0 in a Double (and at −10 the base 2^1024 overflows entirely), so no valid sketch exists for those scales.

Functions

Link copied to clipboard

The DDSketch relative accuracy α that aligns exactly with the OTLP exponential-histogram scale: α = (γ−1)/(γ+1) where γ = 2^(2^−scale).

Link copied to clipboard

Derive SpanLinks from the happens-before relation recorded in each span's SpanRecord.causalStamp.

Link copied to clipboard
fun otlpScaleFor(relativeAccuracy: Double): Int

The integer OTLP scale whose base equals a DDSketch's bucket growth factor γ = (1+relativeAccuracy)/(1−relativeAccuracy) — the inverse of alphaForOtlpScale.