mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
server: add hasura_postgres_max_connection prometheus metric
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10669 GitOrigin-RevId: 6d6607a6dd520866d1aa556bab1007afd1793a01
This commit is contained in:
parent
973035dbbb
commit
acd3f33bb5
@ -15,6 +15,7 @@ module Database.PG.Query.Pool
|
||||
PGPoolStats (..),
|
||||
PGPoolMetrics (..),
|
||||
getInUseConnections,
|
||||
getMaxConnections,
|
||||
defaultConnParams,
|
||||
initPGPool,
|
||||
resizePGPool,
|
||||
@ -97,6 +98,9 @@ data PGPoolMetrics = PGPoolMetrics
|
||||
getInUseConnections :: PGPool -> IO Int
|
||||
getInUseConnections = RP.getInUseResourceCount . _pool
|
||||
|
||||
getMaxConnections :: PGPool -> IO Int
|
||||
getMaxConnections = RP.getMaxResources . _pool
|
||||
|
||||
data ConnParams = ConnParams
|
||||
{ cpStripes :: !Int,
|
||||
cpConns :: !Int,
|
||||
|
@ -34,6 +34,7 @@ module Data.Pool
|
||||
createPool,
|
||||
createPool',
|
||||
resizePool,
|
||||
getMaxResources,
|
||||
tryTrimLocalPool,
|
||||
tryTrimPool,
|
||||
withResource,
|
||||
@ -231,6 +232,9 @@ resizePool Pool {..} maxResources' = do
|
||||
"invalid maximum resource count " ++ show maxResources'
|
||||
atomically $ writeTVar maxResources maxResources'
|
||||
|
||||
getMaxResources :: Pool a -> IO Int
|
||||
getMaxResources Pool {..} = readTVarIO maxResources
|
||||
|
||||
-- | Attempt to reduce resource allocation below maximum by dropping some unused
|
||||
-- resources
|
||||
tryTrimLocalPool :: (a -> IO ()) -> TVar Int -> LocalPool a -> IO ()
|
||||
|
Loading…
Reference in New Issue
Block a user