Repository navigation
fix: Respect explicit granularity on heatmaps #3305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3a9bdf6
fix: Respect explicit granularity on heatmaps
pulpdrew 282fd16
review: Address comments
pulpdrew f18f4f6
fix: Fix highlight at edges of heatmap
pulpdrew ac75575
fix: Align heatmap query to granularity
pulpdrew acce851
Merge branch 'main' into drew/heatmap-granularity
pulpdrew 5ff7ff1
Merge branch 'main' into drew/heatmap-granularity
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| feat: Respect explicit and minimum granularity on heatmaps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/app/src/components/DBHeatmapChart/__tests__/heatmapQueries.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { | ||
| BuilderChartConfigWithDateRange, | ||
| DisplayType, | ||
| } from '@hyperdx/common-utils/dist/types'; | ||
|
|
||
| import { | ||
| resolveHeatmapGranularity, | ||
| toHeatmapQuery, | ||
| } from '@/components/DBHeatmapChart/heatmapQueries'; | ||
|
|
||
| const HOUR = 60 * 60 * 1000; | ||
| const T0 = new Date('2026-07-06T00:00:00Z').getTime(); | ||
| const dateRange: [Date, Date] = [new Date(T0), new Date(T0 + 2 * HOUR)]; | ||
|
|
||
| describe('resolveHeatmapGranularity', () => { | ||
| it('auto-sizes to about 245 buckets', () => { | ||
| // 2h / 245 ≈ 29s | ||
| expect(resolveHeatmapGranularity({ dateRange })).toBe('30 second'); | ||
| expect(resolveHeatmapGranularity({ granularity: 'auto', dateRange })).toBe( | ||
| '30 second', | ||
| ); | ||
| }); | ||
|
|
||
| it('keeps an explicit granularity', () => { | ||
| expect( | ||
| resolveHeatmapGranularity({ granularity: '15 minute', dateRange }), | ||
| ).toBe('15 minute'); | ||
| }); | ||
|
|
||
| it('floors only auto granularity at minGranularitySeconds', () => { | ||
| expect( | ||
| resolveHeatmapGranularity({ dateRange, minGranularitySeconds: 300 }), | ||
| ).toBe('5 minute'); | ||
| expect( | ||
| resolveHeatmapGranularity({ | ||
| granularity: '1 minute', | ||
| dateRange, | ||
| minGranularitySeconds: 300, | ||
| }), | ||
| ).toBe('1 minute'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('toHeatmapQuery', () => { | ||
| const config: BuilderChartConfigWithDateRange = { | ||
| displayType: DisplayType.Heatmap, | ||
| select: [{ aggFn: 'count', aggCondition: '', valueExpression: 'Duration' }], | ||
| from: { databaseName: 'default', tableName: 'otel_traces' }, | ||
| where: '', | ||
| dateRange, | ||
| granularity: '5 minute', | ||
| timestampValueExpression: 'Timestamp', | ||
| connection: 'test-connection', | ||
| }; | ||
|
|
||
| it.each(['distribution', 'series'] as const)( | ||
| 'keeps the granularity in %s mode', | ||
| mode => { | ||
| const query = toHeatmapQuery({ ...config, heatmap: { mode } }); | ||
| expect(query.mode).toBe(mode); | ||
| expect(query.config.granularity).toBe('5 minute'); | ||
| }, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.