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 Feb 23, 2024
1 parent bb93e1e commit 597f45a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion rad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ async fn http_response(
})
})?;

let start_ts = std::time::SystemTime::now();
let response = client
.send(request)
.await
Expand All @@ -306,7 +307,21 @@ async fn http_response(
message: x.to_string(),
})?;

let result = run_retrieval_with_data_report(retrieve, &response_string, context, settings);
let result = run_retrieval_with_data_report(retrieve, &response_string, 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) => {
Expand Down

0 comments on commit 597f45a

Please sign in to comment.