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 (..),
|
PGPoolStats (..),
|
||||||
PGPoolMetrics (..),
|
PGPoolMetrics (..),
|
||||||
getInUseConnections,
|
getInUseConnections,
|
||||||
|
getMaxConnections,
|
||||||
defaultConnParams,
|
defaultConnParams,
|
||||||
initPGPool,
|
initPGPool,
|
||||||
resizePGPool,
|
resizePGPool,
|
||||||
@ -97,6 +98,9 @@ data PGPoolMetrics = PGPoolMetrics
|
|||||||
getInUseConnections :: PGPool -> IO Int
|
getInUseConnections :: PGPool -> IO Int
|
||||||
getInUseConnections = RP.getInUseResourceCount . _pool
|
getInUseConnections = RP.getInUseResourceCount . _pool
|
||||||
|
|
||||||
|
getMaxConnections :: PGPool -> IO Int
|
||||||
|
getMaxConnections = RP.getMaxResources . _pool
|
||||||
|
|
||||||
data ConnParams = ConnParams
|
data ConnParams = ConnParams
|
||||||
{ cpStripes :: !Int,
|
{ cpStripes :: !Int,
|
||||||
cpConns :: !Int,
|
cpConns :: !Int,
|
||||||
|
@ -34,6 +34,7 @@ module Data.Pool
|
|||||||
createPool,
|
createPool,
|
||||||
createPool',
|
createPool',
|
||||||
resizePool,
|
resizePool,
|
||||||
|
getMaxResources,
|
||||||
tryTrimLocalPool,
|
tryTrimLocalPool,
|
||||||
tryTrimPool,
|
tryTrimPool,
|
||||||
withResource,
|
withResource,
|
||||||
@ -231,6 +232,9 @@ resizePool Pool {..} maxResources' = do
|
|||||||
"invalid maximum resource count " ++ show maxResources'
|
"invalid maximum resource count " ++ show maxResources'
|
||||||
atomically $ writeTVar maxResources 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
|
-- | Attempt to reduce resource allocation below maximum by dropping some unused
|
||||||
-- resources
|
-- resources
|
||||||
tryTrimLocalPool :: (a -> IO ()) -> TVar Int -> LocalPool a -> IO ()
|
tryTrimLocalPool :: (a -> IO ()) -> TVar Int -> LocalPool a -> IO ()
|
||||||
|
Loading…
Reference in New Issue
Block a user