-
Notifications
You must be signed in to change notification settings - Fork 458
feat: attribute alert notification time to each target #3003
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
jordan-simonovski
merged 5 commits into
main
from
jordansimonovski/alert-per-target-notification-timings
Aug 28, 2026
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8ce84f5
feat: attribute alert notification time to each target
jordan-simonovski 6d2a9cd
fix: key notification timings on the webhook id
jordan-simonovski b8b30e1
Merge branch 'main' into jordansimonovski/alert-per-target-notificati…
jordan-simonovski f3af1b7
Merge branch 'main' into jordansimonovski/alert-per-target-notificati…
jordan-simonovski 2a7f0b6
Merge branch 'main' into jordansimonovski/alert-per-target-notificati…
jordan-simonovski 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,11 @@ | ||
| --- | ||
| '@hyperdx/api': minor | ||
| '@hyperdx/app': minor | ||
| '@hyperdx/common-utils': minor | ||
| --- | ||
|
|
||
| Record and show which notification target an evaluation's delivery time went to. `webhookDurationMs` was a single number covering the whole delivery, and because targets are dispatched concurrently the slowest one sets it — so a multi-target alert reported a figure with no way to tell which webhook was responsible, or that the other targets were fine. | ||
|
|
||
| Each dispatch is now timed individually and aggregated per target across the evaluation, since a grouped alert notifies the same target once per firing group and again on resolve. One entry per distinct target carries its summed duration, how many dispatches it took, and how many failed. The evaluation history's "Notification duration" cell expands in place to show the breakdown. | ||
|
|
||
| Stored per evaluation rather than per dispatch: a 50-group alert notifying 10 targets would otherwise write 500 entries onto every history row. The array is capped at `ALERT_NOTIFICATION_TARGETS_LIMIT` and sorted slowest-first, so the cap drops the least interesting rows. Records written before this change keep rendering their total with nothing to expand. |
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
80 changes: 80 additions & 0 deletions
80
packages/app/src/components/alerts/NotificationDurationCell.tsx
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,80 @@ | ||
| import * as React from 'react'; | ||
| import type { AlertHistoryAnalytics } from '@hyperdx/common-utils/dist/types'; | ||
| import { Collapse, Group, Stack, Text, UnstyledButton } from '@mantine/core'; | ||
| import { IconChevronDown, IconChevronRight } from '@tabler/icons-react'; | ||
|
|
||
| import { formatDurationMs } from '@/utils'; | ||
|
|
||
| /** | ||
| * The evaluation's notification wall time, expandable in place into a | ||
| * per-target breakdown. | ||
| * | ||
| * It expands *within* the cell rather than adding child rows: the parent row | ||
| * already owns a chevron for groups and errors, and a second row-level | ||
| * expander competing with it would be ambiguous to click. | ||
| */ | ||
| export function NotificationDurationCell({ | ||
| analytics, | ||
| }: { | ||
| analytics?: AlertHistoryAnalytics; | ||
| }) { | ||
| const [expanded, setExpanded] = React.useState(false); | ||
| const total = analytics?.webhookDurationMs; | ||
| const targets = analytics?.notificationTargets ?? []; | ||
|
|
||
| if (total == null) { | ||
| return <>–</>; | ||
| } | ||
|
|
||
| // Records written before per-target timing existed have the total but no | ||
| // breakdown, so there is nothing to expand into. | ||
| if (targets.length === 0) { | ||
| return <Text size="sm">{formatDurationMs(total)}</Text>; | ||
| } | ||
|
|
||
| return ( | ||
| <Stack gap={2} align="flex-start"> | ||
| <UnstyledButton | ||
| // The parent row toggles its own expansion on click; without this the | ||
| // cell's expander would fire both. | ||
| onClick={event => { | ||
| event.stopPropagation(); | ||
| setExpanded(value => !value); | ||
| }} | ||
| aria-expanded={expanded} | ||
| data-testid="notification-duration-toggle" | ||
| > | ||
| <Group gap={2} wrap="nowrap"> | ||
| <Text size="sm">{formatDurationMs(total)}</Text> | ||
| {expanded ? ( | ||
| <IconChevronDown size={12} /> | ||
| ) : ( | ||
| <IconChevronRight size={12} /> | ||
| )} | ||
| </Group> | ||
| </UnstyledButton> | ||
| <Collapse expanded={expanded}> | ||
| <Stack gap={2} pt={2} data-testid="notification-duration-breakdown"> | ||
| {targets.map(target => ( | ||
| <Group key={target.target} gap="xs" wrap="nowrap"> | ||
| <Text size="xs" c="dimmed"> | ||
| {target.target} | ||
| </Text> | ||
| <Text size="xs">{formatDurationMs(target.durationMs)}</Text> | ||
| {target.dispatches > 1 && ( | ||
| <Text size="xs" c="dimmed"> | ||
| ×{target.dispatches} | ||
| </Text> | ||
| )} | ||
| {target.failures > 0 && ( | ||
| <Text size="xs" c="red"> | ||
|
greptile-apps[bot] marked this conversation as resolved.
Outdated
|
||
| {target.failures} failed | ||
| </Text> | ||
| )} | ||
| </Group> | ||
| ))} | ||
| </Stack> | ||
| </Collapse> | ||
| </Stack> | ||
| ); | ||
| } | ||
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.