Otelot
Export your Elixir app's metrics and logs to any OpenTelemetry backend over OTLP — without rewriting your instrumentation.
- Metrics: reuse the
Telemetry.Metricsdefinitions you already have (Phoenix, Ecto, Oban, your own:telemetryevents). Otelot aggregates them in-process and exports them as OTel sums, gauges and histograms. - Logs: a
:loggerhandler that batches log events and ships them as OTel log records, with trace/span correlation when the official tracing SDK is in use.
Otelot is a fork of otel_metric_exporter,
which was used in production at Electric.
Installation
def deps do
[
{:otelot, "~> 0.5"}
]
end
Quickstart
Point Otelot at an OTLP/HTTP endpoint:
# config/runtime.exs
config :otelot,
otlp_endpoint: "http://localhost:4318",
resource: %{service: %{name: "my_app"}}
Export metrics by adding the exporter to your supervision tree, e.g. in the Telemetry
module that Phoenix generates:
children = [
{Otelot.MetricExporter, metrics: metrics(), export_period: :timer.seconds(30)}
]
Export logs by registering the handler:
# config/config.exs
config :my_app, :logger, [
{:handler, :otel, Otelot.LogHandler, %{config: %{metadata: [:request_id]}}}
]
# lib/my_app/application.ex, in start/2
Logger.add_handlers(:my_app)
The standard OTEL_EXPORTER_OTLP_*, OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES
environment variables are honoured too.
Documentation
- Getting started — full setup, a local collector for experimenting, troubleshooting.
- Metrics — how
Telemetry.Metricstypes map to OTel, export semantics, differences from the official SDK. - Configuration — all options and environment variables.
How it differs from the official OpenTelemetry SDK
Otelot trades API compliance for fitting into the existing Elixir ecosystem:
- Metrics are defined with
Telemetry.Metrics, not the OTel Metrics API. No Views, no Exemplars, no link to traces. summarymetrics and OTel'sExponentialHistogramare not supported.- Transport is OTLP over HTTP with protobuf encoding; gRPC and HTTP/JSON are not supported.
- It doesn't do tracing. Use
opentelemetryfor that; the two work fine side by side.
Compatibility
Otelot requires Elixir 1.17+ and is tested in CI against:
| Elixir | Erlang/OTP |
|---|---|
| 1.17 | 27 |
| 1.19 | 28 |
| 1.20 | 29 |
It works with any OTLP/HTTP receiver: the OpenTelemetry Collector, Grafana Cloud, Honeycomb, Datadog, etc.
Development
mix deps.get
mix test
mix format --check-formatted
See CONTRIBUTING.md before opening an issue or a pull request.
Maintenance
Otelot is maintained by Oleksii Sholik on a best-effort basis. It follows semantic versioning; while it is on 0.x, minor releases may contain breaking changes, which are always called out in the changelog.
License
Apache 2.0, see LICENSE.