Otel
Pure Elixir, OpenTelemetry-compatible
Features
- Signals
- Traces
- Metrics
- Logs
- Propagators
- W3C TraceContext
- W3C Baggage
- Exporters
- OTLP/HTTP (Protobuf)
- Integrations
:loggerbridge:telemetrybridge
Requirements
-
Elixir
~> 1.18 -
Erlang/OTP
~> 26.2
Compatibility
| Component | Version |
|---|---|
| OpenTelemetry Specification | v1.55.0 (Stable signals only) |
| OpenTelemetry Protocol (OTLP) | v1.10.0 |
| W3C Trace Context | Level 2 (REC) |
| W3C Baggage | OTel Stable Baggage Propagator wire format |
Installation
Add :otel to deps in mix.exs:
def deps do
[
{:otel, "~> 0.4.0"}
]
endConfiguration
SDK
# config/config.exs
config :otel, otp_app: :my_app, req_options: []:req_options is forwarded to Req.new/1 — see :req for the full option list.
Logs
# config/config.exs
config :kernel,
logger: [
{:handler, :otel, Otel.LoggerHandler, %{}}
]Otel.LoggerHandler bridges Logger — see :logger for log levels and metadata.
Metrics
# lib/my_app/application.ex
children = [
{Otel.TelemetryReporter, metrics: []}
]Otel.TelemetryReporter bridges Telemetry.Metrics — see :telemetry_metrics for metric definitions.
Trace
# lib/my_app/application.ex
children = [
{Otel.TelemetryTracer, events: []}
]Otel.TelemetryTracer bridges :telemetry.span/3 — see :telemetry for instrumentation.
Optional: Otel.TelemetrySpanDecorator
# lib/my_app/calculator.ex
defmodule MyApp.Calculator do
use Otel.TelemetrySpanDecorator
@span [:my_app, :calculator, :add]
def add(a, b), do: a + b
@span event: [:my_app, :calculator, :sub], capture_io: true
def sub(a, b), do: a - b
end@span auto-wraps the function body in :telemetry.span/3 and injects code.function.name / code.file.path / code.line.number; pass capture_io: true to also record arguments and the return value.
License
Released under the MIT License.