deadpool
deadpool copied to clipboard
Feature request: add last_successful_statement metric
Add last_successful_statement: Option<Instant>
to Metrics
.
Use case: can be used as a heuristic for connection health check. For example, don't do health check if last_successful_statement is less than 5 secs.
I tried last_used
, but it's always 0ms right after you get the connection from the pool, therefore not useful.
last_used
is set on retrieval from the pool. You can access the old metrics from inside a pre_recycle
hook which also allows you to drop connections. Added benefit is that the pool will automatically try the next connection in the pool and the code calling Pool::get
doesn't have to handle that.
@juchiast Does this fix your issue or do you still need a way to access this information from within code that uses the pool?
btw. you're right in a way that the last_used
metric is pretty much useless outside of the hooks. It might make sense to add a last_used
instant which returns the previous usage and not the current one:
pub struct Metrics {
pub created: Instant,
pub recycled: Option<Instant>,
pub recycle_count: usize,
+ pub last_used: Option<Instant>,
}
Hi, thanks for the help! I was able to use hook for my code.