Skip to content

Commit a2a26bd

Browse files
feat(crons): Indicate when a timeout has a terminal status (#91774)
This looks like this <img alt="clipboard.png" width="624" src="https://i.imgur.com/80wp6Ze.png" /> Fixes [NEW-333: Indicate how late the closing check-in was when timed out with duration](https://linear.app/getsentry/issue/NEW-333/indicate-how-late-the-closing-check-in-was-when-timed-out-with)
1 parent 6ee8140 commit a2a26bd

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

static/app/views/insights/crons/components/monitorCheckIns.tsx

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {Fragment} from 'react';
22
import styled from '@emotion/styled';
33

44
import {SectionHeading} from 'sentry/components/charts/styles';
5+
import {Tag} from 'sentry/components/core/badge/tag';
56
import {Tooltip} from 'sentry/components/core/tooltip';
67
import {DateTime} from 'sentry/components/dateTime';
78
import Duration from 'sentry/components/duration';
@@ -29,6 +30,8 @@ import {CheckInStatus} from 'sentry/views/insights/crons/types';
2930
import {statusToText} from 'sentry/views/insights/crons/utils';
3031
import {useMonitorCheckIns} from 'sentry/views/insights/crons/utils/useMonitorCheckIns';
3132

33+
import {DEFAULT_MAX_RUNTIME} from './monitorForm';
34+
3235
type Props = {
3336
monitor: Monitor;
3437
monitorEnvs: MonitorEnvironment[];
@@ -133,11 +136,14 @@ export function MonitorCheckIns({monitor, monitorEnvs}: Props) {
133136
</div>
134137
)}
135138
{defined(checkIn.duration) ? (
136-
<div>
139+
<DurationContainer>
137140
<Tooltip title={<Duration exact seconds={checkIn.duration / 1000} />}>
138141
<Duration seconds={checkIn.duration / 1000} />
139142
</Tooltip>
140-
</div>
143+
{checkIn.status === CheckInStatus.TIMEOUT && (
144+
<TimeoutLateBy monitor={monitor} duration={checkIn.duration} />
145+
)}
146+
</DurationContainer>
141147
) : (
142148
emptyCell
143149
)}
@@ -198,10 +204,51 @@ export function MonitorCheckIns({monitor, monitorEnvs}: Props) {
198204
);
199205
}
200206

207+
interface TimeoutLateByProps {
208+
duration: number;
209+
monitor: Monitor;
210+
}
211+
212+
function TimeoutLateBy({monitor, duration}: TimeoutLateByProps) {
213+
const maxRuntimeSeconds = (monitor.config.max_runtime ?? DEFAULT_MAX_RUNTIME) * 60;
214+
const lateBySecond = duration / 1000 - maxRuntimeSeconds;
215+
216+
const maxRuntime = (
217+
<strong>
218+
<Duration seconds={(monitor.config.max_runtime ?? DEFAULT_MAX_RUNTIME) * 60} />
219+
</strong>
220+
);
221+
222+
const lateBy = (
223+
<strong>
224+
<Duration seconds={lateBySecond} />
225+
</strong>
226+
);
227+
228+
return (
229+
<Tooltip
230+
title={tct(
231+
'The closing check-in occurred [lateBy] after this check-in was marked as timed out. The configured maximum allowed runtime is [maxRuntime].',
232+
{lateBy, maxRuntime}
233+
)}
234+
>
235+
<Tag type="error">
236+
{t('%s late', <Duration abbreviation seconds={lateBySecond} />)}
237+
</Tag>
238+
</Tooltip>
239+
);
240+
}
241+
201242
const Status = styled('div')`
202243
line-height: 1.1;
203244
`;
204245

246+
const DurationContainer = styled('div')`
247+
display: flex;
248+
gap: ${space(0.5)};
249+
align-items: center;
250+
`;
251+
205252
const IssuesContainer = styled('div')`
206253
display: flex;
207254
flex-direction: column;

static/app/views/insights/crons/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export interface CheckIn {
148148
/**
149149
* Duration (in milliseconds)
150150
*/
151-
duration: number;
151+
duration: number | null;
152152
/**
153153
* environment the check-in was sent to
154154
*/

0 commit comments

Comments
 (0)