From e0b251a9e7f0b66b6d17feb3d9a16fb0ea41fb1d Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 7 Jan 2026 14:55:32 -0500 Subject: [PATCH] Instrument durable task execution with current span This preserves the distibuted OTEL trace context --- src/worker.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/worker.rs b/src/worker.rs index 11e641f..b28ce49 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use std::time::Duration; use tokio::sync::{RwLock, Semaphore, broadcast, mpsc}; use tokio::time::{Instant, sleep, sleep_until}; -use tracing::Instrument; +use tracing::{Instrument, Span}; use uuid::Uuid; use crate::context::TaskContext; @@ -380,9 +380,11 @@ impl Worker { drop(registry); // Execute task with timeout enforcement + // We instrument the actual task execution itself, to continue the trace context + // all the way through to the individual task steps let task_handle = tokio::spawn({ let params = task.params.clone(); - async move { handler.execute(params, ctx, state).await } + (async move { handler.execute(params, ctx, state).await }).instrument(Span::current()) }); let abort_handle = task_handle.abort_handle();