From 4002dff48be3400302c47ae85c88e5fdaf14655a Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Wed, 13 Mar 2024 15:14:27 -0400 Subject: [PATCH] =?UTF-8?q?feat(mock-consensus):=20=E2=9E=B0=20record=20he?= =?UTF-8?q?ight=20in=20inner=20span?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this tweaks the fast-forward facilities (#3933, #4002) so that we record the height as a span field per-loop iteration, not as a field in the encompassing `#[instrument]` span. see #4005 for an example of the misleading `height: 0` logs this would generate. --- crates/test/mock-consensus/src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/test/mock-consensus/src/lib.rs b/crates/test/mock-consensus/src/lib.rs index d9de6b2dfc..046e454916 100644 --- a/crates/test/mock-consensus/src/lib.rs +++ b/crates/test/mock-consensus/src/lib.rs @@ -56,21 +56,19 @@ where /// Fast forwards a number of blocks. #[tracing::instrument( skip(self), - fields( - height = %self.height, - fast_forward.blocks = %blocks, - ) + fields(fast_forward.blocks = %blocks) )] pub async fn fast_forward(&mut self, blocks: usize) -> anyhow::Result<()> { use { tap::Tap, - tracing::{info, trace}, + tracing::{info, trace, trace_span, Instrument}, }; for i in 0..blocks { self.block() .execute() .tap(|_| trace!(%i, "executing empty block")) + .instrument(trace_span!("executing empty block", %i)) .await .tap(|_| trace!(%i, "finished executing empty block"))?; }