Skip to content

Conversation

@pulpdrew
Copy link
Contributor

@pulpdrew pulpdrew commented Jan 5, 2026

Closes HDX-3094

Summary

This PR standardizes available granularities and inferred/auto granularities throughout the app

  1. A duplicate convertDateRangeToGranularityString implementation was removed.
  2. 10 minute granularity is no longer auto-inferred, because it (in combination with 15 minutes) breaks the property that all granularities are multiples of smaller granularities. Since MVs are only used when the chart granularity is a multiple of the MV granularity, we want to minimize the chance that a MV is 10 minutes and the chart is 15 minutes, or vice versa. To this end, MVs only support 15 minute granularity, and not 10 minute granularity (to align with alerts). By removing the 10 minute granularity from auto granularity inference, we decrease the chance of automatically choosing a granularity that can't be used with an MV.
  3. The max buckets argument was standardized to a constant (DEFAULT_AUTO_GRANULARITY_MAX_BUCKETS) with value 60. It is now an optional argument, only passed when a non-default value is required.

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: 760ee91

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/common-utils Patch
@hyperdx/api Patch
@hyperdx/app Patch

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

@vercel
Copy link

vercel bot commented Jan 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
hyperdx-v2-oss-app Ready Ready Preview, Comment Jan 8, 2026 10:13pm

@claude
Copy link

claude bot commented Jan 5, 2026

Code Review

Overall Assessment: Clean refactoring with good architectural improvements. Found one issue that needs attention:

Issues

  • ⚠️ GranularityPicker.tsx:37-42 - Added 15-minute option but kept 10-minute option → This contradicts the PR's goal of removing 10-minute granularity to align with MVs. The picker still allows manual selection of 10-minute granularity even though it won't be auto-inferred. Consider removing Granularity.TenMinute from the picker options or documenting why manual selection is still allowed.

Positive Changes

  • ✅ Removed duplicate convertDateRangeToGranularityString implementation (DRY principle)
  • ✅ Centralized constant DEFAULT_AUTO_GRANULARITY_MAX_BUCKETS = 60
  • ✅ Moved Granularity enum to common-utils for proper sharing
  • ✅ Consistent use of default parameter for maxNumBuckets
  • ✅ Auto-granularity now skips 10-minute to ensure MV compatibility (lines 276-279 in utils.ts)

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

E2E Test Results

All tests passed • 59 passed • 4 skipped • 769s

Status Count
✅ Passed 59
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 4

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew pulpdrew force-pushed the drew/standardize-granularities branch from 8f01199 to 1cc78a6 Compare January 5, 2026 16:24
@pulpdrew pulpdrew force-pushed the drew/standardize-granularities branch from a6ab41e to 2038ea6 Compare January 5, 2026 17:28
@pulpdrew pulpdrew requested review from a team and wrn14897 and removed request for a team January 5, 2026 17:57
@pulpdrew pulpdrew force-pushed the drew/standardize-granularities branch from 2038ea6 to 7321b64 Compare January 6, 2026 16:35
kodiakhq bot pushed a commit that referenced this pull request Jan 7, 2026
…#1533)

Closes HDX-3067
Closes #1331 
Closes #1212 
Closes #1468

# Summary

This PR makes a number of improvements around the way we handle date ranges and granularities, in an effort to minimize discrepancies between aggregate values queried from original data and aggregate values queried from materialized views.

1. Date ranges for Line and Bar chart queries are now (by default) auto-aligned to the chart's granularity. **This is not limited to materialized view queries.** Since the chart granularity is a multiple of the MV granularity, this ensures that the date range is aligned to the MV granularity as well. This also address a number of related issues that point out 0-values or low-values in the first or last data points. This PR also includes an option to disable this behavior for charts in Chart Explorer or Dashboard Tiles.
2. All materialized view queries and all time chart queries are now end-exclusive, to avoid selecting the entirety of the next "time bucket" from the materialized view when the date range is aligned with the materialized view granularity
3. Materialized views are only used for a query with a granularity if the chart query granularity is a multiple of the MV granularity. Previously, we'd use the MV as long as the chart query granularity was at least as large as the MV granularity, but this could cause unequal distributions of data across time buckets. Nearly all available granularities are multiples of all smaller available granularities - so this should only impact queries with granularity 15 minutes with MVs with granularity 10 minutes. 10m granularity support is being removed in #1551 

## Demo

<details>
<summary>Show Complete Intervals Option</summary>

https://github.com/user-attachments/assets/4b903adb-4edf-4481-93d6-2a0c42589a37
</details>
@pulpdrew pulpdrew force-pushed the drew/standardize-granularities branch from 7321b64 to 1947e1f Compare January 8, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants