fix: implement connection tracking in metrics
Right now metrics observation handler does not track database connections but updates a single Gauge based on HasqlPoolObs events. This is problematic because Hasql pool reports various connection events in multiple phases. The connection state machine is not simple and to precisely report the number of connections in various states, it is necessary to track their lifecycles. This change adds a ConnTrack data structure and logic to track database connections lifecycles. At the moment it supports "connected" and "inUse" connection counts precisely. The "pgrst_db_pool_available" metric is implemented on top of ConnTrack instead of a simple Gauge.
This commit is contained in:
committed by
Steve Chavez
parent
f6e99117ab
commit
ed2dc1fe86
@@ -1811,10 +1811,6 @@ def test_server_timing_transaction_duration(defaultenv, metapostgrest):
|
||||
assert 2000 <= response_dur < 3000
|
||||
|
||||
|
||||
@pytest.mark.xfail(
|
||||
reason="pgrst_db_pool_available should not go negative on pg network failures",
|
||||
strict=True,
|
||||
)
|
||||
def test_positive_pool_metric(defaultenv):
|
||||
"When a network failure is caused on the pg connection, pgrst_db_pool_available stays positive"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user