View Source Peep (peep v1.0.0)

Telemetry.Metrics reporter supporting Statsd and Prometheus.

To use it, start the reporter with start_link/1, providing a list of Telemetry.Metrics metric definitions in a Keyword list matching the schema specified in Peep.Options:

import Telemetry.Metrics

Peep.start_link([
  name: :my_peep,
  metrics: [
    counter("http.request.count"),
    sum("http.request.payload_size"),
    last_value("vm.memory.total"),
    distribution("http.request.latency")
  ]
])

To emit Statsd metrics, Peep supports both UDP and Unix Domain Sockets.

why-another-telemetry-metrics-library

Why another Telemetry.Metrics library?

Both TelemetryMetricsStatsd and TelemetryMetrics.Prometheus are great choices for emitting telemetry. However, Peep makes several different choices that may not be as general-purpose as either of those libraries.

no-sampled-metrics

No sampled metrics

Sampling is a popular approach to reduce the amount of Statsd data flowing out of a service, but naive sampling dramatically reduces visibility into the shapes of distributions. Peep represents distributions using histograms with a small exponential function. This sacrifices some granularity on individual samples, but one usually doesn't mind too much if a sample value of 95 is rounded to 100, or if 950 is rounded to 1000. These histograms are emitted to statsd using the optional sample rate of 1/$count.

Peep uses counters stored in :ets for performance. Peep reporter processes are not involved in the handling of any :telemetry events, so there's no chance of a single process becoming a bottleneck.

distributions-are-aggregated-immediately

Distributions are aggregated immediately

This is a consequence of choosing to represent distributions as histograms. There is no step in Peep's processing where samples are aggregated in large batches. This leads to a flatter performance profile when scaling up.

statsd-packets-are-stuffed

Statsd packets are stuffed

This is something that is not (at the time of writing) supported by TelemetryMetricsStatsd, but the need for stuffing packets became pretty clear when handling tens of thousands of telemetry events every second. During each reporting period, metrics collected by a Peep reporter will be collected into a minimum number of packets. Users can set the maximum packet size in Peep.Options.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Fetches all metrics from the worker. Called when preparing Prometheus or StatsD data.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

get_all_metrics(name_or_pid)

View Source

Fetches all metrics from the worker. Called when preparing Prometheus or StatsD data.