Skip to content
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

feat(pagerduty): Issue alerts will include alert name in summary #87786

Merged
merged 3 commits into from
Mar 25, 2025

Conversation

leeandher
Copy link
Member

@leeandher leeandher commented Mar 24, 2025

For issue alerts that include a pagerduty notification action, the name of the alert rule will be included in the title.

Also ensures test notifications have a label and can include one from the alert. This will enable users to see what the actual Pagerduty Incident title will be from the Send Test Notification button. If they are setting up a notif for the first time and haven't added a name Test Alert will be used instead.

Will require a followup FE PR to send the notif title along with the preview alert payload.

image

todo

  • Add screenshots
  • Add tests

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 24, 2025
@leeandher leeandher marked this pull request as ready for review March 24, 2025 20:59
@leeandher leeandher requested review from a team as code owners March 24, 2025 20:59
@@ -58,7 +59,7 @@ def post(self, request: Request, project) -> Response:
"frequency": 30,
}
)
rule = Rule(id=-1, project=project, data=data)
rule = Rule(id=-1, project=project, data=data, label=data.get("name"))
Copy link
Member Author

Choose a reason for hiding this comment

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

Rules are invalid without a label, so I feel comfortable including this across the board.

@@ -90,6 +91,12 @@ def send_notification(event, futures):
severity=severity,
)

rules: list[Rule] = [f.rule for f in futures]
rule = rules[0] if rules else None
Copy link
Member

Choose a reason for hiding this comment

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

curious if u know why u need to do rules[0] could we ever pass more than one thing inside rules?

Copy link
Member Author

Choose a reason for hiding this comment

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

rules is a list of Rule objects, and they are all identical as per https://github.com/getsentry/sentry/blob/master/src/sentry/rules/processing/processor.py#L178-L186, but this pattern is also used in a bunch of other EventAction's so if someone violated this, many tests would break. Weird pattern though, I agree -- im sure there's a historic reason.

Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 98.00000% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/api/serializers/rest_framework/rule.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #87786   +/-   ##
=======================================
  Coverage   87.74%   87.74%           
=======================================
  Files        9897     9897           
  Lines      561841   561879   +38     
  Branches    22142    22142           
=======================================
+ Hits       492964   493009   +45     
+ Misses      68475    68468    -7     
  Partials      402      402           

@leeandher leeandher merged commit ed4a430 into master Mar 25, 2025
49 checks passed
@leeandher leeandher deleted the leander/pd-title-update branch March 25, 2025 15:02
leeandher added a commit that referenced this pull request Mar 25, 2025
Some notifications may change their content depending on the title of
the alert. This is the case for PagerDuty as per the change in
#87786. For users to better
understand what they can expect when using the test notification button,
if they've set up an alert name we should use it, that way it'll appear
in the test notification as well.

If the user is setting up an issue alert for the first time, the test
notification will use the label `Test Alert` (per the change here
#87786 -- not included in this
PR)
andrewshie-sentry pushed a commit that referenced this pull request Mar 27, 2025
)

For issue alerts that include a pagerduty notification action, the name
of the alert rule will be included in the title.

Also ensures test notifications have a label and can include one from
the alert. This will enable users to see what the actual Pagerduty
Incident title will be from the `Send Test Notification` button. If they
are setting up a notif for the first time and haven't added a name `Test
Alert` will be used instead.

Will require a followup FE PR to send the notif title along with the
preview alert payload.

<img width="1402" alt="image"
src="https://github.com/user-attachments/assets/fb481f48-03c5-4213-93fb-d2c6293f0617"
/>

**todo**
- [x] Add screenshots
- [x] Add tests
andrewshie-sentry pushed a commit that referenced this pull request Mar 27, 2025
Some notifications may change their content depending on the title of
the alert. This is the case for PagerDuty as per the change in
#87786. For users to better
understand what they can expect when using the test notification button,
if they've set up an alert name we should use it, that way it'll appear
in the test notification as well.

If the user is setting up an issue alert for the first time, the test
notification will use the label `Test Alert` (per the change here
#87786 -- not included in this
PR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants