🔧 chore(pagerduty): Support "default" for custom severity config#83564
Merged
iamrajjoshi merged 3 commits intoJan 21, 2025
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #83564 +/- ##
==========================================
+ Coverage 87.55% 87.59% +0.04%
==========================================
Files 9409 9490 +81
Lines 537866 538926 +1060
Branches 21179 21179
==========================================
+ Hits 470916 472098 +1182
+ Misses 66602 66480 -122
Partials 348 348 |
cathteng
reviewed
Jan 16, 2025
|
|
||
| severity = app_config.get("priority", None) | ||
| if severity is not None: | ||
| if severity is not None and severity in PAGERDUTY_DEFAULT_SEVERITY: |
Contributor
There was a problem hiding this comment.
PAGERDUTY_DEFAULT_SEVERITY is a string?
Suggested change
| if severity is not None and severity in PAGERDUTY_DEFAULT_SEVERITY: | |
| if severity is not None and severity in PagerdutySeverity: |
Collaborator
Author
There was a problem hiding this comment.
whoops it needs to be severity == PAGERDUTY_DEFAULT_SEVERITY
|
|
||
| @responses.activate | ||
| def test_custom_severity_with_default_severity(self): | ||
| # default closed incident severity is info, setting severity to default should be ignored |
Contributor
There was a problem hiding this comment.
does this test assert that we used the default severity mapping for metric alerts?
Collaborator
Author
There was a problem hiding this comment.
yeah it makes sure if the priority is default, (meaning we have added a config) it will still use the default priority.
cathteng
approved these changes
Jan 16, 2025
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
As part of ACI Notification Action, we need to consolidate the configuration of Actions between the metric and issue alert registries into a "superset". This PR will get us there for Pagerduty.
Currently we store configuration for Pagerduty AlertRuleTriggerActions in
sentry_app_configas follows:{"priority":"critical"}. We have something similar for Issue Alerts, so we are good there.However, these is 1 thing that isn't aligned:
Issue Alerts have the following option for severity/priority: "default", "critical", "warning", "error", "info"
Metric Alerts have: "critical", "warning", "error", "info"
Notice that "default" is missing. You can also confirm this by trying to configure a pager duty on both Issue/Metric UI - Metric Alert action doesn't have a default option.
Issue

Metric

In the future when Actions can be attached to Workflows that will invoke either Issue/Metric registries, we need the configuration to be the same for the API for Actions to be the same for all automations.
What this PR does is allows us to pass "default" as a severity to Metric Alert action handler and it will use the default severity behavior that is determined here:
sentry/src/sentry/integrations/pagerduty/utils.py
Lines 100 to 107 in 9ffcb55
I tried explaining the reasoning here, but you need more clarifications, lmk!
references:
sentry/src/sentry/integrations/pagerduty/client.py
Line 20 in 9ffcb55
https://www.notion.so/sentry/ACI-Notification-Type-Problem-16f8b10e4b5d80f5a41af031daf3459b#1708b10e4b5d800d8789e988e1c6c25e
closes https://getsentry.atlassian.net/browse/ACI-108