@@ -22,7 +22,7 @@ use sqlx::{query, query_as, Executor, PgConnection};
2222use thiserror:: Error ;
2323use thiserror_ext:: { Construct , ContextInto } ;
2424use tokio:: sync:: mpsc:: { self , Receiver , Sender } ;
25- use tracing:: { error, info, warn, Level , Span } ;
25+ use tracing:: { error, info, warn, Instrument , Level , Span } ;
2626use tracing_indicatif:: span_ext:: IndicatifSpanExt ;
2727use uuid:: Uuid ;
2828
@@ -120,18 +120,21 @@ impl WriterConnectionPool {
120120 match self . connection_rx . recv ( ) . await {
121121 Some ( Ok ( mut connection) ) => {
122122 let connection_tx = self . connection_tx . clone ( ) ;
123- tokio:: task:: spawn ( async move {
124- let to_return = match task ( & mut connection) . await {
125- Ok ( ( ) ) => Ok ( connection) ,
126- Err ( error) => {
127- error ! ( "error in writer: {error}" ) ;
128- Err ( error)
129- }
130- } ;
131- // This should always succeed in sending unless we're already shutting
132- // down for some other reason.
133- let _: Result < _ , _ > = connection_tx. send ( to_return) . await ;
134- } ) ;
123+ tokio:: task:: spawn (
124+ async move {
125+ let to_return = match task ( & mut connection) . await {
126+ Ok ( ( ) ) => Ok ( connection) ,
127+ Err ( error) => {
128+ error ! ( "error in writer: {error}" ) ;
129+ Err ( error)
130+ }
131+ } ;
132+ // This should always succeed in sending unless we're already shutting
133+ // down for some other reason.
134+ let _: Result < _ , _ > = connection_tx. send ( to_return) . await ;
135+ }
136+ . instrument ( tracing:: debug_span!( "spawn_with_connection" ) ) ,
137+ ) ;
135138
136139 Ok ( ( ) )
137140 }
0 commit comments