Elixir notifier for Errorgap. Reports exceptions from Plug/Phoenix apps, OTP processes, and plain Elixir scripts.
Requires Elixir 1.15+ and OTP 26+.
def deps do
[{:errorgap, "~> 0.1"}]
endconfig/runtime.exs:
config :errorgap,
endpoint: System.get_env("ERRORGAP_ENDPOINT"),
project_slug: System.get_env("ERRORGAP_PROJECT_SLUG"),
api_key: System.get_env("ERRORGAP_API_KEY"),
environment: System.get_env("APP_ENV", "production")Falls back to ERRORGAP_* environment variables when keys are omitted.
try do
risky()
rescue
exc ->
Errorgap.notify(exc, stacktrace: __STACKTRACE__, context: %{component: "billing"})
reraise exc, __STACKTRACE__
endUse Plug.ErrorHandler and delegate to Errorgap.Plug.report/2:
defmodule MyAppWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :my_app
use Plug.ErrorHandler
# ... plugs ...
@impl Plug.ErrorHandler
def handle_errors(conn, error_info) do
Errorgap.Plug.report(conn, error_info)
conn
end
end| Key | Default | Notes |
|---|---|---|
:endpoint |
ERRORGAP_ENDPOINT or http://127.0.0.1:3030 |
|
:project_slug |
ERRORGAP_PROJECT_SLUG |
Required |
:project_id |
ERRORGAP_PROJECT_ID |
|
:api_key |
ERRORGAP_API_KEY |
Sent as x-errorgap-project-key |
:environment |
ERRORGAP_ENVIRONMENT or production |
|
:release |
ERRORGAP_RELEASE |
|
:async |
true |
Cast to a GenServer worker |
:filter_keys |
["password", "token", ...] |
Substring, case-insensitive |
:timeout |
5_000 |
HTTP timeout (ms) |
Errorgap.flush(5_000)mix deps.get
mix testMIT.