aboutsummaryrefslogtreecommitdiff
path: root/lib/Server/Util.hs
diff options
context:
space:
mode:
authorstuebinm2022-10-16 13:14:33 +0200
committerstuebinm2022-10-16 13:14:33 +0200
commita07ff36396dd5ad8580e504134e38a6ee0797908 (patch)
tree791c31deed9a3a3f106d40466376cf10acdd83a7 /lib/Server/Util.hs
parent2b5c5f8707feaa9906c85b44dc65602826b861a7 (diff)
simple prometheus metrics
Diffstat (limited to 'lib/Server/Util.hs')
-rw-r--r--lib/Server/Util.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Server/Util.hs b/lib/Server/Util.hs
index 4410711..41d26f7 100644
--- a/lib/Server/Util.hs
+++ b/lib/Server/Util.hs
@@ -1,4 +1,6 @@
-{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE TypeSynonymInstances #-}
-- | mostly the monad the service runs in
module Server.Util (Service, ServiceM, runService, sendErrorMsg, secondsNow, utcToSeconds) where
@@ -12,6 +14,7 @@ import Data.Time (Day, UTCTime (..), diffUTCTime,
getCurrentTime,
nominalDiffTimeToSeconds)
import GTFS (Seconds (..))
+import Prometheus (MonadMonitor (doIO))
import Servant (Handler, ServerError, ServerT, err404,
errBody, errHeaders, throwError)
@@ -21,6 +24,10 @@ type Service api = ServerT api ServiceM
runService :: ServiceM a -> Handler a
runService = runStderrLoggingT
+instance MonadMonitor ServiceM where
+ doIO = liftIO
+
+
sendErrorMsg :: Text -> ServiceM a
sendErrorMsg msg = throwError err404
{ errBody = A.encode $ A.object ["error" A..= (404 :: Int), "msg" A..= msg] }