-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref(alerts): Pull code out into smaller functions #94654
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #94654 +/- ##
========================================
Coverage 87.92% 87.93%
========================================
Files 10418 10422 +4
Lines 602751 603144 +393
Branches 23451 23451
========================================
+ Hits 529993 530363 +370
- Misses 72252 72275 +23
Partials 506 506 |
cursor might be right but I didn't change anything - can address if it's a bug later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Metric Recording Inconsistency
In handle_trigger_anomalies
, the metrics.incr
call for resolve events was reordered to occur after trigger_resolve_threshold
. This prevents the resolve metric from being recorded if trigger_resolve_threshold
raises an exception. This behavior is inconsistent with handle_trigger_alerts
, where metrics are incremented before the trigger call.
src/sentry/incidents/subscription_processor.py#L288-L293
sentry/src/sentry/incidents/subscription_processor.py
Lines 288 to 293 in eef2373
if not has_anomaly and self.active_incident and trigger_matches_status: | |
incident_trigger = self.trigger_resolve_threshold(trigger, aggregation_value) | |
metrics.incr( | |
"incidents.alert_rules.threshold.resolve", | |
tags={"detection_type": self.alert_rule.detection_type}, | |
) |
Was this report helpful? Give feedback by reacting with 👍 or 👎
We're using a lot of flags and processing regular metric alerts, dynamic metric alerts, and workflow engine - the code in
process_update
was getting difficult to read. This PR pulls out some code into their own functions to make it more readable.