GithubHelp home page GithubHelp logo

yurichandra / exception_hunter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rootstrap/exception_hunter

0.0 1.0 0.0 335 KB

Crash reporting engine to hunt down bugs ๐Ÿž

Home Page: https://rootstrap.com

License: MIT License

Ruby 80.10% JavaScript 0.57% CSS 5.46% HTML 13.87%

exception_hunter's Introduction

ExceptionHunter

CI Maintainability Test Coverage

Index screenshot

Exception Hunter is a Rails engine meant to track errors in your Rails project. It works by using your Postgres database to save errors with their corresponding metadata (like backtrace or environment data at the time of failure).

To do so we hook to various points of your application where we can rescue from errors, track and then re-raise those errors so they are handled normally. As such, the gem does not conflict with any other service so you can have your favorite error tracking service running in parallel with Exception Hunter while you decide which you like best.

Motivation

Error tracking is one of the most important tools a developer can have in their toolset. As such we think it'd be nice to provide a way for everyone to have it in their project, be it a personal project, and MVP or something else.

Installation

Add Exception Hunter to your application's Gemfile:

gem 'exception_hunter', '~> 0.4.2'

You may also need to add Devise to your Gemfile if you haven't already done so and plan to use the gem's built in authentication:

gem 'devise'

After installing the dependencies you'll want to run:

$ rails generate exception_hunter:install

This will create an initializer and invoke Devise to create an AdminUser which will be used for authentication to access the dashboard. If you already have this user created (ActiveAdmin uses the same model) you can run the command with the --skip-users flag.

Additionally it should add the 'ExceptionHunter.routes(self)' line to your routes, which means you can go to /exception_hunter/errors in your browser and start enjoying some good old fashioned exception tracking!

Testing it on dev:

ExceptionHunter is disabled on dev by default so if you want to test it before shipping it to another environment, which we highly recommend, you should enable it by going to the initializer and changing the line that says config.enabled = !(Rails.env.development? || Rails.env.test?) with something like config.enabled = !(Rails.env.test?) while you test. Don't forget to change it back if you don't want a bunch of errors in your local DB!

You can then open a rails console and manually track an exception to check that it works ExceptionHunter.track(StandardError.new("It works!")). You should now see the exception on http://localhost:3000/exception_hunter.

Stale data

You can get rid of stale errors by running the rake task to purge them:

$ rake exception_hunter:purge_errors

We recommend you run this task once in a while to de-clutter your DB, using a recurring tasks once a week would be ideal. You can also purge errors by running ExceptionHunter::ErrorReaper.purge.

The time it takes for an error to go stale defaults to 45 days but it's configurable via the initializer.

Manual tracking

ExceptionHunter also includes a facility to manually log from anywhere in the code. Imagine the following case:

case current_user.status
when :inactive then do_something
when :active then do_something_else
when :banned then do_something_else_else
else
  ExceptionHunter.track(ArgumentError.new('This should never happen'), custom_data: { status: current_user.status }, current_user: user)
end

In this scenario we don't really want to raise an exception but we might want to be alerted if by any chance a user has an invalid status.

License

The gem is available as open source under the terms of the MIT License.

Credits

Exception Hunter is maintained by Rootstrap with the help of our contributors.

exception_hunter's People

Contributors

brunvez avatar t-romani avatar vitogit avatar dependabot[bot] avatar sandrodamilano avatar santib avatar

Watchers

James Cloos 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.