Elixir integration guide
Typical installation time: 5 minutes
Hi there! You’ve found Honeybadger’s guide to Elixir error tracking and performance monitoring. If you use Phoenix or Plug, go check out the Phoenix Integration Guide. If not, then read on.
This guide will teach you how to install the honeybadger Hex package in your
Elixir project and use it to manually report errors to Honeybadger. You can also
enable some automatic logging and performance insights (via
telemetry) by setting the insights_enabled option to true in your
configuration.
On this page:
Installing the package
Section titled “Installing the package”Add the Honeybadger package to deps/0 in your application’s mix.exs:
defp deps do [{:honeybadger, "~> 0.22"}]endThen run:
mix do deps.get, deps.compileFinally, update your app’s config.exs file to include the Honeybadger
configuration:
config :honeybadger, api_key: "PROJECT_API_KEY", environment_name: config_env(), insights_enabled: true # Enable logging and performance insightsSee the Configuration reference for additional info.
Testing your installation
Section titled “Testing your installation”To test your installation, fire up iex -S mix, then run:
Honeybadger.notify("Hello Elixir!")If Honeybadger is configured correctly, you should see a new error report in your Honeybadger project dashboard.
Configuring Elixir’s logger
Section titled “Configuring Elixir’s logger”When configured, Honeybadger will report errors for any
SASL-compliant
processes when they crash. Just set the use_logger option to true in your
application’s config.exs and you’re good to go:
config :honeybadger, use_logger: trueManually reporting errors
Section titled “Manually reporting errors”You can use the Honeybadger.notify/2 function to manually report rescued
exceptions:
try do # Buggy code goes hererescue exception -> Honeybadger.notify(exception, stacktrace: __STACKTRACE__)endYou can also pass a string message to the notify function (the second argument
is optional):
Honeybadger.notify("Sign in failed", metadata: %{ user_id: current_user.id})See Reporting Errors for more information.
Reporting custom events
Section titled “Reporting custom events”Use the Honeybadger.event/1 and Honeybadger.event/2 functions to send events
to Honeybadger Insights for logging and performance
monitoring:
Honeybadger.event(%{ event_type: "user_created", user: user.id})
# Honeybadger.event/2 is a shorthand that automatically adds the event_type# property to the event:Honeybadger.event("project_deleted", %{ project: project.name})See Capturing Logs and Events for more details.
Sending logs from your infrastructure
Section titled “Sending logs from your infrastructure”Honeybadger isn’t just for errors and application data! You can use our syslog, Vector, or PaaS integrations to send additional data from your infrastructure to Honeybadger Insights, where you can query, visualize, and analyze all of your production data in one place.
Version requirements
Section titled “Version requirements”See Supported Versions.