Skip to content

Commit

Permalink
refactor(iroh-net): Log best addr on debug if not changed (#1958)
Browse files Browse the repository at this point in the history
## Description

The best addr is renewed every few seconds, always logging this on
info level floods the info log.  Now we log it on debug if the address
has not changed.  Logging that is still useful since it shows how long
the validity is and the latency.

## Notes & open questions


## Change checklist

- [x] Self-review.

Co-authored-by: Friedel Ziegelmayer <[email protected]>
  • Loading branch information
flub and dignifiedquire authored Jan 18, 2024
1 parent d5502b1 commit db41c5e
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions iroh-net/src/magicsock/peer_map/best_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

use iroh_metrics::inc;
use tracing::info;
use tracing::{debug, info};

use crate::magicsock::metrics::Metrics as MagicsockMetrics;

Expand Down Expand Up @@ -149,12 +149,26 @@ impl BestAddr {
) {
let trust_until = source.trust_until(confirmed_at);

info!(
%addr,
latency = ?latency,
trust_for = ?trust_until.duration_since(Instant::now()),
"new best_addr"
);
if self
.0
.as_ref()
.map(|prev| prev.addr.addr == addr)
.unwrap_or_default()
{
debug!(
%addr,
latency = ?latency,
trust_for = ?trust_until.duration_since(Instant::now()),
"new best_addr"
);
} else {
info!(
%addr,
latency = ?latency,
trust_for = ?trust_until.duration_since(Instant::now()),
"new best_addr"
);
}
let was_empty = self.is_empty();
let inner = BestAddrInner {
addr: AddrLatency { addr, latency },
Expand Down

0 comments on commit db41c5e

Please sign in to comment.