Skip to content

Commit b4742f8

Browse files
Pavkazzzclaude
andcommitted
refactor(metrics): update Metrics to use pools/gauges fields
Replace Metrics(drivers=..., hasql=...) with Metrics(pools=..., hasql=..., gauges=...) now that base.py uses the new pool_manager.py. Backward-compat drivers property converts PoolMetrics back to DriverMetrics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8632ac5 commit b4742f8

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

hasql/metrics.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import time
2+
import warnings
23
from collections import defaultdict
34
from contextlib import contextmanager
45
from dataclasses import dataclass, field
@@ -120,8 +121,24 @@ class HasqlGauges:
120121

121122
@dataclass(frozen=True)
122123
class Metrics:
123-
drivers: Sequence[DriverMetrics]
124+
pools: Sequence[PoolMetrics]
124125
hasql: HasqlMetrics
126+
gauges: HasqlGauges
127+
128+
@property
129+
def drivers(self) -> Sequence[DriverMetrics]:
130+
"""Backward-compatible accessor. Deprecated."""
131+
warnings.warn(
132+
"Metrics.drivers is deprecated, use Metrics.pools instead",
133+
DeprecationWarning,
134+
stacklevel=2,
135+
)
136+
return [
137+
DriverMetrics(
138+
min=p.min, max=p.max, idle=p.idle, used=p.used, host=p.host,
139+
)
140+
for p in self.pools
141+
]
125142

126143

127144
__all__ = (

0 commit comments

Comments
 (0)