Repository navigation
feat: Add distribution heatmaps calculated from PromQL values - #3326
Conversation
🦋 Changeset detectedLatest commit: 98b69d5 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🟡 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
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
4 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 3 minor 4 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. |
|
Deep Review✅ No critical issues found. This PR adds a client-side "calculated" distribution heatmap mode for PromQL range queries (bucketing every series' sample values into linear/log value buckets per time column). The new bucketing math in 🟡 P2 -- recommended
🔵 P3 nitpicks (2)
Reviewers (2): performance, orchestrator direct analysis (correctness, previous-comments, api-contract/schema, and editor-wiring lenses applied against the full changed files and the 25 prior PR comments). Testing gaps: No test exercises 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 • 408 passed • 1 skipped • 1135s
Tests ran across 4 shards in parallel. |
fc73f3a to
640298f
Compare
| } from './heatmapGrid'; | ||
| import { HeatmapSeries, makeTimeIndexer } from './heatmapSeriesGrid'; | ||
|
|
||
| export const CALCULATED_TARGET_BUCKETS = 10; |
There was a problem hiding this comment.
Could the row count grow with the number of samples instead of staying fixed at 10?
Builder heatmaps use 80 rows. With 10, high-cardinality data loses most of its shape: 10k series of with latency at different extremes would lose any detail indicating tail-end issues. Few series still need few rows, so something like this keeps the screenshot case as it is:
const n = clamp(Math.round(Math.sqrt(maxSamplesPerColumn)), CALCULATED_TARGET_BUCKETS, HEATMAP_N_BUCKETS);There was a problem hiding this comment.
Good idea, updated! And I've added a followup ticket to support custom row counts so the user can choose
|
|
||
| /** Index of the `yStep`-tall row holding `value`. */ | ||
| function yStepIndex(value: number, yStep: number) { | ||
| return Math.floor(round(value / yStep, 9)); |
There was a problem hiding this comment.
Would a plain epsilon work here instead of lodash round?
round runs once per sample and converts the number to a string and back. For 2.45M samples that's ~930ms against ~12ms for the version below, which is most of the cost of the linear grid:
return Math.floor(value / yStep + 1e-9);There was a problem hiding this comment.
Nice suggestion - updated!
| enabled, | ||
| // 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.
Should there be an upper limit on samples, now that there's no series cap? Would a sample limit with a notice, like MAX_TABLE_ROWS for tables, make sense here?
There was a problem hiding this comment.
There is an upper limit on the API side (100k series). If it's alright with you, I can add the warning as a followup because it turns out to be a wider change in a variety of places.
|
Left you a few questions. Happy to discuss if they don't make sense! |
4f7c09c to
f1fd37c
Compare
f1fd37c to
6ca4357
Compare
6ca4357 to
1a191fd
Compare
|
LGTM! Nice work! |
1a191fd to
98b69d5
Compare
Summary
This PR adds support for heatmaps that display a distribution of data queried from PromQL. The distribution is calculated client-side by bucketing the values returned at each timestamp into linear- or log-spaced buckets. The number of samples per bucket determines the color.
Screenshots or video
Show distribution (# of cores) at varying utilization % over time:
How to test locally
References