From bccd7c76715eac46f92191c5fbd4d6391af1aeae Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 17 Jul 2018 01:57:57 +0600 Subject: [PATCH] add wait queue size stat to client connector --- src/client/connector.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client/connector.rs b/src/client/connector.rs index 1ff0efe51..604af0b86 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -34,6 +34,8 @@ use {HAS_OPENSSL, HAS_TLS}; pub struct ClientConnectorStats { /// Number of waited-on connections pub waits: usize, + /// Size of the wait queue + pub wait_queue: usize, /// Number of reused connections pub reused: usize, /// Number of opened connections @@ -494,8 +496,13 @@ impl ClientConnector { ctx.run_later(Duration::from_secs(1), |act, ctx| act.collect_periodic(ctx)); // send stats - let stats = mem::replace(&mut self.stats, ClientConnectorStats::default()); + let mut stats = mem::replace(&mut self.stats, ClientConnectorStats::default()); if let Some(ref mut subscr) = self.subscriber { + if let Some(ref waiters) = self.waiters { + for w in waiters.values() { + stats.wait_queue += w.len(); + } + } let _ = subscr.do_send(stats); } }