Skip to content

✨ feat(notification): add support for open_period_start for issue alert thread repo#83601

Merged
iamrajjoshi merged 3 commits into
masterfrom
raj/slack-threads-ref/update-issue-alert-repo
Jan 21, 2025
Merged

✨ feat(notification): add support for open_period_start for issue alert thread repo#83601
iamrajjoshi merged 3 commits into
masterfrom
raj/slack-threads-ref/update-issue-alert-repo

Conversation

@iamrajjoshi

@iamrajjoshi iamrajjoshi commented Jan 16, 2025

Copy link
Copy Markdown
Collaborator

this adds support for the open_period_start attribute that i just added to the notificationmessage model.

i will then follow this up by updating the issue alert metric handler to use this additional field. i probably do it via a registry based on group type.

context from a comment:
basically for metric issues and uptime issues, we want 1 thread per "open period" this tests creates 2 notifications, with the same rule & action, but with different open periods. this means the parent should return the latest notification (with the latest open period).

spec: https://www.notion.so/sentry/Slack-Threads-Refactor-1618b10e4b5d807db67ae6d4d85247b9
contributes to: https://getsentry.atlassian.net/browse/ACI-89

@iamrajjoshi iamrajjoshi requested a review from a team January 16, 2025 19:38
@iamrajjoshi iamrajjoshi self-assigned this Jan 16, 2025
@iamrajjoshi iamrajjoshi requested review from a team as code owners January 16, 2025 19:38
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 16, 2025
open_period_start=open_period_start,
)

notification_with_period = NotificationMessage.objects.create(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this meant to overwrite the notification_with_period defined above it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

basically for metric issues and uptime issues, we want 1 thread per "open period" this tests creates 2 notifications, wit the same rule & action, but with different open periods. this means the parent should return the latest notification (with the latest open period).

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.

nit: maybe name it differently so the intent is a bit more clear?

result_ids.append(parent_notification.id)

assert len(result_ids) == 1
assert result_ids[0] == n1.id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are you creating 2 of the same rows except for the open period, and why is it expected that the one with an earlier start time is the only parent notification returned? (sorry I lack context on this)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i made an oopsie on this testcase, i updated it so it ensures that the later notification is the one this returns. what this is testing is that we only return the parent threads for the "latest" open period.

for example, imagine we had a scenario where a metric/uptime issue that opened, then closed --- few minutes later -- it opened again.

when we are updating the thread for it to resolve again, it should only update the latest thread, not the earlier thread.

@iamrajjoshi iamrajjoshi requested a review from ceorourke January 16, 2025 22:14
@iamrajjoshi iamrajjoshi marked this pull request as draft January 17, 2025 03:23
@iamrajjoshi iamrajjoshi marked this pull request as ready for review January 17, 2025 23:18
@iamrajjoshi iamrajjoshi requested a review from a team January 17, 2025 23:37

@cathteng cathteng left a comment

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.

are we guaranteed to have the open period start time stored in the db = the open period start time from the issue?

open_period_start=open_period_start,
)

notification_with_period = NotificationMessage.objects.create(

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.

nit: maybe name it differently so the intent is a bit more clear?

query = self._model.objects.filter(group_id_filter & project_id_filter).filter(
self._parent_notification_message_base_filter()
open_period_start_filter = (
Q(open_period_start=open_period_start) if open_period_start else Q()

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.

should this be open_period_start__gte=open_period_start? is it possible that the seconds/milliseconds don't match up exactly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this shouldn't be the case, we pull the open_period_start from the Activity model, and we should be storing the exact time

the pr for the open period: #83689

@iamrajjoshi iamrajjoshi force-pushed the raj/slack-threads-ref/update-issue-alert-repo branch from f6a0882 to 5ba2ab0 Compare January 21, 2025 17:01
@iamrajjoshi iamrajjoshi merged commit 37e937c into master Jan 21, 2025
@iamrajjoshi iamrajjoshi deleted the raj/slack-threads-ref/update-issue-alert-repo branch January 21, 2025 17:30
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants