Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: cc8eaa1 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 |
🔴 Tier 4 — CriticalTouches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
| return { mode: 'histogram', config }; | ||
| } | ||
| return { | ||
| mode: 'calculated', |
There was a problem hiding this comment.
🟠 major — PromQL heatmap tiles saved before this change silently switch from series to distribution rendering
Before this PR, convertFormStateToSavedChartConfig stripped heatmap from PromQL tiles; the removed test was 'saves a heatmap ... and no heatmap mode'. Every PromQL heatmap saved that way has no heatmap.mode, so getHeatmapMode now returns 'distribution' and toHeatmapQuery sends it down the new calculated path. Their legend template is also hidden in the drawer. These tiles have only shipped on main so far (.changeset/promql-heatmap.md is still pending), so the cheapest fix is a one-off migration that writes heatmap: { mode: 'series' } onto existing PromQL heatmap tiles. The other option is to make a missing mode resolve to 'series' for PromQL configs only.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| } | ||
| return numberFormat | ||
| ? formatNumber(bound, { ...numberFormat, average: true }) | ||
| : COMPACT_NUMBER_FORMAT.format(bound); |
There was a problem hiding this comment.
🔵 minor — Bucket bound labels are rounded to 2 significant digits, despite the doc comment
The doc comment says adjacent bounds must not round to the same label, but COMPACT_NUMBER_FORMAT (compact notation) rounds to about 2 significant digits. So 1.05 and 1.1 both render as "1.1", 0.125 renders as "0.13", and 1024 renders as "1K", which collides with a 1000 bound in both the axis and the tooltip range. For unformatted bounds, use a formatter that keeps the bound's significant digits, e.g. Intl.NumberFormat with maximumSignificantDigits: 6, or compact with roundingPriority. Add a test case with a 3-significant-digit bound.
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
| legendTemplate: z.string().max(MAX_LEGEND_TEMPLATE_LENGTH).optional(), | ||
| heatmap: HeatmapSettingsSchema.extend({ | ||
| mode: PromqlHeatmapModeSchema.optional(), | ||
| scaleType: HeatmapScaleTypeSchema.optional(), |
There was a problem hiding this comment.
🔵 minor — The PromQL heatmap schema allows scaleType with modes that ignore it, and scale type now lives in two places
heatmap.scaleType is only read in distribution mode, yet the schema accepts it alongside series and histogram, and formPromqlHeatmap persists it unchanged. Meanwhile builder heatmaps keep their scale on select[0].heatmapScaleType, so the same concept has two storage locations that EditTimeChartForm must branch on. Option 1: make the PromQL heatmap a discriminated union on mode, with scaleType only on the distribution variant. Option 2: strip scaleType in formPromqlHeatmap when the mode is not distribution.
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
| ); | ||
| } | ||
|
|
||
| function HistogramHeatmapChart({ |
There was a problem hiding this comment.
🔵 minor — SeriesHeatmapChart, CalculatedHeatmapChart and HistogramHeatmapChart are copies of each other
The three wrappers differ only in which data hook they call. Factor them into one component that takes the hook result, or pick the hook from query.mode and render a single HeatmapChartView, so the plotKey and numberFormat wiring isn't repeated three times.
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
PR Review
5 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 4 minor 4 posted as inline comment(s) on the changed lines. 1 listed below. Findings outside the changed lines1 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
|
| if (isPromqlChartConfig(config)) { | ||
| if (mode === 'histogram') { | ||
| return { mode: 'histogram', config }; | ||
| } | ||
| return { | ||
| mode: 'calculated', |
There was a problem hiding this comment.
Previously saved PromQL heatmaps have no heatmap setting because every PromQL heatmap rendered one row per series. They now fall through to calculated, which merges their series into a distribution. Existing dashboards silently show a different kind of chart after upgrading.
Preserve series mode for old tiles through a read-time migration, and set distribution mode explicitly on new tiles.
Knowledge Base Used:
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| cells[ti * rows + r] = Math.max(0, cum - below); | ||
| below = cum; |
There was a problem hiding this comment.
Higher buckets gain extra counts
Clamping a decreasing bucket to zero still lowers below, so the next bucket gains observations already counted. Cumulative values [5, 4.9, 10] produce [5, 0, 5.1], totaling 10.1 despite the final bucket reporting 10. The extra counts also change the tooltip's percentiles.
Keep below at the greatest cumulative value seen so far, and add a test with a decreasing middle bucket.
| return numberFormat | ||
| ? formatNumber(bound, { ...numberFormat, average: true }) | ||
| : COMPACT_NUMBER_FORMAT.format(bound); |
There was a problem hiding this comment.
Bucket labels lose their limits
When a numeric format omits mantissa, formatBucketBound uses formatNumber's default of zero decimal places. Fractional bounds such as 0.1 and 0.5 become rounded labels instead of their actual limits. Different buckets can share a label, and tooltips can show ranges such as 0 – 0.
Choose enough decimal places to distinguish bucket bounds when the user has not set a precision.
| // Every series counts towards the distribution, so none are dropped. This is a | ||
| // client-side limit, so capping it wouldn't affect how much data is in memory. | ||
| maxSeries: Number.POSITIVE_INFINITY, |
There was a problem hiding this comment.
The calculated heatmap keeps every series, then passes them through responseToHeatmapSeries, which checks every series at every returned timestamp. Queries with many short-lived series can turn a small response into millions of empty lookups and extra chart objects, making the page unresponsive.
Build the distribution directly from the returned rows. That keeps all samples without first building a full time-chart representation.
Deep Review✅ No critical issues found. The new PromQL histogram heatmap mode is correct and well-covered: de-accumulation of cumulative buckets, 🟡 P2 — recommended
🔵 P3 nitpicks (7)
Reviewers (10): correctness, adversarial, testing, maintainability, performance, kieran-typescript, julik-frontend-races, project-standards, agent-native, learnings-researcher. 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 |
E2E Test Results✅ All tests passed • 409 passed • 1 skipped • 1723s
Tests ran across 4 shards in parallel. |
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