• Stars
    star
    79
  • Rank 394,145 (Top 8 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Crash reporting engine to hunt down bugs 🐞

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.

Docs

You can check the full documentation at https://rootstrap.github.io/exception_hunter.

Installation

Add Exception Hunter to your application's Gemfile:

gem 'exception_hunter', '~> 1.0'

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 }, user: current_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.

Slack notifications

You can configure ExceptionHunter to send a message to slack every time an error occurs. You have to do the following:

  1. Create a Slack app.
  2. Add it to your workspace.
  3. Add one or more webhooks linked to the channels you want to receive the notifications.
  4. Set the webhook urls in the exception_hunter initializer.
config.notifiers << {
  name: :slack,
  options: {
    webhook: 'SLACK_WEBHOOK_URL_1'
  }
}

config.notifiers << {
  name: :slack,
  options: {
    webhook: 'SLACK_WEBHOOK_URL_2'
  }
}
  1. Add the code below to the environment config file where you are using ExceptionHunter with the correct server url.
ExceptionHunter::Engine.configure do |config|
  config.routes.default_url_options = { host: "your_server_url" }
end

This uses ActiveJob to send notification in the background, so make sure you configure it with the adapter you are using, if not notifications will be sent synchronously.

Async Logging

You can configure ExceptionHunter to log async when an error occurs. You have to do the following:

config.async_logging = true;

This uses ActiveJob to log the error in the background, so make sure you configure it with the adapter you are using, if not the error will be logged synchronously.

Note: Errors from jobs will still be logged synchronously to not queue a job from a job (which sound like a bad idea)

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.

More Repositories

1

rails_api_base

API boilerplate project for Ruby on Rails 7
Ruby
346
star
2

yaaf

Easing the form object pattern in Rails applications
Ruby
342
star
3

ios-base

Boilerplate for new iOS projects using Swift 5. Provides a handful of functionalities.
Swift
251
star
4

active-storage-base64

Base64 support for ActiveStorage
Ruby
148
star
5

node-ts-api-base

REST API boilerplate made with Express + NodeJS
TypeScript
105
star
6

htmx-rails

The easiest way to work with HTMX in your Rails app
Ruby
92
star
7

activeadmin-chat

ActiveAdmin chat plugin
Ruby
89
star
8

RSFormView

A Cocoapods library designed to easily create forms with multiple data entry fields
Swift
86
star
9

swift-ui-base

SwiftUI base is a boilerplate project created by Rootstrap for new projects using SwiftUI. The main objective is helping any new projects jump start into feature development by providing a handful of functionalities.
Swift
85
star
10

rails-modular-monolith-with-ddd

Full Modular Monolith Rails application with Domain-Driven Design approach. Inspired by https://github.com/kgrzybek/modular-monolith-with-ddd
85
star
11

apple_auth

Complete Ruby gem for Sign in with Apple. Actively maintained by rootstrap.com
Ruby
80
star
12

rails_hotwire_base

Rails + Hotwire base app
Ruby
74
star
13

PagedLists

Paginated UITableView and UICollectionViews for iOS.
Swift
70
star
14

react-native-use-styles

A classy approach to manage your react native styles.
JavaScript
65
star
15

tech-guides

Guidelines that document processes and standards followed by our entire organization
64
star
16

react-native-base

React Native-Redux Boilerplate
TypeScript
51
star
17

arqo

Easing the query object pattern in Rails applications
Ruby
50
star
18

django-drip-campaigns

💧 Use Django admin to manage drip campaign emails using querysets on Django's User model.
Python
49
star
19

i18n_linter

Rails i18n Linter Gem
Ruby
44
star
20

NeatTipView

A swift library to easily create and present tips for you user in your iOS app
Swift
43
star
21

ai-job-title-area-classification

Classification of job titles into categories, using different ML techniques
Python
43
star
22

react-native-use-animate

Animations in React native made simple
JavaScript
41
star
23

android-base

Rootstrap Android Base project
Kotlin
39
star
24

validate

An extension to the popular library validate.js that adds some useful custom validations out of the box. Also, a hub for all custom validations, that we have created, so you can easily add them to your own project.
JavaScript
31
star
25

mobx-session

mobx react session managment using localforage
JavaScript
29
star
26

RSFontSizes

RSFontSizes pod repository. Allows you to customize fonts and sizes in different screen sizes.
Swift
26
star
27

ai-job-title-level-classification

Python
24
star
28

rsgem

Rootstrap way ® to generate gems
Ruby
24
star
29

active_outbox

A Transactional Outbox implementation for Rails and ActiveRecord
Ruby
23
star
30

best_buy_ruby

Ruby library for the BestBuy API. https://www.bestbuy.com
Ruby
22
star
31

pull_requests_to_slack

Send Github pull request notifications to Slack
Ruby
21
star
32

SwiftGradients

Useful extensions for UIViews and CALayer classes to add beautiful color gradients.
Swift
17
star
33

redux-tools

Redux tools to speed up development.
JavaScript
16
star
34

airflow-examples

Python
13
star
35

chat-gpt-nodejs

NodeJS REST-API to interact with OpenAI
TypeScript
13
star
36

swift-lib-builder

Builder for Cocoapod, Carthage and Swift Package manager libraries in Swift.
Swift
11
star
37

dolphin-nft-marketplace-frontend

TypeScript
11
star
38

rs-code-review-metrics

Ruby
9
star
39

slack-gpt-base-bot-node

JavaScript
8
star
40

FlowForms

Reactive and declarative Form management library for Kotlin projects
Kotlin
8
star
41

rails_hotwire_playground

Ruby
7
star
42

compress-s3-tinypng

Losslessly compresses and Optimizes PNG and JPG files. Uses TinyPNG API.
Python
6
star
43

gemini-nodejs

NodeJS REST-API to interact with Google Gemini
TypeScript
6
star
44

activeadmin-async_exporter

Async exporter for Active Admin using ActiveJob
Ruby
5
star
45

rails_base

Configurable Rails backend generator
Ruby
5
star
46

flutter-base

Dart
5
star
47

web-a11y-demos

JavaScript
5
star
48

livy-base

Apache Livy is a service that enables easy interaction with a Spark cluster over a REST interface
Shell
5
star
49

blog

Repository for submitting and reviewing posts for Rootstrap blog
4
star
50

apple-sign-in-rails

App for testing apple sign in gem
Ruby
4
star
51

ctakes

cTAKES - instructions and example
Dockerfile
4
star
52

UnicodeEmoji

iOS Library that loads official Unicode Emoji repositories and make them accessible to your app.
Swift
3
star
53

ml-training

Machine Learning tutorials and examples
Jupyter Notebook
3
star
54

swift-unity-integration

Integration of Unity build into an iOS(Swift) project.
C#
3
star
55

hotwire-workshop

Ruby
3
star
56

rubocop-rootstrap

To provide default configuration files for Rubocop and the ability to create custom cops
Ruby
3
star
57

node-ts-api-base-legacy

Base Project for NodeJs + TypeScript Backends
TypeScript
3
star
58

fastai-waste-classifier

Jupyter Notebook
3
star
59

rs-gpt-review

TypeScript
3
star
60

htmx-rails_examples

Ruby
2
star
61

phoenix-target-api

Elixir
2
star
62

nest-target-api

Proof of concept of a nest api project. Trello: https://trello.com/b/4ZrvgNnq/nest-target-api
TypeScript
2
star
63

react-native-peeking-header

React native header that hides when scrolling down and shows when scrolling up.
JavaScript
2
star
64

react-ts-base

react-ts-base
TypeScript
2
star
65

create-rootstrap-react-native-app

TypeScript
2
star
66

yaaf-examples

Rails app with YAAF usage examples
Ruby
2
star
67

courier

A middleware gem for deep links that survive the install process
Ruby
2
star
68

typescript-workshop

2
star
69

django-base

Django boilerplate for rest-api backends
Python
2
star
70

rs-wordle

JavaScript
2
star
71

datasciene-ecommerce

A list of examples/experiments machine learning are provided
Jupyter Notebook
2
star
72

MRI-classifier

Jupyter Notebook
2
star
73

docker-workshop

Materials for internal Docker for Devs workshop
Shell
2
star
74

rails_base_extensions

Add features to your rails project in a simple way!
Ruby
2
star
75

RSSwiftNetworking

A Swift framework that provides a network communication layer API
Swift
1
star
76

gangogh

Python
1
star
77

ios-bases-api

API for demo iOS projects.
Ruby
1
star
78

RSRoutingSwift

iOS Routing
Swift
1
star
79

RSFormViewExample

A RSFormView example showcasing dark mode
Swift
1
star
80

react-native-use-toast

React native hook for integrating an extensible/ultra-customizable toast 📬
1
star
81

blackmarket-remix-research

TypeScript
1
star
82

vue-vs-react

Todo app example made in vuejs and in react
Vue
1
star
83

django-feature-flip

Minimal Django app for feature flipping
Python
1
star
84

coronavirus-analysis

HTML
1
star
85

sprinkler-iot

Elixir
1
star
86

rails_admin_s3_file

A rails admin plugin to direct upload assets to s3.
HTML
1
star
87

spinner-playground

Swift
1
star
88

neuro-backyardbrains

train a ML model using data from backyard brains device
Jupyter Notebook
1
star
89

openform-rbac-api

Ruby
1
star
90

rootstrap-ui

Rootstrap's UI Components & Styles
CSS
1
star
91

mmhuman3d-docker

Docker for mmhuman3d - open-mmlab exposing streamlit app
Python
1
star
92

medical-pipeline

Data pipeline for processing medical text records
Python
1
star
93

cra-template-base

A template created to generate a new CRA based code base for React projects.
JavaScript
1
star
94

biobert-test

Python
1
star