Skip to content

fix(otel): sync OTEL_METRICS_KNOWN_FIELD_LIST with emitted keys (#1723)#1724

Open
prabhaks wants to merge 1 commit into
parseablehq:mainfrom
prabhaks:fix/1723-known-field-list
Open

fix(otel): sync OTEL_METRICS_KNOWN_FIELD_LIST with emitted keys (#1723)#1724
prabhaks wants to merge 1 commit into
parseablehq:mainfrom
prabhaks:fix/1723-known-field-list

Conversation

@prabhaks

@prabhaks prabhaks commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What

Fixes #1723.

compute_series_hash in src/otel/metrics.rs treats every top-level data-point key that is not in OTEL_METRICS_KNOWN_FIELD_LIST as a series label. The list had drifted from the keys the flatteners actually emit, in both directions, corrupting physical-series identity for metrics.

Emitted but missing from the list (series fragmentation)

These are emitted as top-level keys but were absent from the list, so their per-sample values were hashed into __series_hash, splitting one physical series into many:

  • min, max — histogram per-sample statistics (flatten_histogram)
  • data_point_quantile_values — summary quantile array (flatten_summary)

Listed but never emitted top-level (dead entries, with collision risk)

  • value, quantile — only ever emitted nested inside the data_point_quantile_values objects, never as top-level keys. Because they were listed, a user attribute literally named value or quantile was silently excluded from series identity, merging distinct series. value is a common label name, so this was the higher-risk one.
  • data_point_quantile_values_quantile, data_point_quantile_values_value — never emitted anywhere. Harmless dead entries, removed for correctness.

Change

  • Add min, max, data_point_quantile_values to the list.
  • Remove value, quantile, data_point_quantile_values_quantile, data_point_quantile_values_value.
  • List length 37 -> 36.
  • Tests: differing min/max (histogram) and data_point_quantile_values (summary) no longer change compute_series_hash; a data-point attribute named value or quantile now does; plus a guard asserting the list contents and length.

Verification

  • cargo test --lib otel::metrics: 10 passed, 0 failed.
  • cargo clippy --no-deps -- -D warnings: clean.
  • Cross-checked the full set of top-level keys emitted by every flattener (number/gauge/sum/histogram/exp-histogram/summary, exemplars, flags, aggregation temporality, metric-level and resource/scope envelope fields) against the updated list: they now correspond 1:1, with no missing keys and no dead entries.

Note

min/max are emitted with bare (un-prefixed) names, unlike the other data_point_* stats. This PR only syncs the known-field list with what is currently emitted. Renaming them to data_point_min/data_point_max for consistency and to remove the (smaller) collision surface would be a separate, output-schema-changing follow-up worth discussing.

Summary by CodeRabbit

  • Bug Fixes
    • Improved metric series identification for histogram and summary data.
    • Histogram minimum and maximum values, along with summary quantile values, are now handled correctly without creating unintended series.
    • Metric attributes named value or quantile are now preserved correctly when used as labels.
    • Added validation to ensure metric field handling remains consistent.

…eablehq#1723)

compute_series_hash treats any top-level data-point key not in
OTEL_METRICS_KNOWN_FIELD_LIST as a series label, so the list must match
the keys the flatteners actually emit. It had drifted both ways:

- Emitted but missing (fragmented series): `min` and `max` (histogram
  per-sample stats) and `data_point_quantile_values` (summary quantile
  array). Their per-sample values leaked into __series_hash, splitting a
  physical series into many.
- Listed but never emitted as top-level keys (dead entries): `quantile`
  and `value` (only emitted nested inside data_point_quantile_values),
  plus the never-used data_point_quantile_values_quantile /
  data_point_quantile_values_value. `value`/`quantile` also risked
  collisions: a user attribute of that name was silently dropped from
  series identity, merging distinct series.

Add the 3 missing keys, remove the 4 dead ones (length 37 -> 36), and
add tests for min/max and quantile-value fragmentation plus the
value/quantile collision.
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 805279c0-d761-44e0-8606-2151eb40e84d

📥 Commits

Reviewing files that changed from the base of the PR and between 5acfcb6 and 5c90805.

📒 Files selected for processing (1)
  • src/otel/metrics.rs

Walkthrough

The OTEL known-field list was synchronized with emitted metric keys. Histogram min/max and summary quantile values are excluded from series identity, while top-level value and quantile attributes remain series labels. Tests cover the updated behavior.

Changes

OTEL series identity

Layer / File(s) Summary
Align known metric fields
src/otel/metrics.rs
The known-field list length and entries now match emitted top-level metric fields, including histogram min/max and summary data_point_quantile_values.
Validate series-hash classification
src/otel/metrics.rs
Tests verify sample fields do not alter series hashes, top-level value and quantile attributes do alter them, and the field list matches emitted keys.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

I’m a rabbit with a tidy hash,
Sorting fields in a metrics stash.
Min and max now hop away,
Labels keep their names in play.
Quantiles bloom, collisions dash!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly matches the main fix: syncing OTEL_METRICS_KNOWN_FIELD_LIST with emitted metric keys.
Description check ✅ Passed The PR description covers the bug, fix strategy, key changes, and verification, with only the optional checklist omitted.
Linked Issues check ✅ Passed The changes and tests align with #1723 by adding/removing the specified keys, updating the length, and covering the required hash behavior.
Out of Scope Changes check ✅ Passed The patch stays focused on syncing the known-field list and related tests, with no unrelated code changes evident.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: OTEL_METRICS_KNOWN_FIELD_LIST out of sync with emitted keys (metric series fragmentation and collision)

1 participant