Skip to content

feat(explore): Add Heat Map widget to Explore metrics#115608

Draft
gggritso wants to merge 5 commits into
masterfrom
georgegritsouk/dain-1635-add-heat-map-widget-to-explore-ii
Draft

feat(explore): Add Heat Map widget to Explore metrics#115608
gggritso wants to merge 5 commits into
masterfrom
georgegritsouk/dain-1635-add-heat-map-widget-to-explore-ii

Conversation

@gggritso
Copy link
Copy Markdown
Member

@gggritso gggritso commented May 14, 2026

e.g.,

Screenshot 2026-05-14 at 5 45 04 PM

Heat Map support for Metrics! This version is fairly light on crimes, but heavy on shenanigans to be addressed as the project continues.

Here's the gist

  1. If the feature flag is on the "Heat Map" options is available in the dropdown
  2. A Heat Map always plots value on the Y-axis and count() on the Z-axis (for now)
  3. Grouping is not supported, that dropdown is disabled
  4. The X-axis bucket size is controlled by user selection
  5. The Y-axis bucket size is determined based on the chart size, to try and make square heat map points
  6. Heat maps cannot be added to Dashboards (for now)

The gist of the PR is:

  • MetricPanel is in charge of data loading. For heat maps, it makes a request to another endpoint altogether, and returns the data
  • MetricGraph has a sibling called MetricHeatMap. In order to share code between them, they both accept Actions as a prop from the parent, so they get the same buttons for chart type and interval without having to copy stuff. So, that code lives in MetricPanel now
  • Some constants were moved to a settings file, just for ease
  • The heat map endpoint does not currently return correct Y-axis meta, so we have to steal it from the UI selection, this is TBD, I think this is fixable

gggritso added 4 commits May 14, 2026 17:08
Adds a Heat Map visualization option to the Explore metrics tab,
gated behind the `organizations:data-browsing-heat-map-widget`
feature flag.

- Add `ChartType.HEATMAP` to the chart type enum
- Create `MetricsHeatMap` component using the existing
  `HeatMapWidgetVisualization` from dashboards widgets
- Create `metricHeatmapApiOptions` for fetching heatmap data
  from the `/events-heatmap/` endpoint
- Extract shared chart actions (type selector, interval) to
  `MetricPanel` so both `MetricsGraph` and `MetricsHeatMap`
  can use them
- Disable aggregate and group-by dropdowns when heatmap is
  selected via `disabledReason` prop pattern
- Filter heatmaps from dashboard widget export
- Extract graph height constants to `settings.ts`

Ref: DAIN-1635
The wrapping Tooltip component broke flex layout, causing the disabled
aggregate and group-by dropdowns to not stretch correctly. Use
tooltipProps on the OverlayTrigger.Button instead, matching the
pattern used by DeleteMetricButton.
…sions

Use useDimensions to measure the chart container width, then derive
yBuckets from the aspect ratio so heatmap cells are roughly square
instead of rectangular.
The heatmap API returns generic types for the value field. Use the
trace metric's known unit to patch the Y-axis meta so the visualization
formats axis labels with the correct unit (e.g. "1.5 KB" not "1500").
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 14, 2026

DAIN-1635

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 14, 2026
@gggritso
Copy link
Copy Markdown
Member Author

@cursor review

…-1635-add-heat-map-widget-to-explore-ii

; Conflicts:
;	knip.config.ts
@github-actions
Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

Metric Before After Delta
Coverage 93.52% 93.52% ±0%
Typed 135,643 135,700 🟢 +57
Untyped 9,395 9,397 🔴 +2
🔍 1 new type safety issue introduced

Type assertions (as) (1 new)

File Line Detail
static/app/views/explore/metrics/metricPanel/index.tsx 390 as DataUnitunit as DataUnit

This is informational only and does not block the PR.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 206c7ee. Configure here.

isPending || !heatMapSeries ? (
<WidgetLoadingPanel />
) : error ? (
<Widget.WidgetError error={error} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error state hidden behind loading check in heatmap

Medium Severity

When the heatmap API request fails, data (heatMapSeries) is undefined and isPending is false. The condition isPending || !heatMapSeries evaluates to true because !heatMapSeries is true, so WidgetLoadingPanel is rendered instead of Widget.WidgetError. The error branch is unreachable on initial load failures, leaving users stuck on an infinite loading spinner instead of seeing the error message.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 206c7ee. Configure here.

import {
MINIMIZED_GRAPH_HEIGHT,
STACKED_GRAPH_HEIGHT,
} from 'sentry/views/explore/metrics/settings';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import statement placed after function definition

Low Severity

The import of MINIMIZED_GRAPH_HEIGHT and STACKED_GRAPH_HEIGHT from the settings file is placed after the getMetricsChartTypeOptions function definition at line 49. While ES module imports are hoisted so this won't cause a runtime error, it's clearly an accidental artifact of the refactor that moved these constants out to a separate file.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 206c7ee. Configure here.

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

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant