From 32e16ec9278cf0c9cfca4e9f59bdf35d1b679cb0 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 12 Mar 2024 21:13:15 +1100 Subject: [PATCH] feat(relay): improve logs for expiry and deletion of channel bindings (#4089) Unfortunately, the current logs don't allow us to correlate, which allocation and thus which client the expired channel binding relates to. This PR fixes this by adding more fields to the relevant log messages. --- rust/relay/src/server.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rust/relay/src/server.rs b/rust/relay/src/server.rs index af3e89b15..3193fba4a 100644 --- a/rust/relay/src/server.rs +++ b/rust/relay/src/server.rs @@ -395,7 +395,7 @@ where match action { TimedAction::ExpireAllocation(id) => { let Some(allocation) = self.get_allocation(&id) else { - tracing::debug!(target: "relay", "Cannot expire non-existing allocation {id}"); + tracing::debug!(target: "relay", allocation = %id, "Cannot expire non-existing allocation"); continue; }; @@ -407,13 +407,13 @@ where TimedAction::UnbindChannel((client, chan)) => { let Some(channel) = self.channels_by_client_and_number.get_mut(&(client, chan)) else { - tracing::debug!(target: "relay", "Cannot expire non-existing channel binding {chan} of client {client}"); + tracing::debug!(target: "relay", channel = %chan, %client, "Cannot expire non-existing channel binding"); continue; }; if channel.is_expired(now) { - tracing::info!(target: "relay", "Channel {chan} is now expired"); + tracing::info!(target: "relay", channel = %chan, %client, peer = %channel.peer_address, allocation = %channel.allocation, "Channel is now expired"); channel.bound = false; @@ -972,11 +972,12 @@ where return; }; - let addr = channel.peer_address; + let peer = channel.peer_address; + let allocation = channel.allocation; let _peer_channel = self .channel_numbers_by_client_and_peer - .remove(&(client, addr)); + .remove(&(client, peer)); debug_assert_eq!( _peer_channel, Some(chan), @@ -984,6 +985,8 @@ where ); self.channels_by_client_and_number.remove(&(client, chan)); + + tracing::info!(target: "relay", channel = %chan, %client, %peer, %allocation, "Channel binding is now deleted (and can be rebound)"); } }