Skip to content

Commit 2d2b7cd

Browse files
committed
chore: add trace_id to root span
1 parent 712a0da commit 2d2b7cd

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "builder"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
description = "signet builder example"
55

66
edition = "2024"

src/tasks/env.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ use alloy::{
1010
primitives::{B256, U256},
1111
providers::{Provider, network::Network},
1212
};
13+
use init4_bin_base::deps::{
14+
opentelemetry::trace::TraceContextExt, tracing_opentelemetry::OpenTelemetrySpanExt,
15+
};
1316
use signet_constants::SignetSystemConstants;
1417
use signet_sim::{HostEnv, RollupEnv};
1518
use tokio::{sync::watch, task::JoinHandle};
@@ -275,17 +278,22 @@ impl EnvTask {
275278

276279
// This span will be updated at the end of each loop iteration.
277280
let mut span = info_span!(
281+
parent: None,
278282
"SimEnv",
279283
host_block.number = "initial",
280284
rollup_header.number = "initial",
281285
rollup_header.hash = "initial",
286+
trace_id = tracing::field::Empty,
282287
);
283288

284289
while let Some(rollup_header) = rollup_headers
285290
.next()
286291
.instrument(info_span!(parent: &span, "waiting_for_notification"))
287292
.await
288293
{
294+
// Ensure that we record the OpenTelemetry trace ID in the span.
295+
span.record("trace_id", span.context().span().span_context().trace_id().to_string());
296+
289297
let host_block_number =
290298
self.config.constants.rollup_block_to_host_block_num(rollup_header.number);
291299
let rollup_block_number = rollup_header.number;
@@ -299,12 +307,10 @@ impl EnvTask {
299307
self.host_provider
300308
.get_block_by_number(host_block_number.into())
301309
.into_future()
302-
.instrument(
303-
debug_span!(parent: &span, "EnvTask::fetch_host_block", %host_block_number)
304-
),
310+
.instrument(debug_span!(parent: &span, "EnvTask::fetch_host_block")),
305311
// We want to check that we're able to sign for the block we're gonna start building.
306312
// If not, we just want to skip all the work.
307-
self.quincey.preflight_check(host_block_number + 1),
313+
self.quincey.preflight_check(host_block_number + 1).in_current_span(),
308314
);
309315

310316
res_unwrap_or_continue!(
@@ -360,6 +366,7 @@ impl EnvTask {
360366
host_block.number = host_block_number + 1,
361367
rollup_header.number = rollup_block_number + 1,
362368
rollup_header.hash = tracing::field::Empty,
369+
trace_id = tracing::field::Empty,
363370
);
364371
}
365372
}

0 commit comments

Comments
 (0)