Skip to content

Commit a92626d

Browse files
chitoku-kabonander
authored andcommitted
postgres: Use current tracing span when dropping PgListener
1 parent c3fd645 commit a92626d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

sqlx-core/src/ext/async_stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'a, T> Stream for TryAsyncStream<'a, T> {
121121
#[macro_export]
122122
macro_rules! try_stream {
123123
($($block:tt)*) => {
124-
$crate::ext::async_stream::TryAsyncStream::new(move |yielder| async move {
124+
$crate::ext::async_stream::TryAsyncStream::new(move |yielder| ::tracing::Instrument::in_current_span(async move {
125125
// Anti-footgun: effectively pins `yielder` to this future to prevent any accidental
126126
// move to another task, which could deadlock.
127127
let yielder = &yielder;
@@ -133,6 +133,6 @@ macro_rules! try_stream {
133133
}
134134

135135
$($block)*
136-
})
136+
}))
137137
}
138138
}

sqlx-postgres/src/listener.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use futures_util::{FutureExt, StreamExt, TryFutureExt, TryStreamExt};
99
use sqlx_core::acquire::Acquire;
1010
use sqlx_core::transaction::Transaction;
1111
use sqlx_core::Either;
12+
use tracing::Instrument;
1213

1314
use crate::describe::Describe;
1415
use crate::error::Error;
@@ -366,7 +367,7 @@ impl Drop for PgListener {
366367
};
367368

368369
// Unregister any listeners before returning the connection to the pool.
369-
crate::rt::spawn(fut);
370+
crate::rt::spawn(fut.in_current_span());
370371
}
371372
}
372373
}

0 commit comments

Comments
 (0)