fix(logs): Avoid grouping logs for separate tasks (#6923)

* Removes span.enter() in async code

* Restores `accept_span` and uses in_scope() instead of enter()

* Update zebra-network/src/peer_set/initialize.rs
This commit is contained in:
Arya 2023-06-14 15:05:11 -04:00 committed by GitHub
parent dde790e92a
commit 9f0e18282c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -607,6 +607,13 @@ where
let _guard = accept_span.enter();
debug!("got incoming connection");
// # Correctness
//
// Holding the drop guard returned by Span::enter across .await points will
// result in incorrect traces if it yields.
//
// This await is okay because the handshaker's `poll_ready` method always returns Ready.
handshaker.ready().await?;
// TODO: distinguish between proxied listeners and direct listeners
let handshaker_span = info_span!("listen_handshaker", peer = ?connected_addr);
@ -638,6 +645,9 @@ where
handshakes.push(Box::pin(handshake_task));
}
// We need to drop the guard before yielding.
std::mem::drop(_guard);
// Rate-limit inbound connection handshakes.
// But sleep longer after a successful connection,
// so we can clear out failed connections at a higher rate.