OtlpEdge

interface OtlpEdge

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

The contract is intentionally minimal so the bridge stays decoupled from any specific transport: the edge exposes what it already has (digest) and accepts what it is missing (send).

Keep :kuilt-core types off this surface. The bridge consumes Seam and Loom as an implementation detail; neither leaks through here. Consumers depend on :kuilt-otel; they should not need to depend on :kuilt-core just to wire up a backend.

A throw from any of these methods fails that signal's leg of the drain and no other, and a CancellationException this edge mints at a live caller, from its own withTimeout say, is reported the same way: as that leg's SignalFailure (#3392).

A send can fail after delivering part of its batch: an edge that splits a batch into several requests stops at the first one refused. It throws all the same, so WarpOtlpBridge reports that signal as failed with a count of 0, although the collector holds the part that went through. Such an edge tries to record the delivered part in its digest before it throws, so the next drain sends only the rest. That write can fail too: the edge then throws the send's own failure with the write's attached as suppressed, and the next drain resends the delivered part.

Implementations

  • A Ktor HTTP client that POSTs to POST /v1/traces (OTLP/HTTP protobuf).

  • A test double (us.tractat.kuilt.otel package's RecordingEdge in tests).

Samples

// OtlpEdge is the interface you implement to point the bridge at your backend.
// The bridge calls digest() to learn what the edge already has, then send() for the delta.
//
// Example skeleton — replace with real Ktor HTTP or gRPC:
//
// class KtorOtlpEdge(private val endpoint: String) : OtlpEdge {
//     override suspend fun digest(): SpanDigest {
//         val ids = httpClient.get("$endpoint/v1/traces/digest").body<Set<ByteString>>()
//         return SpanDigest(ids)
//     }
//     override suspend fun send(spans: Set<SpanRecord>, links: List<SpanLink>) {
//         httpClient.post("$endpoint/v1/traces") { setBody(spans.toOtlpJson(links)) }
//     }
// }

Functions

Link copied to clipboard
abstract suspend fun digest(): SpanDigest

Returns a compact summary of which spans this producer has already delivered to the edge (producer-local — see SpanDigest).

Link copied to clipboard
open suspend fun logDigest(): LogDigest

Which log records this producer has already delivered (producer-local; see LogDigest).

Link copied to clipboard
open suspend fun metricDigest(): MetricDigest

The value-version this producer last delivered per series (producer-local; see MetricDigest).

Link copied to clipboard
open suspend fun retainMetrics(live: Set<MetricKey>)

Forget what this edge recorded for every series not in live: the series the producer still holds. Without it, a series dropped by the maxMetrics cap or a clear() stays in the edge's record forever, so under attribute churn the record grows with every series ever sent.

Link copied to clipboard
abstract suspend fun send(spans: Set<SpanRecord>, links: List<SpanLink> = emptyList())

Push a batch of spans to the edge, with their inferred causal links.

Link copied to clipboard
open suspend fun sendLogs(logs: Set<LogRecord>)

Push a batch of log records to the edge. Delivery deduplication relies on the collector applying records idempotently by record id; WarpOtlpBridge only sends records absent from logDigest.

Link copied to clipboard
open suspend fun sendMetrics(points: Set<MetricPoint>)

Push a batch of metric data points to the edge. WarpOtlpBridge only sends points whose value-hash differs from metricDigest.