Skip to content

Commit bd78e1e

Browse files
feat(crons): Add new fields to MonitorConfig type (#638)
Need these fields to implement getsentry/sentry-cli#1919
1 parent ab38648 commit bd78e1e

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

sentry-types/src/protocol/envelope.rs

+33
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ mod test {
703703
checkin_margin: Some(5),
704704
max_runtime: Some(30),
705705
timezone: Some("UTC".into()),
706+
failure_issue_threshold: None,
707+
recovery_threshold: None,
706708
}),
707709
};
708710
let envelope: Envelope = check_in.into();
@@ -715,6 +717,37 @@ mod test {
715717
)
716718
}
717719

720+
#[test]
721+
fn test_monitor_checkin_with_thresholds() {
722+
let check_in_id = Uuid::parse_str("22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c").unwrap();
723+
724+
let check_in = MonitorCheckIn {
725+
check_in_id,
726+
monitor_slug: "my-monitor".into(),
727+
status: MonitorCheckInStatus::Ok,
728+
duration: Some(123.4),
729+
environment: Some("production".into()),
730+
monitor_config: Some(MonitorConfig {
731+
schedule: MonitorSchedule::Crontab {
732+
value: "12 0 * * *".into(),
733+
},
734+
checkin_margin: Some(5),
735+
max_runtime: Some(30),
736+
timezone: Some("UTC".into()),
737+
failure_issue_threshold: Some(4),
738+
recovery_threshold: Some(7),
739+
}),
740+
};
741+
let envelope: Envelope = check_in.into();
742+
assert_eq!(
743+
to_str(envelope),
744+
r#"{}
745+
{"type":"check_in","length":310}
746+
{"check_in_id":"22d00b3fd1b14b5d8d2049d138cd8a9c","monitor_slug":"my-monitor","status":"ok","environment":"production","duration":123.4,"monitor_config":{"schedule":{"type":"crontab","value":"12 0 * * *"},"checkin_margin":5,"max_runtime":30,"timezone":"UTC","failure_issue_threshold":4,"recovery_threshold":7}}
747+
"#
748+
)
749+
}
750+
718751
#[test]
719752
fn test_event_with_attachment() {
720753
let event_id = Uuid::parse_str("22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c").unwrap();

sentry-types/src/protocol/monitor.rs

+8
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ pub struct MonitorConfig {
153153
/// tz database style timezone string
154154
#[serde(default, skip_serializing_if = "Option::is_none")]
155155
pub timezone: Option<String>,
156+
157+
/// The number of consecutive failed/error check-ins that triggers issue creation.
158+
#[serde(default, skip_serializing_if = "Option::is_none")]
159+
pub failure_issue_threshold: Option<u64>,
160+
161+
/// The number of consecutive successful check-ins that triggers issue resolution.
162+
#[serde(default, skip_serializing_if = "Option::is_none")]
163+
pub recovery_threshold: Option<u64>,
156164
}
157165

158166
fn serialize_id<S: Serializer>(uuid: &Uuid, serializer: S) -> Result<S::Ok, S::Error> {

0 commit comments

Comments
 (0)