Skip to content

Commit c5e8562

Browse files
committed
fix(perf-detection): handle missing description field in MN+1 DB span detector
Spans processed by the segment consumer may not always include a `description` key. Accessing `db_span["description"]` raised KeyError causing the entire performance problem detection to fail (SENTRY-5QVD, 210K+ events). Changed both callsites to use `.get("description", "")`. Also downgrade `logger.exception` to `logger.warning` for `DetectorGroup.DoesNotExist` in `_get_detector_for_group` — this is an expected condition for legacy groups that predate DetectorGroup associations, and the code already handles it gracefully by falling through to alternative detector lookups (SENTRY-5R4N, 24K events, 4K users). Using `logger.exception` was generating noisy error-level log events with full tracebacks for a known benign case. Fixes SENTRY-5QVD Ref SENTRY-5R4N
1 parent 3f50dd4 commit c5e8562

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/sentry/issue_detection/detectors/mn_plus_one_db_span_detector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def _maybe_performance_problem(self) -> PerformanceProblem | None:
255255
return PerformanceProblem(
256256
fingerprint=self._fingerprint(db_span["hash"], common_parent_span),
257257
op="db",
258-
desc=db_span["description"],
258+
desc=db_span.get("description", ""),
259259
type=PerformanceNPlusOneGroupType,
260260
parent_span_ids=[common_parent_span["span_id"]],
261261
cause_span_ids=db_span_ids,
@@ -280,7 +280,7 @@ def _maybe_performance_problem(self) -> PerformanceProblem | None:
280280
name="Offending Spans",
281281
value=get_notification_attachment_body(
282282
"db",
283-
db_span["description"],
283+
db_span.get("description", ""),
284284
),
285285
# Has to be marked important to be displayed in the notifications
286286
important=True,

src/sentry/workflow_engine/processors/detector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _get_detector_for_group(group: Group) -> Detector:
152152
if detector is not None:
153153
return detector
154154
except DetectorGroup.DoesNotExist:
155-
logger.exception(
155+
logger.warning(
156156
"DetectorGroup not found for group",
157157
extra={"group_id": group.id},
158158
)

0 commit comments

Comments
 (0)