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§
Sourcefn before_query(&self, sql: &str) -> Box<dyn Any + Send>
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.
Sourcefn after_query(
&self,
token: Box<dyn Any + Send>,
sql: &str,
) -> Option<QueryStats>
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.