Skip to content

Commit

Permalink
postgres: Fix tracing span when dropping PgListener
Browse files Browse the repository at this point in the history
  • Loading branch information
chitoku-k committed Feb 7, 2025
1 parent 3a20a92 commit 563a200
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sqlx-postgres/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use futures_util::{FutureExt, StreamExt, TryFutureExt, TryStreamExt};
use sqlx_core::acquire::Acquire;
use sqlx_core::transaction::Transaction;
use sqlx_core::Either;
use tracing::{Instrument, Span};

use crate::describe::Describe;
use crate::error::Error;
Expand All @@ -30,6 +31,7 @@ pub struct PgListener {
buffer_rx: mpsc::UnboundedReceiver<Notification>,
buffer_tx: Option<mpsc::UnboundedSender<Notification>>,
channels: Vec<String>,
span: Span,
ignore_close_event: bool,
eager_reconnect: bool,
}
Expand Down Expand Up @@ -69,6 +71,7 @@ impl PgListener {
buffer_rx: receiver,
buffer_tx: None,
channels: Vec::new(),
span: Span::current(),
ignore_close_event: false,
eager_reconnect: true,
})
Expand Down Expand Up @@ -366,7 +369,7 @@ impl Drop for PgListener {
};

// Unregister any listeners before returning the connection to the pool.
crate::rt::spawn(fut);
crate::rt::spawn(fut.instrument(self.span.clone()));
}
}
}
Expand Down

0 comments on commit 563a200

Please sign in to comment.