talira

Telemetry

Dynamic dispatching library for metrics and instrumentation on the Erlang VM

open sourceApache-2.0free

Telemetry is a lightweight Erlang library, used from Elixir and Erlang alike, that gives the whole BEAM ecosystem one interface for instrumentation. A library emits events with telemetry:execute (an event name as a list of atoms, a map of measurements and a map of metadata), and application code or other libraries attach handlers to the events they care about to log, record metrics or forward them. telemetry:span wraps a piece of work in start, stop and exception events with durations measured for you. Handlers run synchronously in the emitting process, so they must stay fast. It's tooling-agnostic and separate from OpenTelemetry, which connects to it through opentelemetry_telemetry. Apache 2.0.

Problems it solves

  • instrument my Elixir library so applications can collect its metrics
  • hook into events from Phoenix or Ecto to log request latency
  • emit start and stop events with durations around a piece of work in Erlang
  • one instrumentation interface across Erlang and Elixir libraries

Features

  • telemetry:execute emits events with measurements and metadata
  • Attach handlers to one or many events by name
  • telemetry:span emits start, stop and exception events with durations
  • Works from both Erlang and Elixir

Limitations

  • Handlers run synchronously on each telemetry:execute call, so a slow handler slows the code that emits the event1

Alternatives

The same job

These do what Telemetry does.

  1. OpenTelemetry Vendor-neutral APIs, SDKs and tools for traces, metrics and logs
  2. Telemetry.Metrics Define metrics from Telemetry events in Elixir
  3. Grafana Beyla eBPF-based auto-instrumentation: OpenTelemetry traces and RED metrics with no code changes

Compare Telemetry with the top 3