Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLORA-235] Re-enable prometheus metrics for http & process resources #802

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading