Skip to content

test(ingest, storage): label sets whose values hold separators or quotes stay different series - #896

Draft
zzylol wants to merge 1 commit into
feat/collector-state-lineagefrom
fix/series-key-escaping
Draft

zzylol wants to merge 1 commit into
feat/collector-state-lineagefrom
fix/series-key-escaping

Conversation

@zzylol

@zzylol zzylol commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem. The collector built its series key by joining labels as name=value; without escaping, so {a="b", c="d"} and {a="b;c=d"} had the same key and became one series there (fixed in Series key: write each label set as Prometheus' Labels.String(), so values holding ; or = never merge series ASAPCollector-public#65). The question for this repo was whether the backend has the same flaw.
  • Change. It does not. The backend never joins labels into one text: view states are grouped by the label map (LabelSet, a BTreeMap), the series interner hashes length-prefixed name/value pairs and compares the pairs, and the identity text is the label map's canonical JSON. This PR adds tests only. They pin that behavior for the label sets in the collector's series-key vectors.
  • Effect. No behavior changes. 3 new tests pass on the base. The 12 label sets of the collector's vectors that are already Prometheus label sets decode as 12 view-state series and 12 raw series, each with exactly its labels. 7 colliding sets intern as 7 series whose identity texts read back exactly.

Review guide

Behavior: before → after

A collector sends two view states in one request: one series with attributes a="b", c="d", and one with a="b;c=d".

collector (before its fix) backend (before and after this PR)
series key / identity both a=b;c=d;: one series {"__name__":"data","a":"b","c":"d","job":…} and {"__name__":"data","a":"b;c=d","job":…}: two series

This PR changes no behavior. It records that the backend side of the boundary already tells label sets apart, so the collector's fix needs no matching backend change. OTLP attributes carry the labels across the boundary, never the collector's key text.

Interfaces

None (tests and test data only).

Algorithm changes

None.

Decisions and open questions

  • Needs reviewer decision: None.
  • Decided (2026-11-30):
    • The backend keeps its series identity (label-map JSON, length-prefixed hash). Neither repo reads the other's key: the collector's key stays inside the collector process, and only OTLP attributes cross the boundary. So the two repos need not share a key format. Switching the backend identity to Prometheus text would change the persisted $promql_series_identity column and gain nothing. Rejected.
    • No persisted-format change, so no version bump. The stored identity is unchanged.

Verification

Scope Result Newly failing vs base Notes
cargo test -p otlp --lib -- separators 2 passed none new tests
cargo test -p storage --lib -- values_holding_separators 1 passed none new test
cargo fmt -p otlp -p storage + cargo clippy -p otlp -p storage --tests -- -D warnings clean —

New tests:

  • states_whose_values_hold_separators_are_different_series: each label set from the collector vectors, sent as a view-state point, is its own CollectorSeriesStates, whose labels are exactly the set plus __name__ and job.
  • samples_whose_values_hold_separators_are_different_series: the same sets as raw gauge points give as many series, each with exactly its labels.
  • values_holding_separators_are_different_series (storage): sets that collided under name=value; intern to distinct ids, and each identity text reads back (labels_of_identity, by_identity) as exactly its labels, including ", \, a newline, U+0085 and CJK.

The tests pass before and after. They were not failing first because this repo has no bug to fix.

Follow-ups

  • The tests keep only sets whose names are already Prometheus label names and whose values are not empty. The OTLP translation renames a.b to a_b and joins attributes that rename to the same label with ;, as Prometheus' OTLP receiver does. That is a deliberate merge that follows Prometheus, not a key ambiguity, so it is left as is.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf

…or escapes stay different series

The collector's series key wrote labels as `name=value;` without
escaping, so `{a="b", c="d"}` and `{a="b;c=d"}` were one series there.
The backend keys series by the label map (view states by `LabelSet`, the
interner by length-prefixed pairs, the identity text as the map's JSON),
so it already keeps them apart. These tests pin that, over the label
sets of the collector's series-key vectors (copied from
ASAPCollector-public as testdata/collector-series-keys.json).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: data plane Runtime ingestion, storage, and query-serving data paths bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant