From 4010d959403c07260e772a784d96713ccfd9c934 Mon Sep 17 00:00:00 2001 From: Zeying Zhu Date: Tue, 14 Apr 2026 16:01:16 -0400 Subject: [PATCH] proto: add *_ENCODING_MSGPACK / _MSGPACK_DELTA variants for all five sketches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds `_ENCODING_MSGPACK = 3` and `_ENCODING_MSGPACK_DELTA = 4` to the five per-sketch encoding enums in the modified OTLP proto patch — matching the variants landed in ASAPQuery-backend PR #9 (https://github.com/ProjectASAP/ASAPQuery-backend/pull/9) and implemented on the producer side in sketchlib-go PR #50 (https://github.com/ProjectASAP/sketchlib-go/pull/50). Before this PR the three sides of the cross-language MessagePack contract had mismatched proto enum names: * ASAPQuery-backend (Rust consumer) — already had `_MSGPACK = 3` in its vendored metrics.proto, ready to decode msgpack-encoded sketch bytes from the hot path dispatcher * sketchlib-go (Go producer) — already has `wire/asapmsgpack.Marshal*` producing bytes the Rust consumer deserializes byte-for-byte * DataCollector — lacked the enum names entirely, so processors emitting msgpack bytes had to hard-code the integer tag `3` This patch aligns the DataCollector proto with the other two, closing the naming gap. Because protobuf enums are just integer tags, the change is forward-compatible: producers and consumers that already know about tag `3` at runtime continue to interoperate whether or not the name is declared on their side of the wire. So this commit is a pure readability / discoverability win; no generated code or runtime behavior changes until a follow-up wires a processor component to actually emit the new tag. Affected enums: * `DDSketchEncoding` — adds MSGPACK=3, MSGPACK_DELTA=4 * `KLLSketchEncoding` — adds MSGPACK=3, MSGPACK_DELTA=4 (reserved; sketchlib-go KLL doesn't share a byte-level backend with ASAPQuery-backend's KLL, so MSGPACK is not usable for KLL today — use PROTO instead) * `CountSketchEncoding` — adds MSGPACK=3, MSGPACK_DELTA=4 * `CountMinSketchEncoding` — adds MSGPACK=3, MSGPACK_DELTA=4 * `HLLSketchEncoding` — adds MSGPACK=3, MSGPACK_DELTA=4 No changes to .proto message shapes, no reserved-range shifts, no impact on existing `_PROTO = 1` / `_PROTO_DELTA = 2` / `_DELTA = 2` producers and consumers. The generated `.pb.go` files and the opentelemetry-proto submodule checkout are NOT committed — they're regenerated from this patch file via `restore_otel_proto_patches.sh` at build time. Follow-ups: * `*processor` components in DataCollector that today emit only `_ENCODING_PROTO` can gain a config option to emit `_ENCODING_MSGPACK` instead, calling sketchlib-go's `wire/asapmsgpack.Marshal*` on the sketch state * `_DELTA` variants still deferred until sketch-core grows an `apply_delta` API — these enum entries exist only to reserve the tag numbers consistently with the Rust side Co-Authored-By: Claude Opus 4.6 (1M context) --- .../proto/metrics/v1/metrics.proto | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/opentelemetry-proto-patch/opentelemetry/proto/metrics/v1/metrics.proto b/opentelemetry-proto-patch/opentelemetry/proto/metrics/v1/metrics.proto index 3a909e47..7d43ccec 100644 --- a/opentelemetry-proto-patch/opentelemetry/proto/metrics/v1/metrics.proto +++ b/opentelemetry-proto-patch/opentelemetry/proto/metrics/v1/metrics.proto @@ -384,6 +384,12 @@ enum DDSketchEncoding { // github.com/DataDog/sketches-go/ddsketch/pb/sketchpb.DDSketch message. DDSKETCH_ENCODING_PROTO = 1; DDSKETCH_ENCODING_PROTO_DELTA = 2; + // DDSKETCH_ENCODING_MSGPACK indicates the sketch bytes are the MessagePack + // serialization of the cross-language sketch-core `DdSketch` struct + // (matching ASAPQuery-backend's `sketch_core::dd_sketch::DdSketch` and + // sketchlib-go's `wire/asapmsgpack.DDSketchState`). + DDSKETCH_ENCODING_MSGPACK = 3; + DDSKETCH_ENCODING_MSGPACK_DELTA = 4; } // KLLSketch represents the type of a metric that encodes measurements using the KLL quantile sketch. @@ -415,6 +421,13 @@ message KLLSketchDataPoint { enum KLLSketchEncoding { KLL_SKETCH_ENCODING_UNSPECIFIED = 0; KLL_SKETCH_ENCODING_PROTO = 1; + // KLL_SKETCH_ENCODING_MSGPACK is reserved for the cross-language + // sketch-core `KllSketch` msgpack wire format. Not currently usable + // because sketchlib-go's KLL does not share a byte-level backend + // with ASAPQuery-backend's datasketches-rs-backed `KllSketch` + // (tracked as a follow-up — for KLL today, use PROTO). + KLL_SKETCH_ENCODING_MSGPACK = 3; + KLL_SKETCH_ENCODING_MSGPACK_DELTA = 4; } // CountSketch represents the type of a metric that encodes frequency estimations using CountSketch. @@ -446,6 +459,13 @@ enum CountSketchEncoding { COUNT_SKETCH_ENCODING_UNSPECIFIED = 0; COUNT_SKETCH_ENCODING_PROTO = 1; COUNT_SKETCH_ENCODING_DELTA = 2; + // COUNT_SKETCH_ENCODING_MSGPACK indicates the sketch bytes are the + // MessagePack serialization of the cross-language sketch-core + // `CountSketch` struct (matching ASAPQuery-backend's + // `sketch_core::count_sketch::CountSketch` and sketchlib-go's + // `wire/asapmsgpack.MarshalCountSketch`). + COUNT_SKETCH_ENCODING_MSGPACK = 3; + COUNT_SKETCH_ENCODING_MSGPACK_DELTA = 4; } // CountMinSketch represents the type of a metric encoding frequency estimations using CountMinSketch. @@ -477,6 +497,13 @@ enum CountMinSketchEncoding { COUNT_MIN_SKETCH_ENCODING_UNSPECIFIED = 0; COUNT_MIN_SKETCH_ENCODING_PROTO = 1; COUNT_MIN_SKETCH_ENCODING_DELTA = 2; + // COUNT_MIN_SKETCH_ENCODING_MSGPACK indicates the sketch bytes are + // the MessagePack serialization of the cross-language sketch-core + // `CountMinSketch` wire struct (matching ASAPQuery-backend's + // `sketch_core::count_min::CountMinSketch` and sketchlib-go's + // `wire/asapmsgpack.MarshalCountMinSketch`). + COUNT_MIN_SKETCH_ENCODING_MSGPACK = 3; + COUNT_MIN_SKETCH_ENCODING_MSGPACK_DELTA = 4; } // HLLSketch represents the type of a metric that encodes cardinality estimations using HyperLogLog. @@ -508,6 +535,13 @@ enum HLLSketchEncoding { HLL_SKETCH_ENCODING_UNSPECIFIED = 0; HLL_SKETCH_ENCODING_PROTO = 1; HLL_SKETCH_ENCODING_DELTA = 2; + // HLL_SKETCH_ENCODING_MSGPACK indicates the sketch bytes are the + // MessagePack serialization of the cross-language sketch-core + // `HllSketch` struct — registers + variant + precision + HIP state + // (matching ASAPQuery-backend's `sketch_core::hll_sketch::HllSketch` + // and sketchlib-go's `wire/asapmsgpack.MarshalHLLSketch`). + HLL_SKETCH_ENCODING_MSGPACK = 3; + HLL_SKETCH_ENCODING_MSGPACK_DELTA = 4; } // AggregationTemporality defines how a metric aggregator reports aggregated