Skip to content

Commit f00ec17

Browse files
authored
ref: Deprecate get_legacy_message (#16310)
Move the implementation into the Pagerduty plugin since this is the only place it is used.
1 parent a8c8cca commit f00ec17

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

src/sentry/models/event.py

-10
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,6 @@ def interfaces(self):
112112
def get_interface(self, name):
113113
return self.interfaces.get(name)
114114

115-
def get_legacy_message(self):
116-
# TODO: This is only used in the pagerduty plugin. We should use event.title
117-
# there and remove this function once users have been notified, since PD
118-
# alert routing may be based off the message field.
119-
return (
120-
get_path(self.data, "logentry", "formatted")
121-
or get_path(self.data, "logentry", "message")
122-
or self.message
123-
)
124-
125115
def get_event_type(self):
126116
"""
127117
Return the type of this event.

src/sentry_plugins/pagerduty/plugin.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ def notify_users(self, group, event, fail_silently=False, **kwargs):
4949
if not self.is_configured(group.project):
5050
return
5151

52-
description = event.get_legacy_message()[:1024]
52+
# TODO: This should eventually be event.title in line with other plugins.
53+
# However, we should notify users first, since PD alert routing may be
54+
# based off the message field.
55+
description = (event.real_message or event.message)[:1024]
5356

5457
tags = dict(event.tags)
5558
details = {

tests/sentry_plugins/pagerduty/test_plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_simple_notification(self):
100100
"datetime": event.datetime.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
101101
},
102102
"service_key": "abcdef",
103-
"description": event.get_legacy_message(),
103+
"description": event.real_message,
104104
}
105105

106106
def test_no_secrets(self):

0 commit comments

Comments
 (0)