pub struct TracedConnection { /* private fields */ }Expand description
A traced wrapper around SeaORM’s DatabaseConnection.
This wrapper implements ConnectionTrait, StreamTrait, and TransactionTrait,
making it a drop-in replacement for DatabaseConnection. All database operations
are automatically instrumented with tracing spans.
§Span Nesting
Spans created by TracedConnection automatically become children of the current
tracing span context. This means if you’re using tracing middleware in your web
framework (e.g., tower-http’s TraceLayer), database spans will appear nested
under HTTP request spans in your traces.
§Example
use sea_orm::Database;
use sea_orm_tracing::TracedConnection;
let db = Database::connect("postgres://localhost/mydb").await?;
let traced = TracedConnection::from(db);
// All queries are now traced
let users = Users::find().all(&traced).await?;Implementations§
Source§impl TracedConnection
impl TracedConnection
Sourcepub fn new(connection: DatabaseConnection, config: TracingConfig) -> Self
pub fn new(connection: DatabaseConnection, config: TracingConfig) -> Self
Create a new traced connection with the given configuration.
Sourcepub fn wrap(connection: DatabaseConnection) -> Self
pub fn wrap(connection: DatabaseConnection) -> Self
Create a new traced connection with default configuration.
Sourcepub fn inner(&self) -> &DatabaseConnection
pub fn inner(&self) -> &DatabaseConnection
Get a reference to the underlying DatabaseConnection.
Sourcepub fn config(&self) -> &TracingConfig
pub fn config(&self) -> &TracingConfig
Get the tracing configuration.
Sourcepub fn into_inner(self) -> DatabaseConnection
pub fn into_inner(self) -> DatabaseConnection
Consume the wrapper and return the inner DatabaseConnection.
Trait Implementations§
Source§impl AsRef<DatabaseConnection> for TracedConnection
impl AsRef<DatabaseConnection> for TracedConnection
Source§fn as_ref(&self) -> &DatabaseConnection
fn as_ref(&self) -> &DatabaseConnection
Source§impl Clone for TracedConnection
impl Clone for TracedConnection
Source§fn clone(&self) -> TracedConnection
fn clone(&self) -> TracedConnection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConnectionTrait for TracedConnection
impl ConnectionTrait for TracedConnection
Source§fn get_database_backend(&self) -> DbBackend
fn get_database_backend(&self) -> DbBackend
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn query_one<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_one<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn query_all<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_all<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn support_returning(&self) -> bool
fn support_returning(&self) -> bool
RETURNING syntax on insert and updateSource§fn is_mock_connection(&self) -> bool
fn is_mock_connection(&self) -> bool
Source§impl Debug for TracedConnection
impl Debug for TracedConnection
Source§impl From<DatabaseConnection> for TracedConnection
impl From<DatabaseConnection> for TracedConnection
Source§fn from(connection: DatabaseConnection) -> Self
fn from(connection: DatabaseConnection) -> Self
Source§impl StreamTrait for TracedConnection
impl StreamTrait for TracedConnection
Source§impl TransactionTrait for TracedConnection
impl TransactionTrait for TracedConnection
Source§fn begin<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DatabaseTransaction, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DatabaseTransaction, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
BEGIN transaction.
Returns a Transaction that can be committed or rolled backSource§fn begin_with_config<'life0, 'async_trait>(
&'life0 self,
isolation_level: Option<IsolationLevel>,
access_mode: Option<AccessMode>,
) -> Pin<Box<dyn Future<Output = Result<DatabaseTransaction, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin_with_config<'life0, 'async_trait>(
&'life0 self,
isolation_level: Option<IsolationLevel>,
access_mode: Option<AccessMode>,
) -> Pin<Box<dyn Future<Output = Result<DatabaseTransaction, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
BEGIN transaction with isolation level and/or access mode.
Returns a Transaction that can be committed or rolled back