Skip to content

Commit fe52842

Browse files
committed
refactor(coprocessor): remove last non-cross-boundary set_parent, document remaining
- Replace set_parent(t.context()) with parent: &t in batch_store span (same execution context, not cross-boundary) - Add comments on the two remaining set_parent calls explaining they restore OTel context across async/thread boundaries
1 parent 68f80b4 commit fe52842

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ async fn run_uploader_loop(
164164

165165
// Spawn a new task to upload the ciphertexts
166166
let h = tokio::spawn(async move {
167+
// Cross-boundary: spawned task; restore the OTel context
168+
// that was captured when the upload item was created.
167169
let upload_span = error_span!("upload_s3", operation = "upload_s3");
168170
upload_span.set_parent(item.otel.context());
169171
match upload_ciphertexts(trx, item, &client, &conf)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@ async fn fetch_and_execute_sns_tasks(
395395
update_computations_status(trx, &tasks).await?;
396396

397397
let batch_store_span = tracing::info_span!(
398+
parent: &t,
398399
"batch_store_ciphertext128",
399400
operation = "batch_store_ciphertext128"
400401
);
401-
batch_store_span.set_parent(t.context());
402402
let batch_store = async {
403403
update_ciphertext128(trx, &tasks).await?;
404404
notify_ciphertext128_ready(trx, &conf.db.notify_channel).await?;
@@ -569,6 +569,8 @@ fn compute_task(
569569
) {
570570
let started_at = SystemTime::now();
571571
let thread_id = format!("{:?}", std::thread::current().id());
572+
// Cross-boundary: compute_task runs on a thread-pool worker;
573+
// restore the OTel context that was captured when the task was enqueued.
572574
let span = error_span!("compute", thread_id = %thread_id);
573575
span.set_parent(task.otel.context());
574576
let _enter = span.enter();

0 commit comments

Comments
 (0)