Giter VIP home page Giter VIP logo

global_error_handler's Introduction

GlobalErrorHandler

GlobalErrorHandler catches application exceptions on the middleware level and store them into the redis database. It adds Exceptions tab to Redis Web server in case to view, filter, delete or truncate them.

Installation

Add this line to your application's Gemfile:

gem 'global_error_handler', '~> 1.2.3'

And then execute:

$ bundle

Or install it yourself as:

$ gem install global_error_handler

Configuration

Add redis database configuration into global_exceptions_handler section of redis.yml. See redis_example.yml for more details.

Usage

Exceptions tab

Index page

Target your browser to /resque/exceptions/ path of your Rails Application server to view all Exceptions.

Filters

There are two types of filtering: by Error Class and Error Message. Select any Error Class Filter or Error Message Filter from drop-down to view filtered exceptions.

Show

Click on Timestamp or Error Class hyperlink to view details of the exception.

Truncate/Delete functionality

Truncate

Truncate all deletes all Exceptions by filter if filter is selected or ALL Exceptions otherwise.

Delete

  • Delete deletes exception from the database.
  • Delete selected deletes the selected exceptions from the database. Clicking on the table caption checkbox selects/deselects the list.

rescue_from

If rescue_from is used in your application, add following line at top of the method specified to with: parameter of resque_from helper.

GlobalErrorHandler::Handler.new(request.env, exception).process_exception!

Subscribe to Redis notifications

rake tasks

Following command should run on your server in case to automatically clear filters on deleting keys from redis due to expiration. Default expiration time is set to 4 weeks (GlobalErrorHandler::Redis::REDIS_TTL)

rake global_error_handler:subscribe_to_expired

In case to stop subscription, run following below command

rake global_error_handler:unsubscribe_from_expired

capistrano tasks

There are Capistrano recipes that run desired rake tasks on the remote server

  • global_error_handler:subscribe
  • global_error_handler:unsubscribe
  • global_error_handler:update_subscription

In case to subscribe automatically after being deployed, add following require into deploy.rb

require 'global_error_handler/capistrano_recipes'
after 'deploy:restart', 'global_error_handler:update_subscription'

init.d script

Subscribe to expiration keys should run on system start-up as well after you system has been restarted so there is an init.d script to do it. Note that script is for RedHat/CentOS systems only (chkconfig-dependent)!

To generate init.d script run following:

cap <RAILS_ENV> global_error_handler:initd:setup

To install init.d script run following:

cap <RAILS_ENV> global_error_handler:initd:install

To uninstall init.d script run following:

cap <RAILS_ENV> global_error_handler:initd:uninstall

Data structure

Redis database data structure contains following below keys:

  • 'global_error_handler:current_id' : STRING - stores current id of an exception. It is being incremented on adding new exception into database
  • 'global_error_handler:exceptions' : LIST - stores all the exception' keys.
  • 'global_error_handler:exception:<id>' : HASH - exception key, where <id>: number from current_id + 1. Exception key consists of the following attributes:
    • id - exception's internal id
    • error_class - error.class
    • error_message - error.message
    • error_trace - error.backtrace
    • user_agent - request.user_agent
    • request_method - request.method
    • request_params - request.params
    • target_url - request.url
    • referer_url - request.referer
    • user_info - IP Address information
    • timestamp - time when exception was raised
  • 'global_error_handler:filter:<field>:<filter>' : LIST - stores exception' keys that are filtered by field and filter. where <field>: either error_class or error_message, <filter>: string stored in the appropriated attribute.

Database consistency

To check the database consistency, there is a rake task that will check for filters without the keys assigned with.

rake global_error_handler:cleanup_database_dependencies

Contributing

  1. Fork it ( https://github.com/kolobock/global_error_handler/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

global_error_handler's People

Contributors

kolobock avatar

Watchers

James Cloos avatar Rahul Shivprasad pal 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.