diff --git a/crates/syn2mas/src/mas_writer/mod.rs b/crates/syn2mas/src/mas_writer/mod.rs index 8193047f3..6fd9e5df4 100644 --- a/crates/syn2mas/src/mas_writer/mod.rs +++ b/crates/syn2mas/src/mas_writer/mod.rs @@ -22,7 +22,7 @@ use sqlx::{Executor, PgConnection, query, query_as}; use thiserror::Error; use thiserror_ext::{Construct, ContextInto}; use tokio::sync::mpsc::{self, Receiver, Sender}; -use tracing::{Level, error, info, warn}; +use tracing::{Instrument, Level, error, info, warn}; use uuid::{NonNilUuid, Uuid}; use self::{ @@ -119,18 +119,21 @@ impl WriterConnectionPool { match self.connection_rx.recv().await { Some(Ok(mut connection)) => { let connection_tx = self.connection_tx.clone(); - tokio::task::spawn(async move { - let to_return = match task(&mut connection).await { - Ok(()) => Ok(connection), - Err(error) => { - error!("error in writer: {error}"); - Err(error) - } - }; - // This should always succeed in sending unless we're already shutting - // down for some other reason. - let _: Result<_, _> = connection_tx.send(to_return).await; - }); + tokio::task::spawn( + async move { + let to_return = match task(&mut connection).await { + Ok(()) => Ok(connection), + Err(error) => { + error!("error in writer: {error}"); + Err(error) + } + }; + // This should always succeed in sending unless we're already shutting + // down for some other reason. + let _: Result<_, _> = connection_tx.send(to_return).await; + } + .instrument(tracing::debug_span!("spawn_with_connection")), + ); Ok(()) }