Document valueToJson

This commit is contained in:
Johan Tibell 2015-07-31 15:05:11 +01:00
parent 609057c11d
commit c07bb3df14

View file

@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
-- | Encoding of metrics as JSON. The encoding defined by the -- | Encoding of ekg metrics as JSON. The encoding defined by the
-- functions in this module are standardized and used by the ekg web -- functions in this module are standardized and used by the ekg web
-- UI. The purpose of this module is to let other web servers and -- UI. The purpose of this module is to let other web servers and
-- frameworks than the one used by the ekg package expose ekg metrics. -- frameworks than the one used by the ekg package expose ekg metrics.
@ -77,6 +77,13 @@ typeMismatch expected actual =
A.Bool _ -> "Boolean" A.Bool _ -> "Boolean"
A.Null -> "Null" A.Null -> "Null"
-- | Encodes a single metric as a JSON object. Example:
--
-- > {
-- > "type": "c",
-- > "val": 89460
-- > }
--
valueToJson :: Metrics.Value -> A.Value valueToJson :: Metrics.Value -> A.Value
valueToJson (Metrics.Counter n) = scalarToJson n CounterType valueToJson (Metrics.Counter n) = scalarToJson n CounterType
valueToJson (Metrics.Gauge n) = scalarToJson n GaugeType valueToJson (Metrics.Gauge n) = scalarToJson n GaugeType