16
16
from django .utils import timezone as django_timezone
17
17
from snuba_sdk import Column , Condition , Limit , Op
18
18
19
- from sentry import analytics , audit_log , features , options , quotas
19
+ from sentry import analytics , audit_log , features , quotas
20
20
from sentry .api .exceptions import ResourceDoesNotExist
21
21
from sentry .auth .access import SystemAccess
22
22
from sentry .constants import CRASH_RATE_ALERT_AGGREGATE_ALIAS , ObjectStatus
@@ -165,7 +165,9 @@ def create_incident(
165
165
# `bulk_create` doesn't send `post_save` signals, so we manually fire them here.
166
166
for incident_project in incident_projects :
167
167
post_save .send_robust (
168
- sender = type (incident_project ), instance = incident_project , created = True
168
+ sender = type (incident_project ),
169
+ instance = incident_project ,
170
+ created = True ,
169
171
)
170
172
171
173
create_incident_activity (
@@ -205,7 +207,10 @@ def update_incident_status(
205
207
)
206
208
207
209
prev_status = incident .status
208
- kwargs : dict [str , Any ] = {"status" : status .value , "status_method" : status_method .value }
210
+ kwargs : dict [str , Any ] = {
211
+ "status" : status .value ,
212
+ "status_method" : status_method .value ,
213
+ }
209
214
if status == IncidentStatus .CLOSED :
210
215
kwargs ["date_closed" ] = date_closed if date_closed else django_timezone .now ()
211
216
elif status == IncidentStatus .OPEN :
@@ -414,11 +419,7 @@ def get_metric_issue_aggregates(
414
419
)
415
420
416
421
except Exception :
417
- entity_key = (
418
- EntityKey .EAPItems
419
- if options .get ("alerts.spans.use-eap-items" )
420
- else EntityKey .EAPItemsSpan
421
- )
422
+ entity_key = EntityKey .EAPItems
422
423
metrics .incr (
423
424
"incidents.get_incident_aggregates.snql.query.error" ,
424
425
tags = {
@@ -1051,7 +1052,9 @@ def update_detector(detector: Detector, enabled: bool) -> None:
1051
1052
1052
1053
1053
1054
def delete_alert_rule (
1054
- alert_rule : AlertRule , user : User | RpcUser | None = None , ip_address : str | None = None
1055
+ alert_rule : AlertRule ,
1056
+ user : User | RpcUser | None = None ,
1057
+ ip_address : str | None = None ,
1055
1058
) -> None :
1056
1059
"""
1057
1060
Marks an alert rule as deleted and fires off a task to actually delete it.
@@ -1223,7 +1226,9 @@ def _schedule_trigger_action(
1223
1226
)
1224
1227
1225
1228
1226
- def _sort_by_priority_list (triggers : Collection [AlertRuleTrigger ]) -> list [AlertRuleTrigger ]:
1229
+ def _sort_by_priority_list (
1230
+ triggers : Collection [AlertRuleTrigger ],
1231
+ ) -> list [AlertRuleTrigger ]:
1227
1232
priority_dict = {
1228
1233
WARNING_TRIGGER_LABEL : 0 ,
1229
1234
CRITICAL_TRIGGER_LABEL : 1 ,
@@ -1234,7 +1239,9 @@ def _sort_by_priority_list(triggers: Collection[AlertRuleTrigger]) -> list[Alert
1234
1239
)
1235
1240
1236
1241
1237
- def _prioritize_actions (triggers : Collection [AlertRuleTrigger ]) -> list [AlertRuleTriggerAction ]:
1242
+ def _prioritize_actions (
1243
+ triggers : Collection [AlertRuleTrigger ],
1244
+ ) -> list [AlertRuleTriggerAction ]:
1238
1245
"""
1239
1246
Function that given an input array of AlertRuleTriggers, prioritizes those triggers
1240
1247
based on their label, and then re-orders actions based on that ordering
@@ -1364,7 +1371,10 @@ def create_alert_rule_trigger_action(
1364
1371
target = AlertTarget (target_identifier , target_display )
1365
1372
1366
1373
# store priority in the json sentry_app_config
1367
- if priority is not None and type in [ActionService .PAGERDUTY , ActionService .OPSGENIE ]:
1374
+ if priority is not None and type in [
1375
+ ActionService .PAGERDUTY ,
1376
+ ActionService .OPSGENIE ,
1377
+ ]:
1368
1378
if sentry_app_config :
1369
1379
sentry_app_config .update ({"priority" : priority })
1370
1380
else :
@@ -1455,7 +1465,10 @@ def update_alert_rule_trigger_action(
1455
1465
updated_fields ["target_identifier" ] = target .identifier
1456
1466
1457
1467
# store priority in the json sentry_app_config
1458
- if priority is not None and type in [ActionService .PAGERDUTY , ActionService .OPSGENIE ]:
1468
+ if priority is not None and type in [
1469
+ ActionService .PAGERDUTY ,
1470
+ ActionService .OPSGENIE ,
1471
+ ]:
1459
1472
if updated_fields .get ("sentry_app_config" ):
1460
1473
updated_fields ["sentry_app_config" ].update ({"priority" : priority })
1461
1474
else :
@@ -1483,7 +1496,11 @@ def get_target_identifier_display_for_integration(
1483
1496
) -> AlertTarget :
1484
1497
if action_type == AlertRuleTriggerAction .Type .SLACK .value :
1485
1498
return _get_target_identifier_display_for_slack (
1486
- target_value , integration_id , use_async_lookup , input_channel_id , integrations
1499
+ target_value ,
1500
+ integration_id ,
1501
+ use_async_lookup ,
1502
+ input_channel_id ,
1503
+ integrations ,
1487
1504
)
1488
1505
1489
1506
if target_value is None :
@@ -1705,11 +1722,15 @@ def delete_alert_rule_trigger_action(trigger_action: AlertRuleTriggerAction) ->
1705
1722
trigger_action .update (status = ObjectStatus .PENDING_DELETION )
1706
1723
1707
1724
1708
- def get_actions_for_trigger (trigger : AlertRuleTrigger ) -> QuerySet [AlertRuleTriggerAction ]:
1725
+ def get_actions_for_trigger (
1726
+ trigger : AlertRuleTrigger ,
1727
+ ) -> QuerySet [AlertRuleTriggerAction ]:
1709
1728
return AlertRuleTriggerAction .objects .filter (alert_rule_trigger = trigger )
1710
1729
1711
1730
1712
- def get_available_action_integrations_for_org (organization : Organization ) -> list [RpcIntegration ]:
1731
+ def get_available_action_integrations_for_org (
1732
+ organization : Organization ,
1733
+ ) -> list [RpcIntegration ]:
1713
1734
"""
1714
1735
Returns a list of integrations that the organization has installed. Integrations are
1715
1736
filtered by the list of registered providers.
@@ -1878,7 +1899,10 @@ def check_aggregate_column_support(
1878
1899
1879
1900
1880
1901
def translate_aggregate_field (
1881
- aggregate : str , reverse : bool = False , allow_mri : bool = False , allow_eap : bool = False
1902
+ aggregate : str ,
1903
+ reverse : bool = False ,
1904
+ allow_mri : bool = False ,
1905
+ allow_eap : bool = False ,
1882
1906
) -> str :
1883
1907
column = get_column_from_aggregate (aggregate , allow_mri , allow_eap )
1884
1908
if not reverse :
0 commit comments