@@ -29,6 +29,7 @@ import qualified Feature.Auth.NoJwtSecretSpec
2929import qualified Feature.ConcurrentSpec
3030import qualified Feature.CorsSpec
3131import qualified Feature.ExtraSearchPathSpec
32+ import qualified Feature.MetricsSpec
3233import qualified Feature.NoSuperuserSpec
3334import qualified Feature.ObservabilitySpec
3435import qualified Feature.OpenApi.DisabledOpenApiSpec
@@ -87,6 +88,7 @@ main = do
8788 sockets <- AppState. initSockets testCfg
8889 loggerState <- Logger. init
8990 metricsState <- Metrics. init (configDbPoolSize testCfg)
91+ obsChan <- newChan
9092
9193 let
9294 initApp sCache st config = do
@@ -95,6 +97,12 @@ main = do
9597 AppState. putSchemaCache appState (Just sCache)
9698 return (st, postgrest (configLogLevel config) appState (pure () ))
9799
100+ initMetricsApp sCache config = do
101+ appState <- AppState. initWithPool sockets pool config loggerState metricsState (Metrics. observationMetrics metricsState <> writeChan obsChan)
102+ AppState. putPgVersion appState actualPgVersion
103+ AppState. putSchemaCache appState (Just sCache)
104+ return ((metricsState, appState, readChan obsChan), postgrest (configLogLevel config) appState (pure () ))
105+
98106 -- For tests that run with the same schema cache
99107 app = initApp baseSchemaCache ()
100108
@@ -123,6 +131,7 @@ main = do
123131 obsApp = app testObservabilityCfg
124132 serverTiming = app testCfgServerTiming
125133 aggregatesEnabled = app testCfgAggregatesEnabled
134+ metricsApp = initMetricsApp baseSchemaCache testCfg
126135
127136 extraSearchPathApp = appDbs testCfgExtraSearchPath
128137 unicodeApp = appDbs testUnicodeCfg
@@ -278,6 +287,9 @@ main = do
278287 before (initApp baseSchemaCache metricsState testCfgJwtCache) $
279288 describe " Feature.Auth.JwtCacheSpec" Feature.Auth.JwtCacheSpec. spec
280289
290+ before metricsApp $
291+ describe " Feature.MetricsSpec" Feature.MetricsSpec. spec
292+
281293 where
282294 loadSCache pool conf =
283295 either (panic. show ) id <$> P. use pool (HT. transaction HT. ReadCommitted HT. Read $ querySchemaCache conf)
0 commit comments