diff --git a/zebra-network/src/peer_set/initialize.rs b/zebra-network/src/peer_set/initialize.rs index 76eb68cbe11..a065d474493 100644 --- a/zebra-network/src/peer_set/initialize.rs +++ b/zebra-network/src/peer_set/initialize.rs @@ -603,39 +603,46 @@ where ); let connected_addr = peer::ConnectedAddr::new_inbound_direct(addr); - info!(peer = ?connected_addr, "listen_accept"); - - debug!("got incoming connection"); - handshaker.ready().await?; - // TODO: distinguish between proxied listeners and direct listeners - let handshaker_span = info_span!("listen_handshaker", peer = ?connected_addr); - - // Construct a handshake future but do not drive it yet.... - let handshake = handshaker.call(HandshakeRequest { - data_stream: tcp_stream, - connected_addr, - connection_tracker, + let accept_span = info_span!("listen_accept", peer = ?connected_addr); + accept_span.in_scope(|| { + debug!("got incoming connection"); }); - // ... instead, spawn a new task to handle this connection - { - let mut peerset_tx = peerset_tx.clone(); - let handshake_task = tokio::spawn( - async move { - let handshake_result = handshake.await; + handshaker.ready().await?; - if let Ok(client) = handshake_result { - // The connection limit makes sure this send doesn't block - let _ = peerset_tx.send((addr, client)).await; - } else { - debug!(?handshake_result, "error handshaking with inbound peer"); + accept_span.in_scope(|| { + debug!("got incoming connection"); + + // TODO: distinguish between proxied listeners and direct listeners + let handshaker_span = info_span!("listen_handshaker", peer = ?connected_addr); + + // Construct a handshake future but do not drive it yet.... + let handshake = handshaker.call(HandshakeRequest { + data_stream: tcp_stream, + connected_addr, + connection_tracker, + }); + // ... instead, spawn a new task to handle this connection + { + let mut peerset_tx = peerset_tx.clone(); + + let handshake_task = tokio::spawn( + async move { + let handshake_result = handshake.await; + + if let Ok(client) = handshake_result { + // The connection limit makes sure this send doesn't block + let _ = peerset_tx.send((addr, client)).await; + } else { + debug!(?handshake_result, "error handshaking with inbound peer"); + } } - } - .instrument(handshaker_span), - ); + .instrument(handshaker_span), + ); - handshakes.push(Box::pin(handshake_task)); - } + handshakes.push(Box::pin(handshake_task)); + } + }); // Rate-limit inbound connection handshakes. // But sleep longer after a successful connection,