Otelot

CI Hex.pm Docs

Export your Elixir app's metrics and logs to any OpenTelemetry backend over OTLP — without rewriting your instrumentation.

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

How it differs from the official OpenTelemetry SDK

Otelot trades API compliance for fitting into the existing Elixir ecosystem:

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.