ekg-json-0.1.0.6: JSON encoding of ekg metrics

Safe Haskell | None
Language | Haskell2010

System.Metrics.Json

Contents

- Converting metrics to JSON values
  - Newtype wrappers with instances

Description

Encoding of ekg metrics as JSON. The encoding defined by the 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 frameworks than the one used by the ekg package expose ekg metrics.

Synopsis

- sampleToJson :: Sample -> Value
- valueToJson :: Value -> Value
- newtype Sample = Sample Sample
- newtype Value = Value Value

# Converting metrics to JSON values

sampleToJson :: Sample -> Value Source #

Encode metrics as nested JSON objects. Each "." in the metric name introduces a new level of nesting. For example, the metrics `[("foo.bar", 10), ("foo.baz", "label")]` are encoded as

    {
      "foo": {
        "bar": {
          "type:", "c",
          "val": 10
        },
        "baz": {
          "type": "l",
          "val": "label"
        }
      }
    }

valueToJson :: Value -> Value Source #

Encodes a single metric as a JSON object. Example:

    {
      "type": "c",
      "val": 89460
    }

## Newtype wrappers with instances

newtype Sample Source #

Newtype wrapper that provides a `ToJSON` instances for the underlying `Sample` without creating an orphan instance.

Constructors

Sample Sample |

Instances

Show Sample Source # |
Methods showsPrec :: Int -> Sample -> ShowS # show :: Sample -> String # showList :: [Sample] -> ShowS #
ToJSON Sample Source # | Uses `sampleToJson`.
Methods toJSON :: Sample -> Value # toEncoding :: Sample -> Encoding # toJSONList :: [Sample] -> Value # toEncodingList :: [Sample] -> Encoding #

newtype Value Source #

Newtype wrapper that provides a `ToJSON` instances for the underlying `Value` without creating an orphan instance.

Constructors

Value Value |

Instances

Show Value Source # |
Methods showsPrec :: Int -> Value -> ShowS # show :: Value -> String # showList :: [Value] -> ShowS #
ToJSON Value Source # | Uses `valueToJson`.
Methods toJSON :: Value -> Value # toEncoding :: Value -> Encoding # toJSONList :: [Value] -> Value # toEncodingList :: [Value] -> Encoding #