Skip to content

Commit

Permalink
feat: improve tracing in iroh-net
Browse files Browse the repository at this point in the history
  • Loading branch information
Frando committed Oct 18, 2023
1 parent 0390b86 commit d2b2a24
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 208 deletions.
8 changes: 3 additions & 5 deletions iroh-net/src/derp/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use tokio::sync::oneshot;
use tokio::sync::Mutex;
use tokio::task::JoinHandle;
use tokio::time::Instant;
use tracing::{debug, info, info_span, instrument, trace, warn, Instrument};
use tracing::{debug, info, info_span, trace, warn, Instrument};
use url::Url;

use crate::derp::{
Expand Down Expand Up @@ -389,7 +389,7 @@ impl Client {
trace!("got connection, conn num {conn_gen}");
Ok((derp_client, conn_gen))
}
.instrument(info_span!("client-connect", %key))
.instrument(info_span!("client-connect", key = %key.fmt_short()))
.await
}

Expand Down Expand Up @@ -459,7 +459,6 @@ impl Client {
true
}

#[instrument(level = "debug", skip_all)]
async fn connect_0(&self) -> Result<DerpClient, ClientError> {
let url = self.url();
let is_test_url = url
Expand Down Expand Up @@ -865,10 +864,9 @@ impl Client {

/// Reads a message from the server. Returns the message and the `conn_get`, or the number of
/// re-connections this Client has ever made
#[instrument(skip(self))]
pub async fn recv_detail(&self) -> Result<(ReceivedMessage, usize), ClientError> {
loop {
debug!("recv_detail tick");
trace!("recv_detail tick");
let (client, conn_gen) = self.connect().await?;
match client.recv().await {
Ok(msg) => {
Expand Down
6 changes: 3 additions & 3 deletions iroh-net/src/disco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ impl Display for Message {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Message::Ping(ping) => {
write!(f, "ping tx={:?}", &ping.tx_id[..6])
write!(f, "Ping(tx={})", hex::encode(&ping.tx_id))
}
Message::Pong(pong) => {
write!(f, "ping tx={:?}", &pong.tx_id[..6])
write!(f, "Pong(tx={})", hex::encode(&pong.tx_id))
}
Message::CallMeMaybe(_) => {
write!(f, "call-me-maybe")
write!(f, "CallMeMaybe")
}
}
}
Expand Down
Loading

0 comments on commit d2b2a24

Please sign in to comment.