Repository navigation
feat: Support heatmaps on prometheus histograms - #3332
Conversation
🦋 Changeset detectedLatest commit: df47699 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR Review
3 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 3 minor 3 posted as inline comment(s) on the changed lines. Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
|
cc8eaa1 to
15bc2b3
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Deep ReviewScope: PromQL histogram heatmap mode — new Intent (soft framing): render pre-bucketed Prometheus histograms as a distribution heatmap, one row per Most of the prior review thread is already resolved in the current code: the non-monotonic de-accumulation inflation ( 🟡 P2 — recommended
🔵 P3 nitpicks (2)
Reviewers (8 dimensions): correctness, testing, maintainability, typescript, performance, adversarial, previous-comments, project-standards. Findings were verified directly against the current diff and the prior-comment thread. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
E2E Test Results✅ All tests passed • 410 passed • 1 skipped • 1324s
Tests ran across 4 shards in parallel. |
947f2ae to
ba5d7a4
Compare
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
ba5d7a4 to
c3a3e6d
Compare
| } | ||
| return numberFormat | ||
| ? formatNumber(bound, { ...numberFormat, average: true }) | ||
| : COMPACT_NUMBER_FORMAT.format(bound); |
There was a problem hiding this comment.
🔵 minor — Bucket bounds with no number format are rounded to 2 significant digits, so adjacent bounds can share a label
The doc comment says this keeps the digits that tell adjacent bounds apart, but notation: 'compact' with no digit options rounds to 2 significant digits. Bounds 1000/1050/1100 come out as 1K/1.1K/1.1K, so the tooltip reads 1.1K – 1.1K, and 2.25 is shown as 2.3. Use a bound-specific formatter instead, e.g. compact notation with maximumSignificantDigits: 4 (or roundingPriority: 'morePrecision' with maximumFractionDigits), and add a test case such as formatBucketRange([1000, 1050, 1100], 2, …).
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| Number(await heatmap.hoveredTooltipValue('Count Value')), | ||
| ).toBeGreaterThan(0); | ||
| expect(await heatmap.hoveredTooltipValue('Bucket')).toMatch( | ||
| /^(0 – 0\.1|0\.1 – 0\.5|0\.5 – 1|> 1)\b/, |
There was a problem hiding this comment.
🔵 minor — The e2e bucket regex expects a lowest-bucket label the code never produces
formatBucketRange labels row 0 ≤ 0.1 (see the unit test in heatmapAxis.test.ts), not 0 – 0.1. The test passes only because hoverPopulatedCell scans from the top and hits the > 1 row first. Change the alternative to ≤ 0\.1 so the assertion still holds if hover order or the seed data changes.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| }) { | ||
| const options = allowHistogram ? PROMQL_MODE_OPTIONS : BUILDER_MODE_OPTIONS; | ||
| const isOfferedMode = (value: string): value is M => |
There was a problem hiding this comment.
🔵 minor — The generic M and the allowHistogram flag can disagree, so the type guard is unsound
<HeatmapModeControl<HeatmapMode> allowHistogram onModeChange={…}> type-checks, but isOfferedMode would narrow 'histogram' to HeatmapMode and pass it to a builder handler. Derive the options from the type instead, e.g. overloads or a discriminated prop ({ allowHistogram: true; onModeChange: (m: PromqlHeatmapMode) => void } | { allowHistogram?: false; onModeChange: (m: HeatmapMode) => void }), so an invalid combination can't be written.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
c3a3e6d to
9b54f3d
Compare
9b54f3d to
df47699
Compare
Summary
This PR adds a new heatmap mode ("histogram") for Prometheus metrics intended to support displaying pre-bucketed histogram-type data as a heatmap.
This is a distribution-type histogram (y-axis is numeric buckets, color is count of observations), but with the buckets pre-computed in the metric. The bounds are taken from the
le(less than or equal to) labels on each metric, and the counts are the (de-accumulated) values of the metric.Users should
sum by (le) (...expression)to sum by bounds across series.Screenshots or video
How to test locally
References