Skip to content

Commit

Permalink
[FLORA-235] Re-enable prometheus metrics for http & process resources (
Browse files Browse the repository at this point in the history
  • Loading branch information
tchoutri authored Dec 26, 2024
1 parent b7423c4 commit afb04fa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelog.d/801
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
synopsis: Re-enable prometheus metrics for http & process resources
prs: #802
10 changes: 7 additions & 3 deletions flora.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ flag prod

common common-extensions
default-extensions:
NoStarIsType
DataKinds
DeriveAnyClass
DerivingStrategies
DerivingVia
DuplicateRecordFields
LambdaCase
NoStarIsType
OverloadedLabels
OverloadedRecordDot
OverloadedStrings
Expand Down Expand Up @@ -347,7 +347,7 @@ library flora-web
build-depends:
, aeson
, async
, base ^>=4.18.2
, base ^>=4.18.2
, base32
, bytestring
, Cabal-syntax
Expand Down Expand Up @@ -381,13 +381,16 @@ library flora-web
, mtl
, network-uri
, odd-jobs
, one-time-password ==3.0.0.0
, one-time-password ==3.0.0.0
, openapi3
, optics-core
, pg-entity
, pg-transact-effectful
, postgresql-simple
, pretty
, prometheus-client
, prometheus-metrics-ghc
, prometheus-proc
, PyF
, raven-haskell
, resource-pool
Expand All @@ -411,6 +414,7 @@ library flora-web
, wai-app-static
, wai-log
, wai-middleware-heartbeat
, wai-middleware-prometheus
, warp
, xml-conduit
, xml-conduit-writer
Expand Down
12 changes: 11 additions & 1 deletion src/web/FloraWeb/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ import Network.Wai.Handler.Warp
)
import Network.Wai.Log qualified as WaiLog
import Network.Wai.Middleware.Heartbeat (heartbeatMiddleware)
import Network.Wai.Middleware.Prometheus qualified as P
import OddJobs.Endpoints qualified as OddJobs
import OddJobs.Job (startJobRunner)
import OddJobs.Types qualified as OddJobs
import Optics.Core
import Prometheus qualified as P
import Prometheus.Metric.GHC qualified as P
import Prometheus.Metric.Proc qualified as P
import Sel
import Servant
( Application
Expand Down Expand Up @@ -106,6 +110,10 @@ runFlora =
let baseURL = "http://localhost:" <> display env.httpPort
liftIO $ blueMessage $ "🌺 Starting Flora server on " <> baseURL
liftIO $ when (isJust env.mltp.sentryDSN) (blueMessage "📋 Connecting to Sentry endpoint")
liftIO $ when env.mltp.prometheusEnabled $ do
blueMessage $ "🔥 Exposing Prometheus metrics at " <> baseURL <> "/metrics"
void $ P.register P.ghcMetrics
void $ P.register P.procMetrics
liftIO $ when env.mltp.zipkinEnabled (blueMessage "🖊️ Connecting to Zipkin endpoint")
liftIO $ when (env.environment == Development) (blueMessage "🔁 Live reloading enabled")
let withLogger = Logging.makeLogger env.mltp.logger
Expand Down Expand Up @@ -169,7 +177,9 @@ runServer appLogger floraEnv = do
$ heartbeatMiddleware
. loggingMiddleware
. const
$ server
$ P.prometheus
P.def
server

mkServer
:: Logger
Expand Down

0 comments on commit afb04fa

Please sign in to comment.