Skip to content

Commit

Permalink
feat(rad): include retrieval response time within WitnetResultReports
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Dec 13, 2023
1 parent 179503c commit 6802cad
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion rad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ async fn http_response(
})
})?;

let start_ts = std::time::SystemTime::now();
let response = client
.send(request)
.await
Expand Down Expand Up @@ -322,7 +323,19 @@ async fn http_response(
response = RadonTypes::from(RadonString::from(response_string));
}

let result = handle_response_with_data_report(retrieve, response, context, settings);
let result = handle_response_with_data_report(retrieve, response, context, settings)
.map(|report| {
let completion_ts = std::time::SystemTime::now();
RadonReport {
context: ReportContext {
start_time: Some(start_ts),
completion_time: Some(completion_ts),
..report.context
},
running_time: completion_ts.duration_since(start_ts).unwrap_or_default(),
..report
}
});
match &result {
Ok(report) => {
log::debug!(
Expand Down

0 comments on commit 6802cad

Please sign in to comment.