add: log pool flushes
Emit a dedicated PoolFlushed observation when the DB pool is released during schema cache reload.
This commit is contained in:
committed by
Steve Chavez
parent
ad907219be
commit
5d4f82d70f
@@ -225,10 +225,14 @@ usePool AppState{stateObserver=observer, stateMainThreadId=mainThreadId, ..} ses
|
||||
|
||||
-- | Flush the connection pool so that any future use of the pool will
|
||||
-- use connections freshly established after this call.
|
||||
-- | Emits PoolFlushed observation
|
||||
flushPool :: AppState -> IO ()
|
||||
flushPool AppState{..} = SQL.release statePool
|
||||
flushPool AppState{..} = do
|
||||
SQL.release statePool
|
||||
stateObserver PoolFlushed
|
||||
|
||||
-- | Destroy the pool on shutdown.
|
||||
-- | Differs from flushPool in not emiting PoolFlushed observation.
|
||||
destroyPool :: AppState -> IO ()
|
||||
destroyPool AppState{..} = SQL.release statePool
|
||||
|
||||
|
||||
@@ -111,6 +111,9 @@ observationLogger loggerState logLevel obs = case obs of
|
||||
o@PoolRequestFullfilled ->
|
||||
when (logLevel >= LogDebug) $ do
|
||||
logWithZTime loggerState $ observationMessages o
|
||||
o@PoolFlushed ->
|
||||
when (logLevel >= LogDebug) $ do
|
||||
logWithZTime loggerState $ observationMessages o
|
||||
o@JwtCacheEviction ->
|
||||
when (logLevel >= LogDebug) $ do
|
||||
logWithZTime loggerState $ observationMessages o
|
||||
@@ -224,6 +227,8 @@ observationMessages = \case
|
||||
pure "Trying to borrow a connection from pool"
|
||||
PoolRequestFullfilled ->
|
||||
pure "Borrowed a connection from the pool"
|
||||
PoolFlushed ->
|
||||
pure "Database connection pool flushed"
|
||||
JwtCacheLookup _ ->
|
||||
pure "Looked up a JWT in JWT cache"
|
||||
JwtCacheEviction ->
|
||||
|
||||
@@ -53,6 +53,7 @@ data Observation
|
||||
| HasqlPoolObs SQL.Observation
|
||||
| PoolRequest
|
||||
| PoolRequestFullfilled
|
||||
| PoolFlushed
|
||||
| JwtCacheLookup Bool
|
||||
| JwtCacheEviction
|
||||
| TerminationUnixSignalObs Text
|
||||
|
||||
Reference in New Issue
Block a user