Skip to content

Commit aae9d2b

Browse files
feat(crons): New monitor configuration options (#1922)
This PR adds the --failure-issue-threshold and --recovery-threshold command line arguments. These control the number of consecutive failed cron checkins that trigger issue creation, and the number of consecutive successful cron checkins that trigger issue resolution, respectively. Fixes GH-1919
1 parent 00136f3 commit aae9d2b

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

Cargo.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ regex = "1.7.3"
5858
runas = "1.0.0"
5959
rust-ini = "0.18.0"
6060
semver = "1.0.16"
61-
sentry = { version = "0.31.8", default-features = false, features = [
61+
sentry = { version = "0.32.2", default-features = false, features = [
6262
"anyhow",
6363
"curl",
6464
"contexts",

src/commands/monitors/run.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,26 @@ pub fn make_command(command: Command) -> Command {
8787
execution schedule's timezone. Requires --schedule.",
8888
),
8989
)
90+
.arg(
91+
Arg::new("failure_issue_threshold")
92+
.long("failure-issue-threshold")
93+
.value_parser(clap::value_parser!(u64).range(1..))
94+
.requires("schedule")
95+
.help(
96+
"The number of consecutive missed or error check-ins that trigger an \
97+
issue. Requires --schedule.",
98+
),
99+
)
100+
.arg(
101+
Arg::new("recovery_threshold")
102+
.long("recovery-threshold")
103+
.value_parser(clap::value_parser!(u64).range(1..))
104+
.requires("schedule")
105+
.help(
106+
"The number of consecutive successful check-ins that resolve an \
107+
issue. Requires --schedule.",
108+
),
109+
)
90110
}
91111

92112
fn run_program(args: Vec<&String>, monitor_slug: &str) -> (bool, Option<i32>, Duration) {
@@ -211,6 +231,8 @@ fn parse_monitor_config_args(matches: &ArgMatches) -> Result<Option<MonitorConfi
211231
checkin_margin: matches.get_one("checkin_margin").copied(),
212232
max_runtime: matches.get_one("max_runtime").copied(),
213233
timezone: matches.get_one("timezone").map(Tz::to_string),
234+
failure_issue_threshold: matches.get_one("failure_issue_threshold").copied(),
235+
recovery_threshold: matches.get_one("recovery_threshold").copied(),
214236
}))
215237
}
216238

tests/integration/_cases/monitors/monitors-run-help.trycmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ Options:
3434
--timezone <timezone>
3535
A tz database string (e.g. "Europe/Vienna") representing the monitor's execution
3636
schedule's timezone. Requires --schedule.
37+
--failure-issue-threshold <failure_issue_threshold>
38+
The number of consecutive missed or error check-ins that trigger an issue. Requires
39+
--schedule.
40+
--recovery-threshold <recovery_threshold>
41+
The number of consecutive successful check-ins that resolve an issue. Requires --schedule.
3742
-h, --help
3843
Print help
3944

0 commit comments

Comments
 (0)