diff --git a/src/api.rs b/src/api.rs index e9eb95d0b4..761f4220a8 100644 --- a/src/api.rs +++ b/src/api.rs @@ -2490,11 +2490,13 @@ pub struct MonitorCheckIn { pub id: Uuid, pub status: Option, pub duration: Option, + pub environment: Option, } #[derive(Debug, Serialize)] pub struct CreateMonitorCheckIn { pub status: MonitorCheckinStatus, + pub environment: String, } #[derive(Debug, Serialize, Default)] @@ -2503,6 +2505,8 @@ pub struct UpdateMonitorCheckIn { pub status: Option, #[serde(skip_serializing_if = "Option::is_none")] pub duration: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub environment: Option, } #[derive(Deserialize, Debug)] diff --git a/src/commands/monitors/run.rs b/src/commands/monitors/run.rs index e6e1bb6aaf..303d8b6d37 100644 --- a/src/commands/monitors/run.rs +++ b/src/commands/monitors/run.rs @@ -19,6 +19,12 @@ pub fn make_command(command: Command) -> Command { .help("The monitor slug.") .required(true), ) + .arg( + Arg::new("environment") + .short('e') + .default_value("production") + .help("Specify the environment of the monitor."), + ) .arg( Arg::new("allow_failure") .short('f') @@ -47,6 +53,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { } let monitor_slug = matches.get_one::("monitor_slug").unwrap(); + let environment = matches.get_one::("environment").unwrap(); let allow_failure = matches.get_flag("allow_failure"); let args: Vec<_> = matches.get_many::("args").unwrap().collect(); @@ -56,6 +63,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { monitor_slug, &CreateMonitorCheckIn { status: MonitorCheckinStatus::InProgress, + environment: environment.to_string(), }, ); @@ -93,6 +101,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { let elapsed = started.elapsed(); elapsed.as_secs() * 1000 + u64::from(elapsed.subsec_millis()) }), + environment: Some(environment.to_string()), }, ) .ok(); diff --git a/tests/integration/_cases/monitors/monitors-run-help.trycmd b/tests/integration/_cases/monitors/monitors-run-help.trycmd index 7d6e595c48..b68a5f5f61 100644 --- a/tests/integration/_cases/monitors/monitors-run-help.trycmd +++ b/tests/integration/_cases/monitors/monitors-run-help.trycmd @@ -10,6 +10,7 @@ Arguments: ... Options: + -e Specify the environment of the monitor. [default: production] -f, --allow-failure Run provided command even when Sentry reports an error. --header Custom headers that should be attached to all requests in key:value format.