elixir_data_dog

Build Status

A simple library for sending metrics to DataDog

Installation

If available in Hex, the package can be installed by adding elixir_data_dog to your list of dependencies in mix.exs:

def deps do
  [{:elixir_data_dog, "~> 0.1.0"}]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/elixir_data_dog.

Configuration

Provide the following variables in your config.exs:

config :elixir_data_dog,
  datadog_port:      8125,
  datadog_host:      "localhost",
  datadog_namespace: "YOUR_APP_NAME"

Usage

Increments a counter of events.

ElixirDataDog.increment("page.views")

Decrements a counter of events.

ElixirDataDog.decrement("page.logins")

Submits the number of events that occurred during the check interval.

ElixirDataDog.count("page.visits", 10)

If called multiple times during a check’s execution for a metric only the last sample will be used.

ElixirDataDog.gauge("users.online", 123)

Tracks the statistical distribution of a set of values.

ElixirDataDog.histogram("file.upload.size", 1234)

Tracks the time of executing an action.

ElixirDataDog.timing("file.download.time", 1000)

Measures the time of block execution.

result = ElixirDataDog.time("page.render") do
  render_page('home.html')
end

Counts the number of unique elements in a group.

ElixirDataDog.set("users", "John Doe")

Logs a particular event.

ElixirDataDog.event("The server returned 500.")

Tags

For each function you can provide additional options with tags.

ElixirDataDog.event("The server returned 500.", tags: ~w(tag1 tag2))