GithubHelp home page GithubHelp logo

gleber / erlbrake Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kenpratt/erlbrake

1.0 2.0 0.0 113 KB

Erlang Airbrake notification client

Home Page: http://github.com/kenpratt/erlbrake

License: MIT License

Erlang 100.00%

erlbrake's Introduction

erlbrake

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

Requirements

Usage

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
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).
ok
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/erlbrake.app, 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,
    {airbrake, start_link, ["production", "76fdb93ab2cf276ec080671a8b3d3866"]},
    permanent, 5000, worker, dynamic}.

2. Add airbrake hooks:

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

and/or:

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

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:

error_logger:add_report_handler(erlbrake_error_logger)

Macro

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 :)

erlbrake's People

Contributors

ddossot avatar gleber avatar kenpratt avatar tholschuh avatar tsloughter avatar zeisss avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.