Skip to content

Commit

Permalink
ref(crons): Only pass MonitorCheckIns to create_incident_occurrence (#…
Browse files Browse the repository at this point in the history
…80761)

We already have the check-in objects. There's no reason to need this
SimpleCheckIn thing
  • Loading branch information
evanpurkhiser authored Nov 14, 2024
1 parent 5b673ac commit c8861b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/sentry/monitors/logic/incident_occurrence.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
MonitorEnvironment,
MonitorIncident,
)
from sentry.monitors.types import SimpleCheckIn

if TYPE_CHECKING:
from django.utils.functional import _StrPromise
Expand All @@ -30,8 +29,8 @@


def create_incident_occurrence(
failed_checkins: Sequence[SimpleCheckIn],
failed_checkin: MonitorCheckIn,
previous_checkins: Sequence[MonitorCheckIn],
incident: MonitorIncident,
received: datetime | None,
) -> None:
Expand Down Expand Up @@ -60,7 +59,7 @@ def create_incident_occurrence(
evidence_display=[
IssueEvidence(
name="Failure reason",
value=str(get_failure_reason(failed_checkins)),
value=str(get_failure_reason(previous_checkins)),
important=True,
),
IssueEvidence(
Expand Down Expand Up @@ -128,7 +127,7 @@ def create_incident_occurrence(
}


def get_failure_reason(failed_checkins: Sequence[SimpleCheckIn]):
def get_failure_reason(failed_checkins: Sequence[MonitorCheckIn]):
"""
Builds a human readable string from a list of failed check-ins.
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/monitors/logic/incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ def try_incident_threshold(
# - We have an active incident and fingerprint
# - The monitor and env are not muted
if not monitor_env.monitor.is_muted and not monitor_env.is_muted and incident:
checkins = MonitorCheckIn.objects.filter(id__in=[c.id for c in previous_checkins])
checkins = list(MonitorCheckIn.objects.filter(id__in=[c.id for c in previous_checkins]))
for checkin in checkins:
create_incident_occurrence(
previous_checkins,
checkin,
checkins,
incident,
received=received,
)
Expand Down

0 comments on commit c8861b7

Please sign in to comment.