refactor(metrics): single source of truth for summary quantile ranks/labels#791
Merged
Conversation
…labels
The SLA quantile ranks {0.50,0.90,0.95,0.99} were restated in four places
(the get_quantiles helper, and the JSON/Prometheus/OpenTelemetry emit paths),
each positionally coupled to the helper's output order, so a change to one
site could silently mislabel the emitted values. Introduce a single ordered
QUANTILES table carrying each rank plus its JSON key and Prometheus label, and
drive every emit path (and the helper) from it. Output is byte-identical.
Contributor
Author
|
@codex review |
LCOV of commit
|
There was a problem hiding this comment.
Pull request overview
Refactors Quantile summary emission to use a single, ordered quantile specification table so JSON keys, Prometheus quantile labels, and OpenTelemetry quantile ranks are all derived from the same source and cannot drift due to positional coupling.
Changes:
- Introduces a
QuantileSpectable (QUANTILES) defining rank + JSON key + Prometheus label in one place. - Updates
get_quantiles(), JSON emission, Prometheus emission, OpenTelemetry emission, and SUM-merge accumulation to iterateQUANTILES. - Fixes the
quatile→quantiletypo in theget_quantiles()helper parameter.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
samiura
approved these changes
Jun 26, 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.
Problem
The SLA quantiles pktvisor reports (
0.50,0.90,0.95,0.99) were restated in four places insrc/Metrics.h, each positionally coupled to the orderget_quantiles()produces:get_quantiles()helper (the rank list)to_json()—p50/p90/p95/p99keys assigned toquantiles[0..3]to_prometheus()— four hand-writtenLabelMaps"0.5"/"0.9"/"0.95"/"0.99"to_opentelemetry()— a separatefractions[4]{0.50,0.90,0.95,0.99}Nothing tied the emitted label to the value except array position, so changing or reordering the ranks at one site would silently mislabel the values at another. (This tidies up the
get_quantiles()helper introduced when the bulkkll_sketch::get_quantiles(fractions, n)API was removed in the datasketches 5.x upgrade.)Change
Introduce one ordered source of truth and drive every path from it:
get_quantiles()loops the table.to_json/to_prometheus/to_opentelemetryloop the table for their key/label/rank, so values and labels can never desync.0.50maps to the Prometheus label"0.5", while0.95maps to"0.95"), so emitted strings are preserved exactly rather than re-derived by formatting.Single file (
src/Metrics.h). Also fixes aquatiletypo in the helper param.Behavior
No output change — JSON keys, Prometheus
quantilelabels, and OpenTelemetryset_quantileranks are byte-identical, in the same order, including the_quantiles_sum(SUM-merge) path.Testing
unit-tests-visor-core(sketches + metrics) and the handler suites that snapshot summary output —unit-tests-handler-{net,net-v2,dns,dns-v2,flow,netprobe}— all pass (7/7), confirming identical output.🤖 Generated with Claude Code