Document valueToJson
This commit is contained in:
parent
609057c11d
commit
c07bb3df14
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue