Skip to main content

ExecuteExt

Trait ExecuteExt 

Source
pub trait ExecuteExt: Sized {
    // Provided methods
    fn traced(self) -> Traced<Self> { ... }
    fn record(self, span: &Span) -> Traced<Self> { ... }
}
Expand description

An extension trait that wraps a sqlx query so its SQL and timing get recorded when it is executed.

The span attached should have the db.query.text and db.response.returned_rows attribute set.

Provided Methods§

Source

fn traced(self) -> Traced<Self>

Wrap the query so that, when executed, its SQL is recorded as db.query.text on the current span and its count/timing are added to the current [LogContext].

Source

fn record(self, span: &Span) -> Traced<Self>

Like ExecuteExt::traced, but records onto the given span instead of the current one. Use when the query runs under a span other than the one current at the call site.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<DB: Database, A> ExecuteExt for Query<'_, DB, A>

Source§

impl<DB: Database, F, A> ExecuteExt for Map<'_, DB, F, A>

Source§

impl<DB: Database, O, A> ExecuteExt for QueryAs<'_, DB, O, A>

Source§

impl<DB: Database, O, A> ExecuteExt for QueryScalar<'_, DB, O, A>

Implementors§