pub struct PoolMetrics {
pub acquire_count: u64,
pub acquire_failed_count: u64,
pub acquire_wait_time: Duration,
pub release_count: u64,
pub connection_created_count: u64,
pub connection_closed_count: u64,
}Expand description
连接池累计统计指标(Prometheus 风格)
所有字段均为池生命周期内的累计值(不会随获取/归还重置),
由 Pool::pool_metrics() 返回。基于无锁 AtomicU64 计数,
对 acquire/release 热路径的影响可忽略(单条原子指令)。
serde 序列化支持:观测层导出(Pool::metrics_snapshot_json,v4.7.0 观测闭环)。
Fields§
§acquire_count: u64累计成功获取连接次数
acquire_failed_count: u64累计获取连接失败次数(超时 / 连接创建失败 / 池已关闭 / 断路器或限流拒绝)
acquire_wait_time: Duration累计等待获取连接的时长(池满时阻塞等待的累计时间)
release_count: u64累计归还连接次数
connection_created_count: u64累计创建连接数(含 prewarm / warmup / acquire 新建)
connection_closed_count: u64累计关闭连接数(含过期回收 / 失效 / 池关闭)
Implementations§
Source§impl PoolMetrics
impl PoolMetrics
Sourcepub fn average_acquire_wait_time(&self) -> Duration
pub fn average_acquire_wait_time(&self) -> Duration
平均获取等待时长(无成功获取时为 0)
Sourcepub fn connection_reuse_rate(&self) -> f64
pub fn connection_reuse_rate(&self) -> f64
连接复用率:已复用连接次数占总获取次数的比例
复用次数 = acquire_count - connection_created_count(每次新建连接不算复用)。
acquire_count == 0时返回0.0(数据不足)connection_created_count > acquire_count时返回0.0(防御性)
Trait Implementations§
Source§impl Clone for PoolMetrics
impl Clone for PoolMetrics
Source§fn clone(&self) -> PoolMetrics
fn clone(&self) -> PoolMetrics
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for PoolMetrics
Source§impl Debug for PoolMetrics
impl Debug for PoolMetrics
Source§impl Default for PoolMetrics
impl Default for PoolMetrics
Source§fn default() -> PoolMetrics
fn default() -> PoolMetrics
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for PoolMetrics
impl<'de> Deserialize<'de> for PoolMetrics
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for PoolMetrics
Source§impl PartialEq for PoolMetrics
impl PartialEq for PoolMetrics
Source§impl Serialize for PoolMetrics
impl Serialize for PoolMetrics
impl StructuralPartialEq for PoolMetrics
Auto Trait Implementations§
impl Freeze for PoolMetrics
impl RefUnwindSafe for PoolMetrics
impl Send for PoolMetrics
impl Sync for PoolMetrics
impl Unpin for PoolMetrics
impl UnsafeUnpin for PoolMetrics
impl UnwindSafe for PoolMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more