Connection pool metrics #3596
Replies: 1 comment
|
There is no public metrics API on
The only non-public step is reaching the pool from the client: import httpx
def pool_stats(client: httpx.Client) -> dict[str, int]:
pool = client._transport._pool # httpcore.ConnectionPool
conns = pool.connections
return {
"connections": len(conns),
"active": sum(not c.is_idle() for c in conns),
"idle": sum(c.is_idle() for c in conns),
"expired": sum(c.has_expired() for c in conns),
"queued_requests": sum(r.is_queued() for r in pool._requests),
}Sampled from another thread while five requests run against a For Docs for the pool API: https://www.encode.io/httpcore/connection-pools/ |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
can you please provide an example of collecting the connection pool status, I want to be able to
get insight regarding the free vs used connection in the pool
I thought about a seperate thread that pull the information and report it in some interval but I cant find a way to get this information
Thanks,
Eilon
All reactions