AddExponentialHistogram
Add one interval's already-bucketed measurements to the histogram for key, in the shape of an OTLP ExponentialHistogramDataPoint — what an OpenTelemetry SDK exports for an exponential histogram under delta temporality.
OTLP bucket offset + i at scale covers (base^(offset+i), base^(offset+i+1)] with base = 2^(2^−scale), and holds counts[i] values; zeroCount values were zero. Negative buckets index the magnitude, mirrored. The counts are added to the series, the weighted form of RecordHistogram, so applying the same update twice counts it twice, as with IncrementSum.
The exporter keeps one scale, WarpMetricExporter.histogramScale. A scale at or above it maps exactly: equal re-indexes, finer merges 2^(scale − histogramScale) buckets into one. A scale below it cannot be split without losing the sketch's accuracy guarantee, so WarpMetricExporter.record refuses the whole batch that holds one, applying nothing. That check needs the exporter, so it is not made here.
An OTLP point's sum, min, max and exemplars have no field here: a DDSketch does not keep them.
Throws
Samples
val exporter = WarpMetricExporter(
replica = us.tractat.kuilt.crdt.ReplicaId("server-1"),
store = InMemoryDurableStore(),
)
val latency = MetricKey("request.latency.ms", MetricKind.EXPONENTIAL_HISTOGRAM)
// OTLP buckets 160..162 at the exporter's own scale: 3 + 0 + 5 values, plus 2 zeros.
val interval = MetricUpdate.AddExponentialHistogram(
latency,
scale = exporter.histogramScale,
zeroCount = 2L,
positiveOffset = 160,
positiveCounts = listOf(3L, 0L, 5L),
negativeOffset = 0,
negativeCounts = emptyList(),
)
exporter.record(listOf(interval))
exporter.record(listOf(interval)) // a delta: the next interval adds, it does not replace
check(exporter.histogramSnapshot(latency).count == 20L)