add: Publish GHC runtime metrics to Prometheus metrics endpoint

This commit is contained in:
Michał Kłeczek
2026-05-03 11:41:02 +00:00
committed by Wolfgang Walther
parent c09394517d
commit 85d91e5c0a
7 changed files with 78 additions and 2 deletions
+5 -1
View File
@@ -13,10 +13,13 @@ module PostgREST.Metrics
import qualified Data.ByteString.Lazy as LBS
import qualified Hasql.Pool.Observation as SQL
import Prometheus
import GHC.Stats (getRTSStatsEnabled)
import Prometheus
import qualified Prometheus.Metric.GHC as PMG
import PostgREST.Observation
import Protolude
data MetricsState =
@@ -34,6 +37,7 @@ data MetricsState =
init :: Int -> IO MetricsState
init configDbPoolSize = do
whenM getRTSStatsEnabled $ void $ register PMG.ghcMetrics
metricState <- MetricsState <$>
register (counter (Info "pgrst_db_pool_timeouts_total" "The total number of pool connection timeouts")) <*>
register (gauge (Info "pgrst_db_pool_available" "Available connections in the pool")) <*>