-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(crons): Improve occurance evidence Failure reason #70785
feat(crons): Improve occurance evidence Failure reason #70785
Conversation
75dbbfd
to
1615515
Compare
) | ||
|
||
if sum(status_counts.values()) == 1: | ||
return _("A %(status)s check-in was detected") % {"status": list(status_counts.keys())[0]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we say "An error check-in was detected"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
343b3fd
to
31239ed
Compare
@@ -166,8 +179,13 @@ def mark_failed_threshold( | |||
# - 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]) | |||
for previous_checkin in checkins: | |||
create_issue_platform_occurrence(previous_checkin, incident, received=received) | |||
for failed_checkin in checkins: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is some variable shadowing going on here has failed_checkin
is a parameter to this function. would rename to limit the confusion
) | ||
|
||
status_counts = Counter( | ||
human_names[cast(int, checkin["status"])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to cast this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"CheckInStatus" is incompatible with "int"
It's because
human_names: Mapping[int, str] = dict(
[
(CheckInStatus.ERROR, "error"),
(CheckInStatus.MISSED, "missed"),
(CheckInStatus.TIMEOUT, "timeout"),
]
)
I would type this as
human_names: Mapping[CheckInStatus, str] = dict(
[
(CheckInStatus.ERROR, "error"),
(CheckInStatus.MISSED, "missed"),
(CheckInStatus.TIMEOUT, "timeout"),
]
)
But that produces
Type parameter "_KT@Mapping" is invariant, but "Literal[2, 4, 5]" is not the same as "CheckInStatus"
There's a dynamic guard for this because of the if
in the generator
status_counts = Counter(
HUMAN_FAILURE_STATUS_MAP[cast(int, checkin["status"])]
for checkin in failed_checkins
if checkin["status"] in HUMAN_FAILURE_STATUS_MAP.keys()
)
e9c4b4f
to
5cbb9da
Compare
@@ -304,6 +326,41 @@ def create_issue_platform_occurrence( | |||
) | |||
|
|||
|
|||
HUMAN_FAILURE_STATUS_MAP: Mapping[int, str] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think this type is correct? CheckInStatus
is an enum not an IntEnum
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not an enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sentry/src/sentry/monitors/models.py
Line 125 in ac80048
class CheckInStatus: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah
) | ||
|
||
if sum(status_counts.values()) == 1: | ||
return _("An %(status)s check-in was detected") % {"status": list(status_counts.keys())[0]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not familiar but will the string logic here correctly do A
vs 'An`?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. Let me see what django has for a e i o and u and sometimes y
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth adding a test for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would try and remove the casts, but other than that lgtm besides the A vs An bit
39be0c8
to
bc408bd
Compare
Managed to get rid of most of the casts, the problem was the |
9628078
to
3fff04d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #70785 +/- ##
===========================================
- Coverage 78.18% 58.40% -19.78%
===========================================
Files 6506 6469 -37
Lines 290888 290327 -561
Branches 50135 50092 -43
===========================================
- Hits 227434 169570 -57864
- Misses 63019 120316 +57297
- Partials 435 441 +6
|
3edcce9
to
620051c
Compare
33fb44c
to
2a448f7
Compare
The failure reason of "incident" isn't super helpful We can instead say something like > 3 missed check-ins were detected > 2 missed check-ins, 1 timeut check-in and 1 error check-in detected > A failed check-in detected This implements that
d36285b
to
59b49e5
Compare
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
The failure reason of "incident" isn't super helpful
We can instead say something like
This implements that