Skip to content

Commit

Permalink
feat(crons): New monitor configuration options (#1922)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
szokeasaurusrex authored Jan 30, 2024
1 parent 00136f3 commit aae9d2b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ regex = "1.7.3"
runas = "1.0.0"
rust-ini = "0.18.0"
semver = "1.0.16"
sentry = { version = "0.31.8", default-features = false, features = [
sentry = { version = "0.32.2", default-features = false, features = [
"anyhow",
"curl",
"contexts",
Expand Down
22 changes: 22 additions & 0 deletions src/commands/monitors/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ pub fn make_command(command: Command) -> Command {
execution schedule's timezone. Requires --schedule.",
),
)
.arg(
Arg::new("failure_issue_threshold")
.long("failure-issue-threshold")
.value_parser(clap::value_parser!(u64).range(1..))
.requires("schedule")
.help(
"The number of consecutive missed or error check-ins that trigger an \
issue. Requires --schedule.",
),
)
.arg(
Arg::new("recovery_threshold")
.long("recovery-threshold")
.value_parser(clap::value_parser!(u64).range(1..))
.requires("schedule")
.help(
"The number of consecutive successful check-ins that resolve an \
issue. Requires --schedule.",
),
)
}

fn run_program(args: Vec<&String>, monitor_slug: &str) -> (bool, Option<i32>, Duration) {
Expand Down Expand Up @@ -211,6 +231,8 @@ fn parse_monitor_config_args(matches: &ArgMatches) -> Result<Option<MonitorConfi
checkin_margin: matches.get_one("checkin_margin").copied(),
max_runtime: matches.get_one("max_runtime").copied(),
timezone: matches.get_one("timezone").map(Tz::to_string),
failure_issue_threshold: matches.get_one("failure_issue_threshold").copied(),
recovery_threshold: matches.get_one("recovery_threshold").copied(),
}))
}

Expand Down
5 changes: 5 additions & 0 deletions tests/integration/_cases/monitors/monitors-run-help.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ Options:
--timezone <timezone>
A tz database string (e.g. "Europe/Vienna") representing the monitor's execution
schedule's timezone. Requires --schedule.
--failure-issue-threshold <failure_issue_threshold>
The number of consecutive missed or error check-ins that trigger an issue. Requires
--schedule.
--recovery-threshold <recovery_threshold>
The number of consecutive successful check-ins that resolve an issue. Requires --schedule.
-h, --help
Print help

Expand Down

0 comments on commit aae9d2b

Please sign in to comment.