UNPKG

4.04 kBTypeScriptView Raw
1import type { TraceContext } from './context';
2interface CrontabSchedule {
3 type: 'crontab';
4 /** The crontab schedule string, e.g. 0 * * * *. */
5 value: string;
6}
7interface IntervalSchedule {
8 type: 'interval';
9 value: number;
10 unit: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute';
11}
12type MonitorSchedule = CrontabSchedule | IntervalSchedule;
13export interface SerializedCheckIn {
14 /** Check-In ID (unique and client generated). */
15 check_in_id: string;
16 /** The distinct slug of the monitor. */
17 monitor_slug: string;
18 /** The status of the check-in. */
19 status: 'in_progress' | 'ok' | 'error';
20 /** The duration of the check-in in seconds. Will only take effect if the status is ok or error. */
21 duration?: number;
22 release?: string;
23 environment?: string;
24 monitor_config?: {
25 schedule: MonitorSchedule;
26 /**
27 * The allowed allowed margin of minutes after the expected check-in time that
28 * the monitor will not be considered missed for.
29 */
30 checkin_margin?: number;
31 /**
32 * The allowed allowed duration in minutes that the monitor may be `in_progress`
33 * for before being considered failed due to timeout.
34 */
35 max_runtime?: number;
36 /**
37 * A tz database string representing the timezone which the monitor's execution schedule is in.
38 * See: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
39 */
40 timezone?: string;
41 /** How many consecutive failed check-ins it takes to create an issue. */
42 failure_issue_threshold?: number;
43 /** How many consecutive OK check-ins it takes to resolve an issue. */
44 recovery_threshold?: number;
45 };
46 contexts?: {
47 trace?: TraceContext;
48 };
49}
50export interface HeartbeatCheckIn {
51 /** The distinct slug of the monitor. */
52 monitorSlug: SerializedCheckIn['monitor_slug'];
53 /** The status of the check-in. */
54 status: 'ok' | 'error';
55}
56export interface InProgressCheckIn {
57 /** The distinct slug of the monitor. */
58 monitorSlug: SerializedCheckIn['monitor_slug'];
59 /** The status of the check-in. */
60 status: 'in_progress';
61}
62export interface FinishedCheckIn {
63 /** The distinct slug of the monitor. */
64 monitorSlug: SerializedCheckIn['monitor_slug'];
65 /** The status of the check-in. */
66 status: 'ok' | 'error';
67 /** Check-In ID (unique and client generated). */
68 checkInId: SerializedCheckIn['check_in_id'];
69 /** The duration of the check-in in seconds. Will only take effect if the status is ok or error. */
70 duration?: SerializedCheckIn['duration'];
71}
72export type CheckIn = HeartbeatCheckIn | InProgressCheckIn | FinishedCheckIn;
73type SerializedMonitorConfig = NonNullable<SerializedCheckIn['monitor_config']>;
74export interface MonitorConfig {
75 /**
76 * The schedule on which the monitor should run. Either a crontab schedule string or an interval.
77 */
78 schedule: MonitorSchedule;
79 /**
80 * The allowed allowed margin of minutes after the expected check-in time that
81 * the monitor will not be considered missed for.
82 */
83 checkinMargin?: SerializedMonitorConfig['checkin_margin'];
84 /**
85 * The allowed allowed duration in minutes that the monitor may be `in_progress`
86 * for before being considered failed due to timeout.
87 */
88 maxRuntime?: SerializedMonitorConfig['max_runtime'];
89 /**
90 * A tz database string representing the timezone which the monitor's execution schedule is in.
91 * See: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
92 */
93 timezone?: SerializedMonitorConfig['timezone'];
94 /** How many consecutive failed check-ins it takes to create an issue. */
95 failureIssueThreshold?: SerializedMonitorConfig['failure_issue_threshold'];
96 /** How many consecutive OK check-ins it takes to resolve an issue. */
97 recoveryThreshold?: SerializedMonitorConfig['recovery_threshold'];
98}
99export {};
100//# sourceMappingURL=checkin.d.ts.map
\No newline at end of file