Skip to content

Commit

Permalink
Merge #3235
Browse files Browse the repository at this point in the history
3235: submit-api: add tx_submit_fail_count metric r=newhoggy a=sorki

Similar to `tx_submit_count` for failed submissions.

Closes #3233.

Co-authored-by: Richard Marko <[email protected]>
  • Loading branch information
iohk-bors[bot] and sorki authored Oct 27, 2022
2 parents e46c7f8 + 48cc9fd commit f129582
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cardano-submit-api/src/Cardano/TxSubmit/Metrics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Cardano.TxSubmit.Metrics
, registerMetricsServer
) where

import Control.Applicative (Applicative (pure), (<$>))
import Control.Applicative (Applicative (pure), (<$>), (<*>))
import Control.Concurrent.Async (Async, async)
import Control.Monad.Reader (MonadIO (liftIO), MonadReader (ask), ReaderT (runReaderT))
import Data.Function (($), (.))
Expand All @@ -19,8 +19,9 @@ import System.Metrics.Prometheus.Concurrent.RegistryT (RegistryT (..),
import System.Metrics.Prometheus.Http.Scrape (serveMetricsT)
import System.Metrics.Prometheus.Metric.Gauge (Gauge)

newtype TxSubmitMetrics = TxSubmitMetrics
data TxSubmitMetrics = TxSubmitMetrics
{ tsmCount :: Gauge
, tsmFailCount :: Gauge
}

registerMetricsServer :: Int -> IO (TxSubmitMetrics, Async ())
Expand All @@ -32,4 +33,6 @@ registerMetricsServer metricsPort =
pure (metrics, server)

makeMetrics :: RegistryT IO TxSubmitMetrics
makeMetrics = TxSubmitMetrics <$> registerGauge "tx_submit_count" mempty
makeMetrics = TxSubmitMetrics
<$> registerGauge "tx_submit_count" mempty
<*> registerGauge "tx_submit_fail_count" mempty
1 change: 1 addition & 0 deletions cardano-submit-api/src/Cardano/TxSubmit/Web.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ txSubmitPost trace metrics (AnyConsensusModeParams cModeParams) networkId (Socke
liftIO $ logInfo trace $
"txSubmitPost: failed to submit transaction: "
<> renderTxCmdError err
liftIO $ Gauge.inc (tsmFailCount metrics)
errorResponse (TxSubmitFail err)
Right txid -> do
liftIO $ logInfo trace $
Expand Down

0 comments on commit f129582

Please sign in to comment.