MetricUpdate

sealed interface MetricUpdate

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

Each variant is one of the exporter's single-point mutators spelled as data: IncrementSum is WarpMetricExporter.incrementSum, SetGauge is WarpMetricExporter.setGauge, and so on. Applying a list of them through WarpMetricExporter.record leaves the exporter in the same state as calling those mutators one by one, in order; what differs is how many durable writes that costs.

Each variant rejects at construction the arguments its CRDT would reject when applied. What a variant cannot know until it meets an exporter — AddExponentialHistogram's scale against the exporter's WarpMetricExporter.histogramScale, and whether an IncrementSum or a histogram update would carry one of the exporter's counts past Long.MAX_VALUE — WarpMetricExporter.record checks for every update before it applies any, so none leaves a batch applied half-way. The one-by-one equivalence above holds for every batch record accepts.

Remote snapshot merges (mergeSum, mergeGauge, …) are not updates — they are joins of another replica's state, and stay single calls.

Inheritors

Types

Link copied to clipboard
data class AddCardinality(val key: MetricKey, val element: String) : MetricUpdate

Add element to the distinct-count sketch for key — WarpMetricExporter.addCardinality.

Link copied to clipboard
data class AddExponentialHistogram(val key: MetricKey, val scale: Int, val zeroCount: Long, val positiveOffset: Int, val positiveCounts: List<Long>, val negativeOffset: Int, val negativeCounts: List<Long>) : MetricUpdate

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.

Link copied to clipboard
data class IncrementSum(val key: MetricKey, val by: Long = 1) : MetricUpdate

Add by to the integer sum for key — WarpMetricExporter.incrementSum.

Link copied to clipboard
data class IncrementSumDouble(val key: MetricKey, val by: Double) : MetricUpdate

Add by to the exact-precision sum for key — WarpMetricExporter.incrementSumDouble.

Link copied to clipboard
data class RecordHistogram(val key: MetricKey, val value: Double) : MetricUpdate

Record one measurement into the histogram for key — WarpMetricExporter.recordHistogram.

Link copied to clipboard
data class SetGauge(val key: MetricKey, val value: Double, val timestamp: Long) : MetricUpdate

Set the gauge for key to value at timestamp — WarpMetricExporter.setGauge.

Properties

Link copied to clipboard
abstract val key: MetricKey

The series this update changes.