mirror of
https://github.com/tlsnotary/tlsn.git
synced 2026-01-09 21:38:00 -05:00
feat(notary): Log notarization elapsed time (#746)
* Log notarisation elapsed time * Fix formatting * Include time units in field name
This commit is contained in:
@@ -7,6 +7,7 @@ use axum_core::body::Body;
|
||||
use hyper::upgrade::{OnUpgrade, Upgraded};
|
||||
use hyper_util::rt::TokioIo;
|
||||
use std::future::Future;
|
||||
use tokio::time::Instant;
|
||||
use tracing::{debug, error, info};
|
||||
|
||||
use crate::{domain::notary::NotaryGlobals, service::notary_service, NotaryServerError};
|
||||
@@ -84,13 +85,22 @@ pub async fn tcp_notarize(
|
||||
notary_globals: NotaryGlobals,
|
||||
session_id: String,
|
||||
) {
|
||||
let start = Instant::now();
|
||||
debug!(?session_id, "Upgraded to tcp connection");
|
||||
match notary_service(stream, notary_globals, &session_id).await {
|
||||
Ok(_) => {
|
||||
info!(?session_id, "Successful notarization using tcp!");
|
||||
info!(
|
||||
?session_id,
|
||||
elapsed_time_millis = start.elapsed().as_millis(),
|
||||
"Successful notarization using tcp!"
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
error!(?session_id, "Failed notarization using tcp: {err}");
|
||||
error!(
|
||||
?session_id,
|
||||
elapsed_time_millis = start.elapsed().as_millis(),
|
||||
"Failed notarization using tcp: {err}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use tokio::time::Instant;
|
||||
use tracing::{debug, error, info};
|
||||
use ws_stream_tungstenite::WsStream;
|
||||
|
||||
@@ -12,16 +13,25 @@ pub async fn websocket_notarize(
|
||||
notary_globals: NotaryGlobals,
|
||||
session_id: String,
|
||||
) {
|
||||
let start = Instant::now();
|
||||
debug!(?session_id, "Upgraded to websocket connection");
|
||||
// Wrap the websocket in WsStream so that we have AsyncRead and AsyncWrite
|
||||
// implemented
|
||||
let stream = WsStream::new(socket.into_inner());
|
||||
match notary_service(stream, notary_globals, &session_id).await {
|
||||
Ok(_) => {
|
||||
info!(?session_id, "Successful notarization using websocket!");
|
||||
info!(
|
||||
?session_id,
|
||||
elapsed_time_millis = start.elapsed().as_millis(),
|
||||
"Successful notarization using websocket!"
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
error!(?session_id, "Failed notarization using websocket: {err}");
|
||||
error!(
|
||||
?session_id,
|
||||
elapsed_time_millis = start.elapsed().as_millis(),
|
||||
"Failed notarization using websocket: {err}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user