]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
pool 'queue_length' stats renamed to 'requests_waiting'
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 12 Mar 2021 14:27:15 +0000 (15:27 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 12 Mar 2021 14:50:10 +0000 (15:50 +0100)
docs/advanced/pool.rst
psycopg3/psycopg3/pool/async_pool.py
psycopg3/psycopg3/pool/base.py
psycopg3/psycopg3/pool/pool.py
tests/pool/test_pool.py
tests/pool/test_pool_async.py

index c1989a8d07e6aec9da5cdbb3f72212a1599a0d27..f790755626d88d2d07c21343a96b9fc59af8dcd0 100644 (file)
@@ -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
index f901ebc824eeadbb2816ccf2573d5bf6a6f1aff1..5cb14c846fa9937a8ddba9a48972b7cc7d0a5f22 100644 (file)
@@ -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
 
 
index 03d9d860c477b3bc79b65b9329917e351c95f325..919ffce8b0ab594e0505c85b393959287dc000a2 100644 (file)
@@ -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"
index ae58d36bfb9674f2516e06c7f8f519c6b9b80463..f24f3b9f94a55fd19de4d36edfe86c190b11b57b 100644 (file)
@@ -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
 
 
index 64a728aa7f8541ab185e18ed42f3548f2412c7ae..45162d43cc584b286a4be83bbd052a2e6f2dfcc9 100644 (file)
@@ -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
index 3c92e7ba32a86dbe83c50c146707a64952ddf6fc..5c9ca80beb00af27081c18b0301fe6004c043f0d 100644 (file)
@@ -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