Introducing Honeybadger for Elixir

Good news Elixir fans! Honeybadger now supports exception monitoring for Elixir. Let's take a look and see how easy it is to get started.

We are excited to share that you can now send exception information from your Elixir applications to Honeybadger! installation and configuration are very straight forward so we're only going to look at how you use the Honeybadger package.

Let's dive in and see how easy this is to get set up.

Phoenix Applications

There are many things to like about Phoenix but one of the very best is that core to Phoenix's design is staying close to the Plug virtue of functions. Since Phoenix is so close to Plug, we can easily notify Honeybadger of any exceptions in your Phoenix application's web requests. Just use   the Honeybadger.Plug   module in your Phoenix application's router and you're done!

defmodule MyApp.Router do
  use MyApp.Web, :router
  use Honeybadger.Plug

  pipeline :browser do

  pipeline :api do

For debugging and customer experience purposes it can also be really helpful to send extra information about the request along with the exception. We provide the Honeybadger.context/1   function to accomplish this. A great technique is to add a plug   function that sets up the context for a request.

# in your application's router
plug :set_honeybadger_context

def set_honeybadger_context(conn, opts) do
  user_id = current_user(conn)
  context = %{user_id: user_id, account: user.account_id}


OTP Processes

Sometimes we have work that needs to be done outside of the web process so that we can return a response as fast as possible. Examples of this are sending email or updating third party APIs. If you follow the guidelines of OTP architecture then Honeybadger rewards you.

Any process that conforms to SASL error reporting requirements and crashes will send an error message to the logger. Examples of these process types are GenServers, GenEvents, Supervisors, and any processes spawned using proc_lib   such as Tasks. This will be nearly all of the processes you have in any given application.

Simply set use_logger   to true when configuring Honeybadger and we will automatically take care of notifying Honeybadger of these crashes.

Manual Error Handling

While Elixir users inherit the Let It Crash mantra from our Erlang ancestors, the often untold, unsexy part of this is that we need to observe, understand and react to how our applications fail.

Sometimes we have critical code paths that need to succeed. If they don't, we need to know why. You can manually call Honeybadger.notify   to support these cases.

require Honeybadger

try do!("i_dont_exist")
  ex ->
    context = %{user_id: 1}
    Honeybadger.notify(ex, context)

As a side note, the reason you need to require   the Honeybadger module before calling Honeybadger.notify   is because this function is actually a macro. With the power of a macro we can wipe away the function calls to notify in environments that you aren't interested in having exception tracking, such as test and development. Pretty cool, eh?!


At ElixirConf Europe Michael Schäfermeyer gave an excellent talk on using Elixir in a high scale web application. One of the key takeaways from that talk for me was that Elixir is missing some of the tools we might be accustomed to in other languages. We hope that by supporting exception tracking for Elixir applications we are doing our part to help get the Elixir community one step closer.

What to do next:
  1. Try Honeybadger for FREE
    Honeybadger helps you find and fix errors before your users can even report them. Get set up in minutes and check monitoring off your to-do list.
    Start free trial
    Easy 5-minute setup — No credit card required
  2. Get the Honeybadger newsletter
    Each month we share news, best practices, and stories from the DevOps & monitoring community—exclusively for developers like you.
    author photo

    Richard Bishop

    A programmer with interests in programming languages, concepts and tools that make my life better. Known to blabber on endlessly about concurrency and DevOps.

    Stop wasting time manually checking logs for errors!

    Try the only application health monitoring tool that allows you to track application errors, uptime, and cron jobs in one simple platform.

    • Know when critical errors occur, and which customers are affected.
    • Respond instantly when your systems go down.
    • Improve the health of your systems over time.
    • Fix problems before your customers can report them!

    As developers ourselves, we hated wasting time tracking down errors—so we built the system we always wanted.

    Honeybadger tracks everything you need and nothing you don't, creating one simple solution to keep your application running and error free so you can do what you do best—release new code. Try it free and see for yourself.

    Start free trial
    Simple 5-minute setup — No credit card required

    Learn more

    "We've looked at a lot of error management systems. Honeybadger is head and shoulders above the rest and somehow gets better with every new release."
    — Michael Smith, Cofounder & CTO of YvesBlue

    Honeybadger is trusted by top companies like: