SpanRecord
A completed span record, shaped to round-trip through OTLP.
This is kuilt's KMP-native representation of an OpenTelemetry span. It is intentionally minimal: the fields map 1-to-1 to OTLP's Span proto message so a WarpOtlpBridge can serialize them directly with no further transformation.
traceId and spanId carry raw bytes matching the OTLP protobuf wire format:
traceId— 16 bytes (128-bit), matches OTLP proto3bytes trace_id.spanId— 8 bytes (64-bit), matches OTLP proto3bytes span_id.parentSpanId— 8 bytes for child spans;nullfor root spans.
ByteString is used rather than ByteArray because the ORSet inside WarpSpanExporter keys by element equality — ByteString provides content-based equals/hashCode for the byte fields of the full SpanRecord value.
The ORSet inside WarpSpanExporter compares full records, including causalStamp, rather than keying by spanId alone. Merging the same saved snapshot is idempotent. Retrying an unstamped export can mint a different stamp: if an earlier write committed but reported failure or cancellation, recovery followed by retry can retain distinct stamped copies with the same span id. Digest reconciliation filters by span id; it does not coalesce these local values.
Honest limits
Clock skew. startEpochNanos and endEpochNanos are the producer's local clock. Long-offline devices may produce timestamps far in the past. A hybrid logical clock (HLC) offset could be estimated on reconnect, but is not yet implemented — this is filed as a follow-up.
Late traces. Spans that straddle an offline and an online producer only assemble into a complete trace when the offline half syncs. OTLP collectors accept late spans within an assembly window (typically 10 min–1 hr); spans that miss the window are indexed as orphaned roots.
Constructors
Properties
Key/value string attributes.
Optional happens-before position for causal-link inference.
Epoch-nanosecond end timestamp from the producer's local clock.
Parent span id (8 bytes), or null for root spans.
64-bit span id as raw bytes (8 bytes). Matches OTLP proto3 bytes span_id.
Epoch-nanosecond start timestamp from the producer's local clock.
Span status.
128-bit trace id as raw bytes (16 bytes). Matches OTLP proto3 bytes trace_id.