Skip to content

Commit

Permalink
trace-dispatcher: Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jutaro committed Apr 29, 2024
1 parent ff40f7a commit e49c665
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ packages:
trace-forward

program-options
ghc-options: -Werror
-- ghc-options: -Werror

test-show-details: direct

Expand Down
13 changes: 8 additions & 5 deletions trace-dispatcher/src/Cardano/Logging/Tracer/EKG.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import Control.Concurrent.MVar
import Control.Monad.IO.Class (MonadIO, liftIO)
import qualified Control.Tracer as T
import qualified Data.Map.Strict as Map
import Data.Text (Text, pack)
import Data.Text (Text, intercalate, pack)

import qualified System.Metrics as Metrics
import qualified System.Metrics.Counter as Counter
import qualified System.Metrics.Gauge as Gauge
Expand Down Expand Up @@ -91,7 +92,9 @@ ekgTracer storeOrServer = liftIO $ do
pure (rgsMap', gauge)

presentPrometheusM :: [(Text, Text)] -> Text
presentPrometheusM labels = "{" <> foldr (\(k, v) acc -> k <> "=\"" <> v <>
(if k == fst (last labels)
then "\" " <> acc
else "\", " <> acc)) "" labels <> "} 1"
presentPrometheusM =
label . map pair
where
label pairs = "{" <> intercalate "," pairs <> "} 1"
pair (k, v) = k <> "=\"" <> v <> "\""

4 changes: 4 additions & 0 deletions trace-dispatcher/src/Cardano/Logging/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ data Metric
-- Text is used to name the metric
-- [(Text, Text)] is used to represent the key label pairs
-- The value of the metric will always be "1"
-- e.g. if you have a prometheus metric with the name "prometheus_metric"
-- and the key label pairs [("key1", "value1"), ("key2", "value2")]
-- the metric will be represented as "prometheus_metric{key1=\"value1\",key2=\"value2\"} 1"

| PrometheusM Text [(Text, Text)]
deriving (Show, Eq)

Expand Down

0 comments on commit e49c665

Please sign in to comment.