/install-otel-elixir:install-otel-elixirfrom install-otel-elixir
Install, configure, or troubleshoot vendor-neutral OpenTelemetry traces, metrics, and log correlation in Elixir and Phoenix applications. Use when adding OpenTelemetry to a new or existing Elixir or Phoenix project, wiring OTLP export to an in-cluster Collector or direct backend such as Axiom, or fixing missing spans, metrics, or trace context propagation. Don't use for ripping out New Relic (:new_relic_agent); use migrate-to-otel-elixir instead, which loads this skill, and don't use for Cloudflare Workers OTel export.
Ships in install-otel-elixir. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Wire vendor-neutral OpenTelemetry traces and metrics over OTLP plus OTP :logger trace correlation for stdout log shippers (Alloy, fly-log-shipper), configured solely via runtime OTEL_* environment variables with zero vendor URLs, dataset names, or tokens in Elixir code.
Read references/setup-and-config.md and references/examples.md before editing mix.exs, config/*.exs, or telemetry modules. Read references/testing.md before writing span or metric tests.
mix.exs, mix.lock, config/*.exs, application.ex, and any telemetry.ex. Detect HTTP server (:bandit vs :plug_cowboy), ecto_repos and their adapters, Oban, outbound HTTP clients (:req, :finch), Logger formatter (:default_formatter vs :default_handler / LoggerJSON), and releases. Treat metrics enabled as true only when the request asks for OTel metrics or an OTLP metrics backend is configured; otherwise default to traces and log correlation only (do not key on :telemetry_metrics, which phx.new always includes), state that assumption in one line, omit :opentelemetry_experimental items in steps 2-5, and skip step 7.mix hex.info <pkg> before editing mix.exs.
:opentelemetry, :opentelemetry_api, :opentelemetry_exporter. Never set runtime: false on :opentelemetry_exporter or OTP releases omit it and fail on boot.mix.exs): :opentelemetry_phoenix, :opentelemetry_bandit (or :opentelemetry_cowboy ~> 1.0), :opentelemetry_ecto, :opentelemetry_oban, and either :opentelemetry_finch (OpentelemetryFinch.setup() in Telemetry.setup/0) or :opentelemetry_req (OpentelemetryReq.attach(req, propagate_trace_headers: true) where Req.new clients are built; propagate_trace_headers defaults to false, and never attach both Req and Finch instrumentation on the same stack).opentelemetry_api natively writes :otel_trace_id and :otel_span_id into Logger process metadata. Add third-party :opentelemetry_logger_metadata only when the log backend requires unprefixed :trace_id and :span_id keys (it uses a :logger primary filter, so Logger.metadata()[:trace_id] stays nil).:opentelemetry_experimental and :opentelemetry_api_experimental.mix.exs. Under releases: [<app>: [applications: [...]]], set opentelemetry_exporter: :permanent, opentelemetry: :temporary, and (when metrics enabled) opentelemetry_experimental: :temporary.test against shell OTEL_* leaks.
config/config.exs: set config :opentelemetry, traces_exporter: :none, set config :opentelemetry_experimental, readers: [] when metrics enabled, and append :otel_trace_id, :otel_span_id (or :trace_id, :span_id) to the active Logger formatter's metadata list without clobbering existing keys or LoggerJSON handler config.config/test.exs: otel_configuration gives OS env vars precedence over app env, so clear OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, and OTEL_EXPORTER_OTLP_* via System.delete_env/1 in config/test.exs, set span_processor: :simple, traces_exporter: :none, and set config :opentelemetry_experimental, readers: [] when metrics enabled.config/runtime.exs: guard the OTel block with if config_env() != :test do.config/runtime.exs.
resource_detectors: [:otel_resource_app_env, :otel_resource_env_var] alongside config :opentelemetry, :resource so OTEL_RESOURCE_ATTRIBUTES wins over release defaults.nil and "" as unset when reading OTEL_* env vars.:otel_metric_reader defaults export_interval_ms to :undefined (pull-only); explicitly set export_interval_ms (from OTEL_METRIC_EXPORT_INTERVAL, default 15_000) in reader config.MyApp.Telemetry.setup/0.
MyApp.Telemetry.setup/0 once at the top of Application.start/2, writing its :persistent_term guard key after setup finishes so repeated test calls do not re-register instruments while a startup crash is not masked.OpentelemetryBandit.setup() + OpentelemetryPhoenix.setup(adapter: :bandit)) or Cowboy (:opentelemetry_cowboy.setup() + OpentelemetryPhoenix.setup(adapter: :cowboy2)). OpentelemetryPhoenix already wraps LiveView mount/handle_params/handle_event; do not add duplicate manual spans there, and propagate context manually into assign_async/start_async.OpentelemetryEcto.setup/2 once per distinct repo telemetry_prefix across Application.get_env(:my_app, :ecto_repos, []). Strip both userinfo: nil and query: nil when overriding :"db.url" on single-repo prefixes; on Ecto.Adapters.SQLite3 (url: nil, hostname: nil), override :"db.url" so OpentelemetryEcto does not emit "ecto://".plugin: :disabled to OpentelemetryOban.setup(job: [span_relationship: :child], plugin: :disabled) unless periodic Pruner/Cron plugin spans are wanted.OpentelemetryProcessPropagator.Task.async/1 (or OpenTelemetry.Ctx.get_current/0 + attach/1). Inside any Ecto.Multi Oban enqueue (Ecto.Multi.insert, Oban.insert/3,4, or OpentelemetryOban.insert/3,4, which passes straight through without injecting headers), merge :otel_propagator_text_map.inject([]) |> Map.new() into job meta.OpenTelemetry.Tracer.with_span never records exceptions or sets :error status, whether rescued or re-raised. Use MyApp.Telemetry.with_span/3 (which rescues, calls MyApp.Telemetry.record_otel_error/2, and reraises) or call MyApp.Telemetry.record_otel_error(e, __STACKTRACE__) in rescue blocks that return error tuples.Counter, Histogram, and ObservableGauge are macros (require ..., as: ...), require atom instrument names (:"phoenix.router_dispatch.duration"), and require map options (%{unit: :ms}, %{}). String names silently drop measurements; keyword options raise BadMapError.:native durations via max(System.convert_time_unit(d, :native, :microsecond) / 1000.0, 0.0), never integer :millisecond. Use framework-namespaced :ms names (:"phoenix.router_dispatch.duration", :"ecto.repo.query.duration"), since OTel semconv http.server.request.duration and db.client.operation.duration specify seconds (:s).[:phoenix, :router_dispatch, :stop] and :exception (Plug.Exception.status/1 on exceptions; omit "http.response.status_code" when conn.status is nil; use meta[:route] || "unknown", never conn.request_path where path params explode cardinality). Read Oban outcome from meta[:state], never job.state (which is "executing").ObservableGauge.create/4 in 0.6.x takes an arity-1 callback (callback_args -> [{number(), attrs}]). Never write an arity-2 callback or call nonexistent :otel_observer.observe/3.OTEL_EXPORTER_OTLP_METRICS_HEADERS replaces OTEL_EXPORTER_OTLP_HEADERS wholesale (repeat Authorization when metrics target a separate dataset) and only the *_HEADERS vars (they embed the token) belong in platform secret stores (fly secrets); endpoint, protocol, and service name go in fly.toml [env].mix compile --warnings-as-errors, mix format --check-formatted, linter/Dialyzer if configured, and ExUnit tests asserting real exported spans and metric datapoints via references/testing.md.service.name and the deployed service.version, and list metric names in the metrics dataset. Empty results with a healthy app mean export is misconfigured; check the app logs for OTLP 4xx errors.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub dvcrn/skills --plugin install-otel-elixir