Skip to main content

QueryStatsProvider

Trait QueryStatsProvider 

Source
pub trait QueryStatsProvider: Send + Sync {
    // Required methods
    fn before_query(&self, sql: &str) -> Box<dyn Any + Send>;
    fn after_query(
        &self,
        token: Box<dyn Any + Send>,
        sql: &str,
    ) -> Option<QueryStats>;
}
Expand description

Trait for collecting query statistics from a Hyper server.

Implementations capture stats using different mechanisms (log file parsing, future native protocol support, etc.). The trait uses an opaque token pattern: before_query is called before execution and returns a token (e.g., a file offset), which is passed to after_query after execution to extract the stats.

§Thread Safety

Providers must be Send + Sync since they may be shared across connections.

Required Methods§

Source

fn before_query(&self, sql: &str) -> Box<dyn Any + Send>

Called before a query is executed.

Returns an opaque token that will be passed to after_query. For the log-based provider, this is the current file offset.

Source

fn after_query( &self, token: Box<dyn Any + Send>, sql: &str, ) -> Option<QueryStats>

Called after a query completes.

Uses the token from before_query to locate and extract the query statistics. Returns None if stats could not be found.

Trait Implementations§

Source§

impl Debug for dyn QueryStatsProvider

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§