@@ -28,6 +28,7 @@ pub struct SqlxPostgresConnector;
2828pub struct SqlxPostgresPoolConnection {
2929 pub ( crate ) pool : PgPool ,
3030 metric_callback : Option < crate :: metric:: Callback > ,
31+ pub ( crate ) record_stmt_in_spans : bool ,
3132}
3233
3334impl std:: fmt:: Debug for SqlxPostgresPoolConnection {
@@ -41,6 +42,7 @@ impl From<PgPool> for SqlxPostgresPoolConnection {
4142 SqlxPostgresPoolConnection {
4243 pool,
4344 metric_callback : None ,
45+ record_stmt_in_spans : true ,
4446 }
4547 }
4648}
@@ -60,6 +62,7 @@ impl SqlxPostgresConnector {
6062 /// Add configuration options for the PostgreSQL database
6163 #[ instrument( level = "trace" ) ]
6264 pub fn connect ( options : ConnectOptions ) -> Result < DatabaseConnection , DbErr > {
65+ let record_stmt_in_spans = options. get_record_stmt_in_spans ( ) ;
6366 let mut sqlx_opts = options
6467 . url
6568 . parse :: < PgConnectOptions > ( )
@@ -134,6 +137,7 @@ impl SqlxPostgresConnector {
134137 DatabaseConnectionType :: SqlxPostgresPoolConnection ( SqlxPostgresPoolConnection {
135138 pool,
136139 metric_callback : None ,
140+ record_stmt_in_spans,
137141 } )
138142 . into ( ) ;
139143
@@ -151,6 +155,7 @@ impl SqlxPostgresConnector {
151155 DatabaseConnectionType :: SqlxPostgresPoolConnection ( SqlxPostgresPoolConnection {
152156 pool,
153157 metric_callback : None ,
158+ record_stmt_in_spans : true ,
154159 } )
155160 . into ( )
156161 }
@@ -241,6 +246,7 @@ impl SqlxPostgresPoolConnection {
241246 DatabaseTransaction :: new_postgres (
242247 conn,
243248 self . metric_callback . clone ( ) ,
249+ self . record_stmt_in_spans ,
244250 isolation_level,
245251 access_mode,
246252 )
@@ -262,6 +268,7 @@ impl SqlxPostgresPoolConnection {
262268 let transaction = DatabaseTransaction :: new_postgres (
263269 conn,
264270 self . metric_callback . clone ( ) ,
271+ self . record_stmt_in_spans ,
265272 isolation_level,
266273 access_mode,
267274 )
@@ -372,13 +379,15 @@ impl crate::DatabaseTransaction {
372379 pub ( crate ) fn new_postgres (
373380 inner : PoolConnection < sqlx:: Postgres > ,
374381 metric_callback : Option < crate :: metric:: Callback > ,
382+ record_stmt_in_spans : bool ,
375383 isolation_level : Option < IsolationLevel > ,
376384 access_mode : Option < AccessMode > ,
377385 ) -> Result < crate :: DatabaseTransaction , DbErr > {
378386 Self :: begin (
379387 Arc :: new ( Mutex :: new ( crate :: InnerConnection :: Postgres ( inner) ) ) ,
380388 crate :: DbBackend :: Postgres ,
381389 metric_callback,
390+ record_stmt_in_spans,
382391 isolation_level,
383392 access_mode,
384393 None ,
0 commit comments