File tree 4 files changed +17
-4
lines changed
cardano-submit-api/src/Cardano
4 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ runTxSubmitWebapi :: TxSubmitNodeParams -> IO ()
30
30
runTxSubmitWebapi tsnp = do
31
31
tsnc <- readTxSubmitNodeConfig (unConfigFile $ tspConfigFile tsnp)
32
32
trce <- mkTracer tsnc
33
- (metrics, metricsServer) <- registerMetricsServer
33
+ (metrics, metricsServer) <- registerMetricsServer (tspMetricsPort tsnp)
34
34
txSubmitServer <- Async. async $
35
35
runTxSubmitServer trce metrics tspWebserverConfig tspProtocol tspNetworkId tspSocketPath
36
36
void $ Async. waitAnyCancel
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import Cardano.TxSubmit.Rest.Parsers (pWebserverConfig)
18
18
import Control.Applicative (Alternative (.. ), Applicative (.. ), (<**>) )
19
19
import Data.Function ((.) )
20
20
import Data.Functor (Functor (fmap ), (<$>) )
21
+ import Data.Int
21
22
import Data.Semigroup (Semigroup ((<>) ))
22
23
import Data.Word (Word64 )
23
24
import Options.Applicative (Parser , ParserInfo )
@@ -37,6 +38,7 @@ pTxSubmitNodeParams = TxSubmitNodeParams
37
38
<*> pNetworkId
38
39
<*> pSocketPath
39
40
<*> pWebserverConfig 8090
41
+ <*> pMetricsPort 8081
40
42
41
43
pConfigFile :: Parser ConfigFile
42
44
pConfigFile = ConfigFile <$> Opt. strOption
@@ -122,3 +124,11 @@ pSocketPath = SocketPath <$> Opt.strOption
122
124
<> Opt. completer (Opt. bashCompleter " file" )
123
125
<> Opt. metavar " FILEPATH"
124
126
)
127
+
128
+ pMetricsPort :: Int -> Parser Int
129
+ pMetricsPort defaultValue = Opt. option Opt. auto
130
+ ( Opt. long " metrics-port"
131
+ <> Opt. help " Metrics port"
132
+ <> Opt. metavar " PORT"
133
+ <> Opt. value defaultValue
134
+ )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ module Cardano.TxSubmit.CLI.Types
7
7
8
8
import Cardano.Api (AnyConsensusModeParams , NetworkId (.. ))
9
9
import Cardano.TxSubmit.Rest.Types (WebserverConfig )
10
+ import Data.Int
10
11
import System.IO (FilePath )
11
12
12
13
-- | The product type of all command line arguments
@@ -16,6 +17,7 @@ data TxSubmitNodeParams = TxSubmitNodeParams
16
17
, tspNetworkId :: ! NetworkId
17
18
, tspSocketPath :: ! SocketPath
18
19
, tspWebserverConfig :: ! WebserverConfig
20
+ , tspMetricsPort :: ! Int
19
21
}
20
22
21
23
newtype ConfigFile = ConfigFile
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import Control.Applicative (Applicative (pure), (<$>))
11
11
import Control.Concurrent.Async (Async , async )
12
12
import Control.Monad.Reader (MonadIO (liftIO ), MonadReader (ask ), ReaderT (runReaderT ))
13
13
import Data.Function (($) , (.) )
14
+ import Data.Int
14
15
import Data.Monoid (Monoid (mempty ))
15
16
import System.IO (IO )
16
17
import System.Metrics.Prometheus.Concurrent.RegistryT (RegistryT (.. ), registerGauge ,
@@ -22,12 +23,12 @@ newtype TxSubmitMetrics = TxSubmitMetrics
22
23
{ tsmCount :: Gauge
23
24
}
24
25
25
- registerMetricsServer :: IO (TxSubmitMetrics , Async () )
26
- registerMetricsServer =
26
+ registerMetricsServer :: Int -> IO (TxSubmitMetrics , Async () )
27
+ registerMetricsServer metricsPort =
27
28
runRegistryT $ do
28
29
metrics <- makeMetrics
29
30
registry <- RegistryT ask
30
- server <- liftIO . async $ runReaderT (unRegistryT $ serveMetricsT 8081 [] ) registry
31
+ server <- liftIO . async $ runReaderT (unRegistryT $ serveMetricsT metricsPort [] ) registry
31
32
pure (metrics, server)
32
33
33
34
makeMetrics :: RegistryT IO TxSubmitMetrics
You can’t perform that action at this time.
0 commit comments