-
-
Notifications
You must be signed in to change notification settings - Fork 5
fix(uptime): remove and prevent unwrap/panic #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,10 +68,7 @@ async fn do_request( | |
| check_config: &CheckConfig, | ||
| sentry_trace: &str, | ||
| ) -> Result<(Response, RequestId), reqwest::Error> { | ||
| let timeout = check_config | ||
| .timeout | ||
| .to_std() | ||
| .expect("Timeout duration should be representable as a duration"); | ||
| let timeout = check_config.timeout.to_std().unwrap_or_default(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: A negative 🔍 Detailed AnalysisThe change from 💡 Suggested FixInstead of using 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
||
| let url = check_config.url.as_str(); | ||
|
|
||
|
|
@@ -312,15 +309,17 @@ fn run_assertion( | |
| ) -> Check { | ||
| let comp_assert = assert_cache.get_or_compile(assertion); | ||
|
|
||
| if let Err(err) = comp_assert { | ||
| tracing::warn!( | ||
| "a bad assertion made it to compile from {} : {}", | ||
| subscription_id, | ||
| err.to_string(), | ||
| ); | ||
| return Check::assert_compile_failure(&err); | ||
| } | ||
| let assertion = comp_assert.expect("already tested above"); | ||
| let assertion = match comp_assert { | ||
| Ok(assertion) => assertion, | ||
| Err(err) => { | ||
| tracing::warn!( | ||
| "a bad assertion made it to compile from {} : {}", | ||
| subscription_id, | ||
| err.to_string(), | ||
| ); | ||
| return Check::assert_compile_failure(&err); | ||
| } | ||
| }; | ||
|
|
||
| let result = assertion.eval(r.status().as_u16(), r.headers(), body_bytes); | ||
|
|
||
|
|
@@ -388,16 +387,15 @@ fn to_errored_request_infos( | |
| // connection error_ will require some effort, so for now, just bill the full time to the part that | ||
| // we failed on, leaving the others at zero. | ||
|
|
||
| let request_duration = | ||
| TimeDelta::from_std(start.elapsed()).expect("duration shouldn't be large"); | ||
| let request_duration = TimeDelta::from_std(start.elapsed()).unwrap_or_default(); | ||
| let zero_timing = Timing { | ||
| start_us: actual_check_time.timestamp_micros() as u128, | ||
| duration_us: 0, | ||
| }; | ||
|
|
||
| let full_duration = Timing { | ||
| start_us: actual_check_time.timestamp_micros() as u128, | ||
| duration_us: request_duration.num_microseconds().unwrap() as u64, | ||
| duration_us: request_duration.num_microseconds().unwrap_or(0) as u64, | ||
| }; | ||
|
|
||
| let mut dns_timing = zero_timing; | ||
|
|
@@ -424,7 +422,7 @@ fn to_errored_request_infos( | |
| request_body_size_bytes: check.get_config().request_body.len() as u32, | ||
| url: check.get_config().url.clone(), | ||
| response_body_size_bytes: 0, | ||
| request_duration_us: request_duration.num_microseconds().unwrap() as u64, | ||
| request_duration_us: request_duration.num_microseconds().unwrap_or(0) as u64, | ||
| durations: RequestDurations { | ||
| dns_lookup: dns_timing, | ||
| tcp_connection: connection_timing, | ||
|
|
@@ -493,9 +491,9 @@ impl Checker for ReqwestChecker { | |
| let check_result = to_check_result(&self.assert_cache, response, check, &body_bytes); | ||
|
|
||
| // Our total duration includes the additional processing time, including running the assert. | ||
| let duration = TimeDelta::from_std(start.elapsed()).expect("duration shouldn't be large"); | ||
| let duration = TimeDelta::from_std(start.elapsed()).unwrap_or_default(); | ||
|
|
||
| let final_req = rinfos.last().unwrap().clone(); | ||
| let request_info = rinfos.last().cloned(); | ||
|
|
||
| CheckResult { | ||
| guid: trace_id, | ||
|
|
@@ -510,7 +508,7 @@ impl Checker for ReqwestChecker { | |
| actual_check_time_us: actual_check_time, | ||
| duration: Some(duration), | ||
| duration_us: Some(duration), | ||
| request_info: Some(final_req), | ||
| request_info, | ||
| region, | ||
| request_info_list: rinfos, | ||
| assertion_failure_data: check_result.assert_path, | ||
|
|
||
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.