Master Hex.pm Version

Steaming Metrics

Description

A library that interfaces with several metric recording backends.

Installation

To add to your mix dependencies, add the following block to your mix.exs deps:

def deps do
  [
    {:streaming_metrics, "~> 2.2.0"}
  ]
end

Usage

This library can record metrics to AWS CloudWatch, Prometheus, or to the console. To specify this, put something like the below in your environment config file.

config :my_app,
  metric_collector: StreamingMetrics.ConsoleMetricCollector

or

config :my_app,
  metric_collector: StreamingMetrics.PrometheusMetricCollector

or

config :my_app,
  metric_collector: StreamingMetrics.AwsMetricCollector

Each collector implementation has three functions:

  • record_metrics/2 takes an array of metrics and a namespace.
  • count_metric/4 takes an integer, a namespace, an optional array of dimensions (ex: [{"DimensionName", "some dimension value"}]), and an optional timestamp.
  • gauge_metric/5 takes an integer, a namespace, an optional array of dimensions (ex: [{"DimensionName", "some dimension value"}]), an optional unit type (see here), and an optional timestamp.

## License

SmartCity is released under the Apache 2.0 license - see the license at http://www.apache.org/licenses/LICENSE-2.0