Skip to content

Commit c750e92

Browse files
committed
refactor(coprocessor): replace parent: &span with span.in_scope()
The explicit `parent: &span` pattern on log macros bypasses the OtelJsonFormat trace_id injection layer. Replace with `span.in_scope()` which enters the span as the current context, allowing the formatting layer to see it. Each usage is a synchronous log call with no .await inside, so thread-jumping is not a concern.
1 parent 6fab718 commit c750e92

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

coprocessor/fhevm-engine/sns-worker/src/executor.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,12 @@ pub async fn garbage_collect(pool: &PgPool, limit: u32) -> Result<(), ExecutionE
341341
cleanup_span.record("rows_affected", rows_affected as i64);
342342

343343
if rows_affected > 0 {
344-
info!(parent: &cleanup_span,
345-
rows_affected = rows_affected,
346-
"Cleaning up old ciphertexts128"
347-
);
344+
cleanup_span.in_scope(|| {
345+
info!(
346+
rows_affected = rows_affected,
347+
"Cleaning up old ciphertexts128"
348+
)
349+
});
348350
}
349351

350352
Ok(())

coprocessor/fhevm-engine/transaction-sender/src/ops/verify_proof.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,19 @@ where
292292

293293
let txn_request = match row.verified {
294294
Some(true) => {
295-
info!(parent: &span, zk_proof_id = row.zk_proof_id, "Processing verified proof");
295+
span.in_scope(|| {
296+
info!(zk_proof_id = row.zk_proof_id, "Processing verified proof")
297+
});
296298
let handles = row
297299
.handles
298300
.ok_or(anyhow::anyhow!("handles field is None"))?;
299301
if handles.len() % 32 != 0 {
300-
error!(parent: &span,
301-
handles_len = handles.len(),
302-
"Bad handles field, len is not divisible by 32"
303-
);
302+
span.in_scope(|| {
303+
error!(
304+
handles_len = handles.len(),
305+
"Bad handles field, len is not divisible by 32"
306+
)
307+
});
304308
self.remove_proof_by_id(row.zk_proof_id)
305309
.instrument(span.clone())
306310
.await?;
@@ -364,7 +368,9 @@ where
364368
}
365369
}
366370
Some(false) => {
367-
info!(parent: &span, zk_proof_id = row.zk_proof_id, "Processing rejected proof");
371+
span.in_scope(|| {
372+
info!(zk_proof_id = row.zk_proof_id, "Processing rejected proof")
373+
});
368374
if let Some(gas) = self.gas {
369375
(
370376
row.zk_proof_id,
@@ -389,10 +395,12 @@ where
389395
}
390396
}
391397
None => {
392-
error!(parent: &span,
393-
zk_proof_id = row.zk_proof_id,
394-
"verified field is unexpectedly None for proof"
395-
);
398+
span.in_scope(|| {
399+
error!(
400+
zk_proof_id = row.zk_proof_id,
401+
"verified field is unexpectedly None for proof"
402+
)
403+
});
396404
continue;
397405
}
398406
};

0 commit comments

Comments
 (0)