feat: per-listener latency tracking
Each listener now tracks chain setup latency independently via a dict[str, LatencyTracker] on Metrics. The global aggregate stays for summary output. /status embeds per-listener latency on each listener entry; /metrics includes a listener_latency map keyed by host:port.
This commit is contained in:
@@ -135,11 +135,18 @@ class TestHandleStatus:
|
||||
],
|
||||
)
|
||||
ctx = _make_ctx(config=config)
|
||||
# record some latency for the first listener
|
||||
ctx["metrics"].get_listener_latency("0.0.0.0:1080").record(0.2)
|
||||
_, body = _handle_status(ctx)
|
||||
assert len(body["listeners"]) == 2
|
||||
assert body["listeners"][0]["chain"] == ["socks5://127.0.0.1:9050"]
|
||||
assert body["listeners"][0]["pool_hops"] == 0
|
||||
assert body["listeners"][1]["pool_hops"] == 1
|
||||
# per-listener latency present on each entry
|
||||
assert "latency" in body["listeners"][0]
|
||||
assert body["listeners"][0]["latency"]["count"] == 1
|
||||
assert "latency" in body["listeners"][1]
|
||||
assert body["listeners"][1]["latency"] is None
|
||||
|
||||
|
||||
class TestHandleMetrics:
|
||||
@@ -156,6 +163,7 @@ class TestHandleMetrics:
|
||||
assert "uptime" in body
|
||||
assert "rate" in body
|
||||
assert "latency" in body
|
||||
assert "listener_latency" in body
|
||||
|
||||
|
||||
class TestHandlePool:
|
||||
|
||||
Reference in New Issue
Block a user