Erlang Airbrake notification client
Switch branches/tags
Nothing to show
Clone or download
kenpratt Merge pull request #12 from rramsden/master
Add ibrowse as dependency in rebar.config
Latest commit d38a417 Nov 17, 2012



An Erlang client for the Airbrake exception notification service (formerly known as Hoptoad).



1. Sign up for Airbrake
2. Create a Airbrake project, and copy the API key
3. Proceed with “Running the Erlbrake application” or “Embedding Erlbrake in an existing application”

Running the Erlbrake application

1. Compile erlbrake: cd path/to/erlbrake/ && make or rebar compile
2. Start the erlbrake application, replacing the API key with your own and the paths to ibrowse and erlbrake to where they are installed on your machine:

ERL_LIBS="$HOME/erlang/ibrowse:$HOME/erlang/erlbrake:$ERL_LIBS" erl -erlbrake apikey '"76fdb93ab2cf276ec080671a8b3d3866"' -erlbrake error_logger true -erlbrake environment '"development"' -s erlbrake start

3. Try generating a couple of error reports:

1> airbrake:notify(error, fake, "Testing erlbrake with a manual error report", no_module, 0).
2> error_logger:error_msg("A sample error caught by the erlbrake error logger.").

4. Configure erlbrake: three configuration options are supported: apikey, environment, and error_logger

  • apikey – Set this to the API key of your Airbrake project (String).
  • environment – The Airbrake environment that errors will be reported under (String).
  • error_logger – Set to true to enable the erlbrake error_logger (Boolean). The erlbrake error logger will intergrate with the existing Erlang/OTP error logging, notifying airbrake of any runtime errors in your application. The upside is that it can catch things that manual airbrake notification can’t.

These configuration options can be set in ebin/, or configured on the command line as in the above example.

Embedding Erlbrake in an existing application

1. Add airbrake to your application supervision tree:

    {airbrake, start_link, ["production", "76fdb93ab2cf276ec080671a8b3d3866"]},
    permanent, 5000, worker, dynamic}.

2. Add airbrake hooks:

case calculate_something() of
    {ok, Value} ->
    Error = {error, Reason} ->
        airbrake:notify(error, Reason, "Frobber calculation failed", ?MODULE, ?LINE)


try do_stuff() of
    Value ->
    Type:Reason ->
        airbrake:notify(Type, Reason, "Ahhh! Stuff is not good!", ?MODULE, ?LINE, erlang:get_stacktrace())

3. Compile erlbrake: cd path/to/erlbrake/ && make
4. Add the erlbrake ebin directory to your Erlang path: -pa path/to/erlbrake/ebin
5. Start ibrowse during your application startup: application:start(ibrowse)
6. Test it out!
7. (Optional) Add the erlbrake error logger to your application startup:



A macro similar to this is likely useful to avoid duplication:

-define(NOTIFY_AIRBRAKE(Type, Reason, Message),
        airbrake:notify(Type, Reason, Message, ?MODULE, ?LINE, erlang:get_stacktrace())).

If you already have a macro to log errors, just add it to that :)