Repository navigation
Conversation
…irst) Tests for moving a state's lineage out of the OTLP point attributes and into a binary frame in front of its ASAPv1 bytes in `sketch.envelope`: - envelope: pinned frame bytes for sequences 0, 1 and 300 and their round trip (the same vectors as ASAPQuery-backend's decoder), and refusals with their reason (a bare ASAPv1 state, frame version 2, unknown flags, a truncated or overflowing varint, a kind that disagrees with its sequence and base). - codec: the q01 state's point carries no lineage attributes and its sketch.envelope is `A1 00 00` + the ASAPv1 bytes; a bad frame, a bare ASAPv1 state under a metric with a producer epoch, and a framed state under a metric without one are refused. - collector_views_e2e: the golden comparison strips the epoch metadata and the full's 3-byte frame; the q01 wire fixture otlp-body.pb is the framed body (781 -> 724 bytes). Lineage::frame and Lineage::unframe are stubs here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
A collector view state's sequence and kind move from three OTLP point
attributes (asap.sequence, asap.state_kind, asap.base_sequence) into a
binary lineage frame in front of its ASAPv1 bytes in sketch.envelope:
[ 0xA1 | flags:u8 (bit 0: delta) | sequence:uleb128
| base_sequence:uleb128 (deltas only) | ASAPv1 bytes ]
0xA1 is the frame's marker (0xA) and version (1); an ASAPv1 envelope
starts with b'A' (0x41), so the two never collide. A full adds 3 bytes,
a delta below sequence 128 adds 4. The decoder refuses a bare ASAPv1
state under a metric with asap.producer_epoch (a collector from before
the frame), another frame version, unknown flags, and a kind that
disagrees with its sequence and base.
asap.producer_epoch stays Metric metadata: it is the same for every point
of the metric, so it costs ~40 bytes per metric instead of a 10-byte
varint (a random u64) per state; it would only be cheaper in the frame for
metrics of fewer than about four states.
Bytes per state, same input (the golden test's 12 s stream, three
messages of 80 states, OTLP protobuf):
no lineage 215.9 B
lineage attributes 264.6 B (+48.7, +22.6%)
lineage frame 219.7 B (+3.8, +1.8%)
The q01 one-state wire fixture goes 781 -> 724 bytes (669 without
lineage).
The golden states file is unchanged: its test strips the epoch and the
full's 3-byte frame, leaving the pre-lineage messages. The schema
constants for the three attributes are removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
asap.sequence,asap.state_kindandasap.base_sequence. On the golden test's on-time states that costs 48.7 bytes per state, +22.6 % (215.9 → 264.6 B).sketch.envelope:[0xA1 | flags | uleb128 sequence | uleb128 base (deltas only) | ASAPv1]. The producer epoch stays in the metric's metadata.Review guide
perf/collector-views-series-intern(collector_views: find a point's series by its attribute bytes (1.27 → 1.11 µs/sample) #62). Stack: … → collector_views: send late samples within retention as correction states #60 → collector_views: sequence numbers and delta emission (full, then deltas per window) #61 → collector_views: find a point's series by its attribute bytes (1.27 → 1.11 µs/sample) #62 → this PR. collector_views: find a point's series by its attribute bytes (1.27 → 1.11 µs/sample) #62 was restacked onto collector_views: sequence numbers and delta emission (full, then deltas per window) #61 first, with the same conflict resolution as the local demo merge.8852ebbadds the tests, which fail first (Lineage::frameandLineage::unframeare stubs).ff8240ais the implementation.envelope.rsforLineage::frame,Lineage::unframeand the varint helpers. Thenotap/codec.rs:AsapMetricsView::framedandattributes_for_rowon the encode side,decode_lineageon the decode side.schema.rs, the docs updated (docs/data_model.md, thecollector_views.rsmodule doc), andotlp-body.pbregenerated.tests/golden/collector-views-states.bin: unchanged. Its test now strips the metric's epoch and each full's 3-byte frame (A1 00 00) and compares the rest. What is left is the pre-lineage message, byte for byte, so the sketch bytes are pinned as before. The frame bytes are pinned by the unit vectors and byotlp-body.pb.Behavior: before → after
The input is the golden test's 12 s stream of q01 (DDSketch α 0.05, 5 s windows). The collector emits three OTLP messages of 80 on-time states each, every one a full of epoch 42.
sketch.envelope(ASAPv1),asap.sequence=0,asap.state_kind="full"sketch.envelope=A1 00 00+ ASAPv1asap.base_sequence=2A1 01 03 02+ ASAPv1asap.producer_epochotlp-body.pb(1 state; no lineage = 669)This serves the collector-views evaluation: the cost of delta transmission should be bytes per state, not tens of bytes per state.
Interfaces
envelope.rs/// A collector view state's place in its lineage (stays). pub struct Lineage { pub producer_epoch: u64, pub sequence: u64, } +/// The first byte of a version 1 lineage frame: marker nibble 0xA, version 1. +pub const LINEAGE_FRAME_V1: u8 = 0xA1; impl Lineage { pub fn base_sequence(&self) -> Option<u64>; + /// `asapv1` behind this record's lineage frame: the bytes of its `sketch.envelope`. + pub fn frame(&self, asapv1: &[u8]) -> Vec<u8>; + /// A framed state's sequence and its ASAPv1 bytes; Err (with the reason) for a bare + /// ASAPv1 state, another frame version, unknown flags, a bad varint, or a kind that + /// disagrees with its sequence and base. + pub fn unframe(bytes: &[u8]) -> Result<(u64, &[u8]), String>; }otap/schema.rsThese constants are removed because the frame replaces the attributes. The wire format change is also the interface: see the frame layout in Summary and in
docs/data_model.md.Usage (the processor's path; checked by
view_identity_is_otlp_metric_metadataandemitted_states_match_the_golden_bytes):Algorithm changes
None. The emission order, the sequences and the delta contents are #61's. Only their encoding changes.
Decisions and open questions
sketch.envelope, with no sketchlib change. This PR deploys together with Collector views: reorder buffer, persisted incomplete marks, lineage frame in sketch.envelope ASAPQuery-backend#897: that backend refuses an unframed state under a producer epoch, and the older backend (#893) refuses framed states.u64in the frame it would be a 10-byte varint per state, which is cheaper only for metrics with fewer than about four states. Here a message has 80 states in 2 metrics.0xAmarks a frame and the low nibble is its version. ASAPv1 starts withb'A'(0x41), so a bare state from an older collector is refused explicitly and never misread. A reader refuses a version it does not know.Verification
Run locally in a separate target dir, which has since been deleted.
cargo fmt --checkcargo clippy --all-targets --features otap-engine,stream-benchmark -- -D warningscargo test --features otap-engine --lib--test collector_views_e2e --test otap_pipeline_e2e --test runtime8852ebbNew or changed tests:
lineage_frames_are_these_bytes_and_round_trippins the frame bytes for sequences 0, 1, 300 and u64::MAX. ASAPQuery-backend's decoder holds the same vectors.bad_lineage_frames_are_refusedchecks each refusal and its reason: a bare ASAPv1 state, version 2, unknown flags, a truncated or overflowing varint, a full with a sequence, and a delta whose base is wrong.a_bad_or_missing_lineage_frame_is_refused_on_decodereplacesan_inconsistent_lineage_is_refused_on_decode. It covers a bad frame, a bare state under an epoch, and a frame without an epoch.view_identity_is_otlp_metric_metadata: the point has no lineage attributes, and its envelope isA1 00 00+ ASAPv1.emitted_states_match_the_golden_bytesstrips the epoch and the frame. The golden file is unchanged.q01_otlp_body_matches_golden:otlp-body.pbwas regenerated (781 → 724 bytes).Measurement: the same 12 s stream and the same three messages. Bytes are the encoded OTLP protobuf; per state = total / 240.
Follow-ups
🤖 Generated with Claude Code
https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf