Skip to content

Commit c8e9cb3

Browse files
authored
feat(notary): Log notarization elapsed time (#746)
* Log notarisation elapsed time * Fix formatting * Include time units in field name
1 parent 4dc5570 commit c8e9cb3

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

crates/notary/server/src/service/tcp.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use axum_core::body::Body;
77
use hyper::upgrade::{OnUpgrade, Upgraded};
88
use hyper_util::rt::TokioIo;
99
use std::future::Future;
10+
use tokio::time::Instant;
1011
use tracing::{debug, error, info};
1112

1213
use crate::{domain::notary::NotaryGlobals, service::notary_service, NotaryServerError};
@@ -84,13 +85,22 @@ pub async fn tcp_notarize(
8485
notary_globals: NotaryGlobals,
8586
session_id: String,
8687
) {
88+
let start = Instant::now();
8789
debug!(?session_id, "Upgraded to tcp connection");
8890
match notary_service(stream, notary_globals, &session_id).await {
8991
Ok(_) => {
90-
info!(?session_id, "Successful notarization using tcp!");
92+
info!(
93+
?session_id,
94+
elapsed_time_millis = start.elapsed().as_millis(),
95+
"Successful notarization using tcp!"
96+
);
9197
}
9298
Err(err) => {
93-
error!(?session_id, "Failed notarization using tcp: {err}");
99+
error!(
100+
?session_id,
101+
elapsed_time_millis = start.elapsed().as_millis(),
102+
"Failed notarization using tcp: {err}"
103+
);
94104
}
95105
}
96106
}

crates/notary/server/src/service/websocket.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use tokio::time::Instant;
12
use tracing::{debug, error, info};
23
use ws_stream_tungstenite::WsStream;
34

@@ -12,16 +13,25 @@ pub async fn websocket_notarize(
1213
notary_globals: NotaryGlobals,
1314
session_id: String,
1415
) {
16+
let start = Instant::now();
1517
debug!(?session_id, "Upgraded to websocket connection");
1618
// Wrap the websocket in WsStream so that we have AsyncRead and AsyncWrite
1719
// implemented
1820
let stream = WsStream::new(socket.into_inner());
1921
match notary_service(stream, notary_globals, &session_id).await {
2022
Ok(_) => {
21-
info!(?session_id, "Successful notarization using websocket!");
23+
info!(
24+
?session_id,
25+
elapsed_time_millis = start.elapsed().as_millis(),
26+
"Successful notarization using websocket!"
27+
);
2228
}
2329
Err(err) => {
24-
error!(?session_id, "Failed notarization using websocket: {err}");
30+
error!(
31+
?session_id,
32+
elapsed_time_millis = start.elapsed().as_millis(),
33+
"Failed notarization using websocket: {err}"
34+
);
2535
}
2636
}
2737
}

0 commit comments

Comments
 (0)