4
4
from sentry .models .team import Team
5
5
from sentry .users .services .user import RpcUser
6
6
7
- MAX_CHARS = 248 # (256 minus space for '...(+3_)')
7
+ MAX_ACTIONS = 3
8
8
9
9
10
10
def get_action_description (action : AlertRuleTriggerAction ) -> str :
11
11
"""
12
12
Returns a human readable action description
13
13
"""
14
- action_type_to_string = {
15
- AlertRuleTriggerAction .Type .PAGERDUTY .value : f "PagerDuty to { action . target_display } " ,
16
- AlertRuleTriggerAction .Type .SLACK .value : f "Slack { action . target_display } " ,
17
- AlertRuleTriggerAction .Type .MSTEAMS .value : f "Microsoft Teams { action . target_display } " ,
18
- AlertRuleTriggerAction .Type .SENTRY_APP .value : f"Notify { action . target_display } " ,
14
+ ACTION_TYPE_TO_STRING = {
15
+ AlertRuleTriggerAction .Type .PAGERDUTY .value : "PagerDuty" ,
16
+ AlertRuleTriggerAction .Type .SLACK .value : "Slack" ,
17
+ AlertRuleTriggerAction .Type .MSTEAMS .value : "Microsoft Teams" ,
18
+ AlertRuleTriggerAction .Type .OPSGENIE .value : "Opsgenie " ,
19
19
}
20
20
21
21
if action .type == AlertRuleTriggerAction .Type .EMAIL .value :
@@ -26,13 +26,10 @@ def get_action_description(action: AlertRuleTriggerAction) -> str:
26
26
elif action .target_type == AlertRuleTriggerAction .TargetType .TEAM .value :
27
27
action_target_team = cast (Team , action .target )
28
28
return "Email #" + action_target_team .slug
29
- elif action .type == AlertRuleTriggerAction .Type .OPSGENIE .value :
30
- return f"Opsgenie to { action .target_display } "
31
- elif action .type == AlertRuleTriggerAction .Type .DISCORD .value :
32
- return f"Discord to { action .target_display } "
33
- else :
34
- return action_type_to_string [action .type ]
35
- return ""
29
+ elif action .type == AlertRuleTriggerAction .Type .SENTRY_APP .value :
30
+ return f"Notify { action .target_display } "
31
+
32
+ return f"Notify { action .target_display } via { ACTION_TYPE_TO_STRING [action .type ]} "
36
33
37
34
38
35
def get_workflow_name (alert_rule : AlertRule ) -> str :
@@ -54,7 +51,7 @@ def get_workflow_name(alert_rule: AlertRule) -> str:
54
51
for action in actions .filter (alert_rule_trigger_id = trigger .id ):
55
52
description = get_action_description (action ) + ", "
56
53
57
- if len ( name ) + len ( description ) <= MAX_CHARS :
54
+ if actions_counter < MAX_ACTIONS :
58
55
name += description
59
56
actions_counter += 1
60
57
else :
0 commit comments