Server SDK

Error monitoring for Elixir & Phoenix

A client that starts under your supervision tree and a Phoenix error reporter. Wire `handle_errors/2` once and unhandled request errors flow to errorgap.

Frameworks Phoenix · PlugRequires Elixir 1.15+ · OTP 26+Package errorgapSource ↗Package ↗Agent guide ↗
Install

Install

Add the dependency to mix.exs:

elixir
def deps do
  [{:errorgap, "~> 0.2"}]
end
Configure

Configure

In config/runtime.exs:

elixir
config :errorgap,
  endpoint: System.fetch_env!("ERRORGAP_ENDPOINT"),
  project_slug: System.fetch_env!("ERRORGAP_PROJECT_SLUG"),
  api_key: System.fetch_env!("ERRORGAP_API_KEY"),
  environment: System.get_env("APP_ENV", "production")

The Errorgap.Client GenServer starts under your application's supervision tree automatically.

Phoenix

elixir
defmodule MyAppWeb.Endpoint do
  use Phoenix.Endpoint, otp_app: :my_app
  use Plug.ErrorHandler

  @impl Plug.ErrorHandler
  def handle_errors(conn, error_info) do
    Errorgap.Plug.report(conn, error_info)
    conn
  end
end
Keep the key in an environment variable (or your framework's secret store) — never commit it to source control.
Trigger a test error

Trigger a test error

Add a controller action that raises, hit it, then remove it:

elixir
def errorgap_test(_conn, _params) do
  raise "Errorgap test error"
end
Verify

Verify the connection

Confirm your key and endpoint reach errorgap before wiring anything else — send one event straight to the ingestion API:

bash
curl -sS -X POST "$ERRORGAP_ENDPOINT/api/projects/$ERRORGAP_PROJECT_SLUG/notices" \
  -H "content-type: application/json" \
  -H "x-errorgap-project-key: $ERRORGAP_API_KEY" \
  -d '{"errors":[{"type":"ErrorgapInstallTest","message":"Errorgap install verification"}]}'

A 201 with a group_id means ingestion works (202 = received but sampled; 401 = wrong key). Then trigger the test error above through the SDK. Your onboarding screen's Verify step checks the stack off automatically once the first event lands — it polls every three seconds.

Next: the full ingestion API, or browse every SDK.