From: Daniele Varrazzo Date: Fri, 12 Mar 2021 14:27:15 +0000 (+0100) Subject: pool 'queue_length' stats renamed to 'requests_waiting' X-Git-Tag: 3.0.dev0~87^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25a766ee025c7fab5276b8c572f2e438e566eea4;p=thirdparty%2Fpsycopg.git pool 'queue_length' stats renamed to 'requests_waiting' --- diff --git a/docs/advanced/pool.rst b/docs/advanced/pool.rst index c1989a8d0..f79075562 100644 --- a/docs/advanced/pool.rst +++ b/docs/advanced/pool.rst @@ -214,8 +214,8 @@ Metric Meaning ``pool_size`` Current number of connections in the pool, given, being prepared ``pool_available`` Number of connections currently idle in the pool - ``queue_length`` Number of client in the queue waiting for a - connection + ``requests_waiting`` Number of requests currently waiting in a queue to + receive a connection ``usage_ms`` Total usage time of the connections outside the pool ``requests_num`` Number of connections requested to the pool ``requests_queued`` Number of requests queued because a connection wasn't diff --git a/psycopg3/psycopg3/pool/async_pool.py b/psycopg3/psycopg3/pool/async_pool.py index f901ebc82..5cb14c846 100644 --- a/psycopg3/psycopg3/pool/async_pool.py +++ b/psycopg3/psycopg3/pool/async_pool.py @@ -545,7 +545,7 @@ class AsyncConnectionPool(BasePool[AsyncConnection]): def _get_measures(self) -> Dict[str, int]: rv = super()._get_measures() - rv[self._QUEUE_LENGTH] = len(self._waiting) + rv[self._REQUESTS_WAITING] = len(self._waiting) return rv diff --git a/psycopg3/psycopg3/pool/base.py b/psycopg3/psycopg3/pool/base.py index 03d9d860c..919ffce8b 100644 --- a/psycopg3/psycopg3/pool/base.py +++ b/psycopg3/psycopg3/pool/base.py @@ -29,12 +29,12 @@ class BasePool(Generic[ConnectionType]): _POOL_MAX = "pool_max" _POOL_SIZE = "pool_size" _POOL_AVAILABLE = "pool_available" - _QUEUE_LENGTH = "queue_length" - _USAGE_MS = "usage_ms" + _REQUESTS_WAITING = "requests_waiting" _REQUESTS_NUM = "requests_num" _REQUESTS_QUEUED = "requests_queued" _REQUESTS_WAIT_MS = "requests_wait_ms" _REQUESTS_TIMEOUTS = "requests_timeouts" + _USAGE_MS = "usage_ms" _RETURNS_BAD = "returns_bad" _CONNECTIONS_NUM = "connections_num" _CONNECTIONS_MS = "connections_ms" diff --git a/psycopg3/psycopg3/pool/pool.py b/psycopg3/psycopg3/pool/pool.py index ae58d36bf..f24f3b9f9 100644 --- a/psycopg3/psycopg3/pool/pool.py +++ b/psycopg3/psycopg3/pool/pool.py @@ -616,7 +616,7 @@ class ConnectionPool(BasePool[Connection]): def _get_measures(self) -> Dict[str, int]: rv = super()._get_measures() - rv[self._QUEUE_LENGTH] = len(self._waiting) + rv[self._REQUESTS_WAITING] = len(self._waiting) return rv diff --git a/tests/pool/test_pool.py b/tests/pool/test_pool.py index 64a728aa7..45162d43c 100644 --- a/tests/pool/test_pool.py +++ b/tests/pool/test_pool.py @@ -874,7 +874,7 @@ def test_stats_measures(dsn): assert stats["pool_max"] == 4 assert stats["pool_size"] == 2 assert stats["pool_available"] == 2 - assert stats["queue_length"] == 0 + assert stats["requests_waiting"] == 0 ts = [Thread(target=worker, args=(i,)) for i in range(3)] [t.start() for t in ts] @@ -885,7 +885,7 @@ def test_stats_measures(dsn): assert stats["pool_max"] == 4 assert stats["pool_size"] == 3 assert stats["pool_available"] == 0 - assert stats["queue_length"] == 0 + assert stats["requests_waiting"] == 0 p.wait(2.0) ts = [Thread(target=worker, args=(i,)) for i in range(7)] @@ -897,7 +897,7 @@ def test_stats_measures(dsn): assert stats["pool_max"] == 4 assert stats["pool_size"] == 4 assert stats["pool_available"] == 0 - assert stats["queue_length"] == 3 + assert stats["requests_waiting"] == 3 @pytest.mark.slow diff --git a/tests/pool/test_pool_async.py b/tests/pool/test_pool_async.py index 3c92e7ba3..5c9ca80be 100644 --- a/tests/pool/test_pool_async.py +++ b/tests/pool/test_pool_async.py @@ -874,7 +874,7 @@ async def test_stats_measures(dsn): assert stats["pool_max"] == 4 assert stats["pool_size"] == 2 assert stats["pool_available"] == 2 - assert stats["queue_length"] == 0 + assert stats["requests_waiting"] == 0 ts = [create_task(worker(i)) for i in range(3)] await asyncio.sleep(0.1) @@ -884,7 +884,7 @@ async def test_stats_measures(dsn): assert stats["pool_max"] == 4 assert stats["pool_size"] == 3 assert stats["pool_available"] == 0 - assert stats["queue_length"] == 0 + assert stats["requests_waiting"] == 0 await p.wait(2.0) ts = [create_task(worker(i)) for i in range(7)] @@ -895,7 +895,7 @@ async def test_stats_measures(dsn): assert stats["pool_max"] == 4 assert stats["pool_size"] == 4 assert stats["pool_available"] == 0 - assert stats["queue_length"] == 3 + assert stats["requests_waiting"] == 3 @pytest.mark.slow