Skip to content

Commit 096986d

Browse files
committed
Log which request we started/ended
1 parent 6899a71 commit 096986d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ui/src/request_database.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use tokio::{
66
sync::{mpsc, oneshot},
77
task,
88
};
9-
use tracing::warn;
9+
use tracing::{info, warn, Instrument as _};
1010

1111
pub struct Database {
1212
db: Connection,
@@ -172,7 +172,11 @@ impl Handle {
172172
.drop_error_details()
173173
.context(SendStartRequestSnafu)?;
174174

175-
rx.await.context(RecvStartRequestSnafu)?.map_err(Into::into)
175+
let id = rx.await.context(RecvStartRequestSnafu)??;
176+
177+
info!(request_id = id.0, "Started request");
178+
179+
Ok(id)
176180
}
177181

178182
async fn attempt_start_request(
@@ -198,7 +202,11 @@ impl Handle {
198202
.drop_error_details()
199203
.context(SendEndRequestSnafu)?;
200204

201-
rx.await.context(RecvEndRequestSnafu)?.map_err(Into::into)
205+
rx.await.context(RecvEndRequestSnafu)??;
206+
207+
info!(request_id = id.0, "Ended request");
208+
209+
Ok(())
202210
}
203211

204212
async fn attempt_end_request(&self, id: Id, how: How) {
@@ -245,7 +253,7 @@ impl Drop for EndGuardInner {
245253
let Self(id, how, ref mut handle) = *self;
246254
if let Ok(h) = tokio::runtime::Handle::try_current() {
247255
if let Some(handle) = handle.take() {
248-
h.spawn(async move { handle.attempt_end_request(id, how).await });
256+
h.spawn(async move { handle.attempt_end_request(id, how).await }.in_current_span());
249257
}
250258
}
251259
}

0 commit comments

Comments
 (0)