Demote some Peer logging to trace level

This commit is contained in:
Max Brunsfeld 2023-08-28 17:45:19 -07:00
parent 89eab78cf7
commit 5142049515

View file

@ -171,12 +171,12 @@ impl Peer {
let this = self.clone(); let this = self.clone();
let response_channels = connection_state.response_channels.clone(); let response_channels = connection_state.response_channels.clone();
let handle_io = async move { let handle_io = async move {
tracing::debug!(%connection_id, "handle io future: start"); tracing::trace!(%connection_id, "handle io future: start");
let _end_connection = util::defer(|| { let _end_connection = util::defer(|| {
response_channels.lock().take(); response_channels.lock().take();
this.connections.write().remove(&connection_id); this.connections.write().remove(&connection_id);
tracing::debug!(%connection_id, "handle io future: end"); tracing::trace!(%connection_id, "handle io future: end");
}); });
// Send messages on this frequency so the connection isn't closed. // Send messages on this frequency so the connection isn't closed.
@ -188,68 +188,68 @@ impl Peer {
futures::pin_mut!(receive_timeout); futures::pin_mut!(receive_timeout);
loop { loop {
tracing::debug!(%connection_id, "outer loop iteration start"); tracing::trace!(%connection_id, "outer loop iteration start");
let read_message = reader.read().fuse(); let read_message = reader.read().fuse();
futures::pin_mut!(read_message); futures::pin_mut!(read_message);
loop { loop {
tracing::debug!(%connection_id, "inner loop iteration start"); tracing::trace!(%connection_id, "inner loop iteration start");
futures::select_biased! { futures::select_biased! {
outgoing = outgoing_rx.next().fuse() => match outgoing { outgoing = outgoing_rx.next().fuse() => match outgoing {
Some(outgoing) => { Some(outgoing) => {
tracing::debug!(%connection_id, "outgoing rpc message: writing"); tracing::trace!(%connection_id, "outgoing rpc message: writing");
futures::select_biased! { futures::select_biased! {
result = writer.write(outgoing).fuse() => { result = writer.write(outgoing).fuse() => {
tracing::debug!(%connection_id, "outgoing rpc message: done writing"); tracing::trace!(%connection_id, "outgoing rpc message: done writing");
result.context("failed to write RPC message")?; result.context("failed to write RPC message")?;
tracing::debug!(%connection_id, "keepalive interval: resetting after sending message"); tracing::trace!(%connection_id, "keepalive interval: resetting after sending message");
keepalive_timer.set(create_timer(KEEPALIVE_INTERVAL).fuse()); keepalive_timer.set(create_timer(KEEPALIVE_INTERVAL).fuse());
} }
_ = create_timer(WRITE_TIMEOUT).fuse() => { _ = create_timer(WRITE_TIMEOUT).fuse() => {
tracing::debug!(%connection_id, "outgoing rpc message: writing timed out"); tracing::trace!(%connection_id, "outgoing rpc message: writing timed out");
Err(anyhow!("timed out writing message"))?; Err(anyhow!("timed out writing message"))?;
} }
} }
} }
None => { None => {
tracing::debug!(%connection_id, "outgoing rpc message: channel closed"); tracing::trace!(%connection_id, "outgoing rpc message: channel closed");
return Ok(()) return Ok(())
}, },
}, },
_ = keepalive_timer => { _ = keepalive_timer => {
tracing::debug!(%connection_id, "keepalive interval: pinging"); tracing::trace!(%connection_id, "keepalive interval: pinging");
futures::select_biased! { futures::select_biased! {
result = writer.write(proto::Message::Ping).fuse() => { result = writer.write(proto::Message::Ping).fuse() => {
tracing::debug!(%connection_id, "keepalive interval: done pinging"); tracing::trace!(%connection_id, "keepalive interval: done pinging");
result.context("failed to send keepalive")?; result.context("failed to send keepalive")?;
tracing::debug!(%connection_id, "keepalive interval: resetting after pinging"); tracing::trace!(%connection_id, "keepalive interval: resetting after pinging");
keepalive_timer.set(create_timer(KEEPALIVE_INTERVAL).fuse()); keepalive_timer.set(create_timer(KEEPALIVE_INTERVAL).fuse());
} }
_ = create_timer(WRITE_TIMEOUT).fuse() => { _ = create_timer(WRITE_TIMEOUT).fuse() => {
tracing::debug!(%connection_id, "keepalive interval: pinging timed out"); tracing::trace!(%connection_id, "keepalive interval: pinging timed out");
Err(anyhow!("timed out sending keepalive"))?; Err(anyhow!("timed out sending keepalive"))?;
} }
} }
} }
incoming = read_message => { incoming = read_message => {
let incoming = incoming.context("error reading rpc message from socket")?; let incoming = incoming.context("error reading rpc message from socket")?;
tracing::debug!(%connection_id, "incoming rpc message: received"); tracing::trace!(%connection_id, "incoming rpc message: received");
tracing::debug!(%connection_id, "receive timeout: resetting"); tracing::trace!(%connection_id, "receive timeout: resetting");
receive_timeout.set(create_timer(RECEIVE_TIMEOUT).fuse()); receive_timeout.set(create_timer(RECEIVE_TIMEOUT).fuse());
if let proto::Message::Envelope(incoming) = incoming { if let proto::Message::Envelope(incoming) = incoming {
tracing::debug!(%connection_id, "incoming rpc message: processing"); tracing::trace!(%connection_id, "incoming rpc message: processing");
futures::select_biased! { futures::select_biased! {
result = incoming_tx.send(incoming).fuse() => match result { result = incoming_tx.send(incoming).fuse() => match result {
Ok(_) => { Ok(_) => {
tracing::debug!(%connection_id, "incoming rpc message: processed"); tracing::trace!(%connection_id, "incoming rpc message: processed");
} }
Err(_) => { Err(_) => {
tracing::debug!(%connection_id, "incoming rpc message: channel closed"); tracing::trace!(%connection_id, "incoming rpc message: channel closed");
return Ok(()) return Ok(())
} }
}, },
_ = create_timer(WRITE_TIMEOUT).fuse() => { _ = create_timer(WRITE_TIMEOUT).fuse() => {
tracing::debug!(%connection_id, "incoming rpc message: processing timed out"); tracing::trace!(%connection_id, "incoming rpc message: processing timed out");
Err(anyhow!("timed out processing incoming message"))? Err(anyhow!("timed out processing incoming message"))?
} }
} }
@ -257,7 +257,7 @@ impl Peer {
break; break;
}, },
_ = receive_timeout => { _ = receive_timeout => {
tracing::debug!(%connection_id, "receive timeout: delay between messages too long"); tracing::trace!(%connection_id, "receive timeout: delay between messages too long");
Err(anyhow!("delay between messages too long"))? Err(anyhow!("delay between messages too long"))?
} }
} }
@ -274,13 +274,13 @@ impl Peer {
let response_channels = response_channels.clone(); let response_channels = response_channels.clone();
async move { async move {
let message_id = incoming.id; let message_id = incoming.id;
tracing::debug!(?incoming, "incoming message future: start"); tracing::trace!(?incoming, "incoming message future: start");
let _end = util::defer(move || { let _end = util::defer(move || {
tracing::debug!(%connection_id, message_id, "incoming message future: end"); tracing::trace!(%connection_id, message_id, "incoming message future: end");
}); });
if let Some(responding_to) = incoming.responding_to { if let Some(responding_to) = incoming.responding_to {
tracing::debug!( tracing::trace!(
%connection_id, %connection_id,
message_id, message_id,
responding_to, responding_to,
@ -290,7 +290,7 @@ impl Peer {
if let Some(tx) = channel { if let Some(tx) = channel {
let requester_resumed = oneshot::channel(); let requester_resumed = oneshot::channel();
if let Err(error) = tx.send((incoming, requester_resumed.0)) { if let Err(error) = tx.send((incoming, requester_resumed.0)) {
tracing::debug!( tracing::trace!(
%connection_id, %connection_id,
message_id, message_id,
responding_to = responding_to, responding_to = responding_to,
@ -299,14 +299,14 @@ impl Peer {
); );
} }
tracing::debug!( tracing::trace!(
%connection_id, %connection_id,
message_id, message_id,
responding_to, responding_to,
"incoming response: waiting to resume requester" "incoming response: waiting to resume requester"
); );
let _ = requester_resumed.1.await; let _ = requester_resumed.1.await;
tracing::debug!( tracing::trace!(
%connection_id, %connection_id,
message_id, message_id,
responding_to, responding_to,
@ -323,7 +323,7 @@ impl Peer {
None None
} else { } else {
tracing::debug!(%connection_id, message_id, "incoming message: received"); tracing::trace!(%connection_id, message_id, "incoming message: received");
proto::build_typed_envelope(connection_id, incoming).or_else(|| { proto::build_typed_envelope(connection_id, incoming).or_else(|| {
tracing::error!( tracing::error!(
%connection_id, %connection_id,