Skip to content

Commit a21afd1

Browse files
committed
feat(rad): include retrieval response time within WitnetResultReports
1 parent bb93e1e commit a21afd1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

rad/src/lib.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ async fn http_response(
282282
})
283283
})?;
284284

285+
let start_ts = std::time::SystemTime::now();
285286
let response = client
286287
.send(request)
287288
.await
@@ -306,7 +307,20 @@ async fn http_response(
306307
message: x.to_string(),
307308
})?;
308309

309-
let result = run_retrieval_with_data_report(retrieve, &response_string, context, settings);
310+
let result = run_retrieval_with_data_report(retrieve, &response_string, context, settings).map(
311+
|report| {
312+
let completion_ts = std::time::SystemTime::now();
313+
RadonReport {
314+
context: ReportContext {
315+
start_time: Some(start_ts),
316+
completion_time: Some(completion_ts),
317+
..report.context
318+
},
319+
running_time: completion_ts.duration_since(start_ts).unwrap_or_default(),
320+
..report
321+
}
322+
},
323+
);
310324

311325
match &result {
312326
Ok(report) => {

0 commit comments

Comments
 (0)