diff --git a/Cargo.lock b/Cargo.lock index 5784858..a689999 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2560,7 +2560,7 @@ dependencies = [ [[package]] name = "sqlx-tracing" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow", "futures", diff --git a/Cargo.toml b/Cargo.toml index 5c94ea7..97d6e41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqlx-tracing" -version = "0.2.0" +version = "0.2.1" edition = "2024" description = "OpenTelemetry-compatible tracing for SQLx database operations in Rust." license = "MIT" diff --git a/src/lib.rs b/src/lib.rs index ee99dbc..851aab5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,7 +110,7 @@ impl PoolBuilder { /// An asynchronous pool of SQLx database connections with tracing instrumentation. /// /// Wraps a SQLx [`Pool`] and propagates tracing attributes to all acquired connections. -#[derive(Clone, Debug)] +#[derive(Debug)] pub struct Pool where DB: sqlx::Database, @@ -119,6 +119,18 @@ where attributes: Arc, } +impl Clone for Pool +where + DB: sqlx::Database, +{ + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + attributes: Arc::clone(&self.attributes), + } + } +} + impl From> for Pool where DB: sqlx::Database, @@ -126,7 +138,7 @@ where { /// Convert a SQLx [`Pool`] into a tracing-instrumented [`Pool`]. fn from(inner: sqlx::Pool) -> Self { - PoolBuilder::from(inner).build() + PoolBuilder::from(inner.into()).build() } } diff --git a/tests/postgres.rs b/tests/postgres.rs index 0b2d0c6..7a788d7 100644 --- a/tests/postgres.rs +++ b/tests/postgres.rs @@ -3,6 +3,7 @@ use std::time::Duration; use sqlx::Postgres; +use sqlx_tracing::Pool; use testcontainers::{ GenericImage, ImageExt, core::{ContainerPort, WaitFor}, @@ -78,3 +79,9 @@ async fn execute() { .await; } } + +#[test] +fn pool_postgres_is_clone() { + fn assert_clone() {} + assert_clone::>(); +}