This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CSL-1585] Namespace cardano EKG metrics (#1464)
[CSL-1585] Namespace all the relevant IOHK's EKG metrics
- Loading branch information
1 parent
86e0787
commit ee50e1d
Showing
9 changed files
with
119 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Pos.System.Metrics.Constants ( | ||
cardanoNamespace | ||
, withCardanoNamespace | ||
) where | ||
|
||
import Universum | ||
|
||
cardanoNamespace :: Text | ||
cardanoNamespace = "cardano" | ||
|
||
withCardanoNamespace :: Text -> Text | ||
withCardanoNamespace label = cardanoNamespace <> "." <> label |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
|
||
module Pos.Util.Monitor ( | ||
|
||
startMonitor | ||
, stopMonitor | ||
|
||
) where | ||
|
||
import Control.Concurrent (killThread) | ||
import Control.Monad.IO.Class (MonadIO) | ||
import Mockable.Class (Mockable) | ||
import qualified Mockable.Metrics as Metrics | ||
import Node (Node) | ||
import Node.Util.Monitor (registerMetrics) | ||
import Pos.System.Metrics.Constants (cardanoNamespace) | ||
import qualified System.Metrics as Monitoring | ||
import qualified System.Metrics.Distribution as Monitoring.Distribution | ||
import qualified System.Remote.Monitoring.Wai as Monitoring | ||
|
||
import Universum | ||
|
||
startMonitor | ||
:: ( Mockable Metrics.Metrics m | ||
, Metrics.Distribution m ~ Monitoring.Distribution.Distribution | ||
, MonadIO m | ||
) | ||
=> Int | ||
-> (forall t . m t -> IO t) | ||
-> Node m | ||
-> m Monitoring.Server | ||
startMonitor port lowerIO node = do | ||
store <- liftIO Monitoring.newStore | ||
registerMetrics (Just cardanoNamespace) lowerIO node store | ||
liftIO $ Monitoring.registerGcMetrics store | ||
server <- liftIO $ Monitoring.forkServerWith store "127.0.0.1" port | ||
liftIO . putStrLn $ "Forked EKG server on port " ++ show port | ||
return server | ||
|
||
stopMonitor | ||
:: ( MonadIO m ) | ||
=> Monitoring.Server | ||
-> m () | ||
stopMonitor server = liftIO $ killThread (Monitoring.serverThreadId server) |
Oops, something went wrong.