Data Daemon

Hex.pmBuild StatusCoverage StatusHex.pm

An Elixir StatsD client made for DataDog.

Quick Setup

# In your config/config.exs file
config :my_app, Sample.DataDog,
url: "statsd+udp://localhost:8125"
# In your application code
defmodule Sample.DataDog do
@moduledoc ~S"My DataDog reporter."
use DataDaemon,
otp_app: :my_app,
extensions: [:datadog, :erlang_vm]
end
defmodule Sample.App do
alias Sample.DataDog
def send_metrics do
tags = [zone: "us-east-1a"]
DataDog.gauge("request.queue_depth", 12, tags: tags)
DataDog.distribution("connections", 123, tags: tags)
DataDog.histogram("request.file_size", 1034, tags: tags)
DataDog.timing("request.duration", 34, tags: tags)
DataDog.increment("request.count_total", tags: tags)
DataDog.decrement("request.count_total", tags: tags)
DataDog.count("request.count_total", 2, tags: tags)
end
end

Installation

The package can be installed by adding data_daemon to your list of dependencies in mix.exs:

def deps do
[
{:data_daemon, "~> 0.4"}
]
end

The docs can be found at https://hexdocs.pm/data_daemon.

Extensions

DataDog

A DataDog extension is available offering the following functionality:

Events

Create an event for the DataDog event stream by passing a title and message to event/3.

The following options are also supported:

OptionDescription
:timestamp (optional)Add a timestamp to the event. Default is the current timestamp.
:hostname (optional)Add a hostname to the event. No default.
:aggregation_key (optional)Add an aggregation key to group the event with others that have the same key. No default.
:priority (optional)Set to :normal or :low. Default :normal.
:source_type_name (optional)Add a source type to the event. No default.
:alert_type (optional)Set to :error, :warning, :info or :success. Default :info.

Example

defmodule Sample.DataDog do
@moduledoc ~S"My DataDog reporter."
use DataDaemon,
otp_app: :my_app,
extensions: [:datadog],
error_handler: true
end
defmodule Sample.App do
alias Sample.DataDog
def send_events do
tags = [zone: "us-east-1a"]
DataDog.event("Event Title", "Event body.\nMore details", tags: tags)
end
end

All event options are support, for more details see: []

Erlang VM

An Erlang VM extension is available logging Erlang VM stats/metrics every minute.

The reporting interval can be configured with the :rate (in millisecond) inside the :erlang_vm config.

Example: config :my_app, MyDaemon, erlang_vm: [rate: 1_000] for updates every second.

The following metrics are tracked:

Changelog

0.4.1 (2022-08-09)

Fix resolving url with IP as host. Reduce dependency on Plug. Namespace logging.

0.4.0 (2020-08-11)

Improved metrics throughput by sharing named sockets/ports.

0.3.4 (2020-03-15)

Elixir 1.10 support. (Purely spec updates.)

0.3.3 (2020-02-06)

Bug fixes:

0.3.2 (2020-02-01)

New:

Bug fixes:

0.3.1 (2020-01-31)

Changes:

Bug fixes:

0.3.0 (2020-01-30)

Changes:

Bug fixes:

0.2.4 (2020-01-29)

Bug fixes:

0.2.3 (2019-04-30)

Bug fixes:

0.2.2 (2019-04-29)

New features:

Bug fixes:

0.2.1 (2019-04-27)

New features:

Optimizations:

Bug fixes:

0.2.0 (2019-04-17)

New features:

Optimizations:

0.1.4 (2019-03-25)

New features:

Optimizations:

0.1.3 (2018-11-03)

New features:

Optimizations:

Fixes:

0.1.2 (2018-10-09)

New features:

Optimizations:

Fixes:

0.1.0 (2018-10-07)

New features:

Optimizations: