Skip to content

Commit 182b5f1

Browse files
authored
ref(emails): Update perf issue email subject (#40072)
Update the default email subject line for performance issues to be the short id + issue type rather than the short id + title.
1 parent 673dd38 commit 182b5f1

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

src/sentry/eventstore/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from sentry.models import EventDict
2121
from sentry.snuba.events import Column, Columns
2222
from sentry.spans.grouping.api import load_span_grouping_config
23+
from sentry.types.issues import GROUP_TYPE_TO_TEXT, GroupCategory
2324
from sentry.utils import json
2425
from sentry.utils.cache import memoize
2526
from sentry.utils.canonical import CanonicalKeyView
@@ -495,6 +496,8 @@ def get_email_subject(self) -> str:
495496
template = self.project.get_option("mail:subject_template")
496497
if template:
497498
template = EventSubjectTemplate(template)
499+
elif self.group.issue_category == GroupCategory.PERFORMANCE:
500+
template = EventSubjectTemplate("$shortID - $issueType")
498501
else:
499502
template = DEFAULT_SUBJECT_TEMPLATE
500503
return cast(
@@ -753,6 +756,8 @@ def __getitem__(self, name: str) -> str:
753756
return cast(str, self.event.organization.slug)
754757
elif name == "title":
755758
return self.event.title
759+
elif name == "issueType":
760+
return cast(str, GROUP_TYPE_TO_TEXT.get(self.event.group.issue_type, "Issue"))
756761
raise KeyError
757762

758763

src/sentry/types/issues.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ class GroupCategory(Enum):
2929
GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES: GroupCategory.PERFORMANCE,
3030
}
3131

32+
GROUP_TYPE_TO_TEXT = {
33+
GroupType.ERROR: "Error",
34+
GroupType.PERFORMANCE_N_PLUS_ONE: "N+1 Query",
35+
GroupType.PERFORMANCE_SLOW_SPAN: "Slow Span",
36+
GroupType.PERFORMANCE_SEQUENTIAL_SLOW_SPANS: "Sequential Slow Spans",
37+
GroupType.PERFORMANCE_LONG_TASK_SPANS: "Long Task Spans",
38+
GroupType.PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN: "Render Blocking Asset Span",
39+
GroupType.PERFORMANCE_DUPLICATE_SPANS: "Duplicate Spans",
40+
GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES: "N+1 DB Queries",
41+
}
42+
3243

3344
def get_category_type_mapping():
3445
category_type_mapping = defaultdict(list)

tests/sentry/mail/test_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def test_full_integration_performance(self):
186186
assert len(mail.outbox) == 1
187187
sent = mail.outbox[0]
188188
assert sent.to == [self.user.email]
189-
assert "/country_by_code/" in sent.subject
189+
assert "N+1 DB Queries" in sent.subject
190190

191191
# XXX(gilbert): remove this later one
192192
@mock.patch("sentry.mail.actions.determine_eligible_recipients")

tests/sentry/mail/test_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def test_simple_notification_perf(self):
311311
self.adapter.notify(notification, ActionTargetType.ISSUE_OWNERS)
312312

313313
msg = mail.outbox[0]
314-
assert msg.subject == "[Sentry] BAR-1 - /books/"
314+
assert msg.subject == "[Sentry] BAR-1 - N+1 DB Queries"
315315
checked_values = [
316316
"Transaction Name",
317317
# TODO: Not sure if this is right

0 commit comments

Comments
 (0)