From 72c715016f4b59a5677a4c97e4ce2c58bf9114ec Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 24 Apr 2024 15:26:54 +0100 Subject: [PATCH] fetch: add trace logging to fetch protocol Log the following at the trace level: - Receiving the pack along with the amount of time it took - The closing of the connection Also organising the imports, while in the neighbourhood. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-fetch/src/transport/fetch.rs | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/radicle-fetch/src/transport/fetch.rs b/radicle-fetch/src/transport/fetch.rs index 5dfc1535..f56d1dad 100644 --- a/radicle-fetch/src/transport/fetch.rs +++ b/radicle-fetch/src/transport/fetch.rs @@ -1,23 +1,21 @@ -use std::{ - borrow::Cow, - io::{self, BufRead}, - path::PathBuf, - sync::{atomic::AtomicBool, Arc}, -}; +use std::borrow::Cow; +use std::io; +use std::io::BufRead; +use std::path::PathBuf; +use std::sync::{atomic::AtomicBool, Arc}; use gix_features::progress::NestedProgress; use gix_pack as pack; -use gix_protocol::{ - fetch::{self, Delegate, DelegateBlocking}, - handshake::{self, Ref}, - ls_refs, FetchConnection, -}; -use gix_transport::{ - bstr::BString, - client, - client::{ExtendedBufRead, MessageKind}, - Protocol, -}; +use gix_protocol::fetch; +use gix_protocol::fetch::{Delegate, DelegateBlocking}; +use gix_protocol::handshake; +use gix_protocol::handshake::Ref; +use gix_protocol::ls_refs; +use gix_protocol::FetchConnection; +use gix_transport::bstr::BString; +use gix_transport::client; +use gix_transport::client::{ExtendedBufRead, MessageKind}; +use gix_transport::Protocol; use super::{agent_name, indicate_end_of_interaction, Connection, WantsHaves}; @@ -253,6 +251,7 @@ where if !sideband_all { setup_remote_progress(progress, &mut reader); } + let timer = std::time::Instant::now(); // TODO: remove delegate in favor of functional style to fix progress-hack, // needed as it needs `'static`. As the top-level seems to pass `Discard`, // there should be no repercussions right now. @@ -262,6 +261,7 @@ where &[], &response, )?; + log::trace!(target: "fetch", "Received pack ({}ms)", timer.elapsed().as_millis()); assert_eq!( reader.stopped_at(), None, @@ -286,6 +286,7 @@ where if matches!(protocol, Protocol::V2) && matches!(conn.mode, FetchConnection::TerminateOnSuccessfulCompletion) { + log::trace!(target: "fetch", "Indicating end of interaction"); indicate_end_of_interaction(&mut conn)?; }