diff --git a/sentry-types/src/protocol/envelope.rs b/sentry-types/src/protocol/envelope.rs index 02f77803..56809a7f 100644 --- a/sentry-types/src/protocol/envelope.rs +++ b/sentry-types/src/protocol/envelope.rs @@ -703,6 +703,8 @@ mod test { checkin_margin: Some(5), max_runtime: Some(30), timezone: Some("UTC".into()), + failure_issue_threshold: None, + recovery_threshold: None, }), }; let envelope: Envelope = check_in.into(); @@ -715,6 +717,37 @@ mod test { ) } + #[test] + fn test_monitor_checkin_with_thresholds() { + let check_in_id = Uuid::parse_str("22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c").unwrap(); + + let check_in = MonitorCheckIn { + check_in_id, + monitor_slug: "my-monitor".into(), + status: MonitorCheckInStatus::Ok, + duration: Some(123.4), + environment: Some("production".into()), + monitor_config: Some(MonitorConfig { + schedule: MonitorSchedule::Crontab { + value: "12 0 * * *".into(), + }, + checkin_margin: Some(5), + max_runtime: Some(30), + timezone: Some("UTC".into()), + failure_issue_threshold: Some(4), + recovery_threshold: Some(7), + }), + }; + let envelope: Envelope = check_in.into(); + assert_eq!( + to_str(envelope), + r#"{} +{"type":"check_in","length":310} +{"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}} +"# + ) + } + #[test] fn test_event_with_attachment() { let event_id = Uuid::parse_str("22d00b3f-d1b1-4b5d-8d20-49d138cd8a9c").unwrap(); diff --git a/sentry-types/src/protocol/monitor.rs b/sentry-types/src/protocol/monitor.rs index b6d6bf2a..b8e883c8 100644 --- a/sentry-types/src/protocol/monitor.rs +++ b/sentry-types/src/protocol/monitor.rs @@ -153,6 +153,14 @@ pub struct MonitorConfig { /// tz database style timezone string #[serde(default, skip_serializing_if = "Option::is_none")] pub timezone: Option, + + /// The number of consecutive failed/error check-ins that triggers issue creation. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub failure_issue_threshold: Option, + + /// The number of consecutive successful check-ins that triggers issue resolution. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub recovery_threshold: Option, } fn serialize_id(uuid: &Uuid, serializer: S) -> Result {