Skip to content

beam-telemetry/telemetry_metrics_statsd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0e72efd · Aug 17, 2024

History

99 Commits
Aug 25, 2023
Jun 2, 2024
Sep 17, 2023
Mar 11, 2021
Oct 10, 2019
Jan 12, 2019
Aug 17, 2024
Mar 25, 2019
May 20, 2021
Aug 17, 2024
Aug 17, 2024

Repository files navigation

TelemetryMetricsStatsd

Test

Telemetry.Metrics reporter for StatsD-compatible metric servers (including DataDog).

To use it, start the reporter with the start_link/1 function, providing it a list of Telemetry.Metrics metric definitions:

import Telemetry.Metrics

TelemetryMetricsStatsd.start_link(
  metrics: [
    counter("http.request.count"),
    sum("http.request.payload_size"),
    last_value("vm.memory.total")
  ]
)

or put it under a supervisor:

import Telemetry.Metrics

children = [
  {TelemetryMetricsStatsd, [
    metrics: [
      counter("http.request.count"),
      sum("http.request.payload_size"),
      last_value("vm.memory.total")
    ]
  ]}
]

Supervisor.start_link(children, ...)

By default the reporter sends metrics to 127.0.0.1:8125 - both hostname / IP and port number can be configured using the :host and :port options. You can also configure the prefix for all the published metrics using the :prefix option.

Note that the reporter doesn't aggregate metrics in-process - it sends metric updates to StatsD whenever a relevant Telemetry event is emitted.

DataDog integration

To use the reporter with DataDog, add a formatter: :datadog to the reporter's list of options:

import Telemetry.Metrics

children = [
  {TelemetryMetricsStatsd, [
    metrics: [
      counter("http.request.count"),
      sum("http.request.payload_size"),
      last_value("vm.memory.total")
    ],
    formatter: :datadog
  ]}
]

Supervisor.start_link(children, ...)

Installation

Just add the reporter to your dependencies in mix.exs:

defp deps do
  [
    {:telemetry_metrics_statsd, "~> 0.6.0"}
  ]
end

Copyright and License

TelemetryMetricsStatsd is copyright (c) 2019 Arkadiusz Gil.

TelemetryMetricsStatsd source code is released under MIT license.

See LICENSE for more information.