Skip to content

Commit

Permalink
create uuid only when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Jan 30, 2023
1 parent b2e52ea commit b0c09df
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/commands/monitors/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
.map(|x| x.parse::<Uuid>().unwrap())
.unwrap();

let trace_id = Uuid::new_v4();

let allow_failure = matches.is_present("allow_failure");
let args: Vec<_> = matches.values_of("args").unwrap().collect();

Expand All @@ -61,9 +59,9 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
p.env("SENTRY_MONITOR_ID", monitor.to_string());

// Inherit outer SENTRY_TRACE_ID if present
if env::var_os("SENTRY_TRACE_ID").is_none() {
p.env("SENTRY_TRACE_ID", trace_id.to_string().replace("-", ""));
}
let trace_id = env::var_os("SENTRY_TRACE_ID")
.unwrap_or_else(|| Uuid::new_v4().simple().to_string().into());
p.env("SENTRY_TRACE_ID", trace_id);

let (success, code) = match p.status() {
Ok(status) => (status.success(), status.code()),
Expand Down

0 comments on commit b0c09df

Please sign in to comment.