• Stars
    star
    517
  • Rank 85,558 (Top 2 %)
  • Language
    Ruby
  • Created almost 12 years ago
  • Updated over 6 years ago

Reviews

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

Repository Details

Use GitHub to track your application errors!

PartyFoul

Build Status Dependency Status Code Climate

Rails exceptions automatically opened as issues on GitHub

Looking for help?

If it is a bug please open an issue on GitHub.

About

PartyFoul captures exceptions in your application and does the following:

  1. Attempt to find a matching issue in your GitHub repo
  2. If no matching issue is found, a new issue is created with a unique title, session information, and stack trace. The issue is tagged as a bug. A new comment is added with relevant data on the application state.
  3. If an open issue is found, the occurrence count and time stamp is updated. A new comment is added with relevant data on the application state.
  4. If a closed issue is found, the occurrence count and time stamp is updated. The issue is reopened and a regression tag is added. A new comment is added with relevant data on the application state.
  5. If the issue is marked as wontfix the issue is not updated nor is a new issue created. No comments are added.

Installation

Note We highly recommend that you create a new GitHub account that is a collaborator on your repository. Use this new account's credentials for the installation below. If you use your own account you will not receive emails when issues are created, updated, reopened, etc... because all of the work is done as your account.

In your Gemfile add the following:

gem 'party_foul'

Rails

If you are using Rails you can run the install generator.

rails g party_foul:install

This prompts you for the GitHub credentials of the account that is opening the issues. The OAuth token for that account is stored in config/initializers/party_foul.rb. You may want to remove the token string and store in an environment variable. It is best not to store the token in version control.

Add as the very last middleware in your production Rack stack in config/environments/production.rb

config.middleware.use('PartyFoul::Middleware')

Other

You need to initialize PartyFoul, use the following:

PartyFoul.configure do |config|
  # The collection of exceptions PartyFoul should not be allowed to handle
  # The constants here *must* be represented as strings
  config.blacklisted_exceptions = ['ActiveRecord::RecordNotFound', 'ActionController::RoutingError']

  # The OAuth token for the account that is opening the issues on GitHub
  config.oauth_token            = 'abcdefgh1234567890'

  # The API endpoint for GitHub. Unless you are hosting a private
  # instance of Enterprise GitHub you do not need to include this
  config.api_endpoint           = 'https://api.github.com'

  # The Web URL for GitHub. Unless you are hosting a private
  # instance of Enterprise GitHub you do not need to include this
  config.web_url                = 'https://github.com'

  # The organization or user that owns the target repository
  config.owner                  = 'owner_name'

  # The repository for this application
  config.repo                   = 'repo_name'

  # The branch for your deployed code
  # config.branch               = 'master'

  # Additional labels to add to issues created
  # config.additional_labels    = ['production']
  # or
  # config.additional_labels    = Proc.new do |exception, env|
  #   []
  # end

  # Limit the number of comments per issue
  # config.comment_limit        = 10

  # Setting your title prefix can help with
  # distinguising the issue between environments
  # config.title_prefix         = Rails.env
end

You can create an OAuth token or generate an OAuth token via the OAuth Authorizations API with cURL:

curl -u <github_login> -i -d "{ \"scopes\": [\"repo\"], \"note\":[\"Test\"] }" \
https://api.github.com/authorizations

Customization

Labels

You can specify an additional array of labels that will be applied to the issues PartyFoul creates.

PartyFoul.configure do |config|
  config.additional_labels = ['front-end']
end

You can also provide a Proc that is passed the exception and the environment.

PartyFoul.configure do |config|
  config.additional_labels = Proc.new do |exception, env|
    labels = if env["HTTP_HOST"] =~ /beta\./
      ['beta']
    else
      ['production']
    end
    if exception.message =~ /PG::Error/
      labels << 'database'
    end
    labels
  end
end

Background Processing

You can specify the adapter with which the exceptions should be handled. By default, PartyFoul includes the PartyFoul::Processors::Sync which handles the exception synchronously. To use your own adapter, include the following in your PartyFoul.configure block:

PartyFoul.configure do |config|
  config.processor = PartyFoul::Processors::MyBackgroundProcessor
end

class PartyFoul::Processors::MyBackgroundProcessor
  def self.handle(exception, env)
    # Enqueue the exception, then in your worker, call
    # PartyFoul::ExceptionHandler.new(exception, env).run
  end
end

PartyFoul comes with the following background processing adapters:

These adapters are not loaded by default. You must explicitly require if you want to use:

require 'party_foul/processors/sidekiq'

PartyFoul.configure do |config|
  config.processor = PartyFoul::Processors::Sidekiq
end

Limiting Comments

You can specify a limit on the number of comments added to each issue. The main issue will still be updated with a count and time for each occurrence, regardless of the limit.

PartyFoul.configure do |config|
  config.comment_limit = 10
end

Tracking errors outside of an HTTP request

You may want to track errors outside of a regular HTTP stack. In that case you will need to make sure of the PartyFoul::RacklessExceptionHandler.

The code that you want to handle should be wrapped like so:

begin
  ... # some code that might raise an error
rescue => error
  PartyFoul::RacklessExceptionHandler.handle(error, class: class_name, method: method_name, params: message)
  raise error
end

Tracking errors in a Sidekiq worker

In order to use PartyFoul for exception handling with Sidekiq you will need to create an initializer with some middleware configuration. The following example is based on using Sidekiq with another exception notifier server.

File: config/initializers/partyfoul_sidekiq.rb

module PartyFoul
  class Sidekiq
    def call(worker, msg, queue)
      begin
        yield
      rescue => error
        PartyFoul::RacklessExceptionHandler.handle(error, {class: worker.class.name, method: queue, params: msg})
        raise error
      end
    end
  end
end

::Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.add ::PartyFoul::Sidekiq
  end
end

This will pass the worker class name and queue as well as all worker-related parameters off to PartyFoul before passing on the exception.

Authors

We are very thankful for the many contributors

Versioning

This gem follows Semantic Versioning

Want to help?

Please do! We are always looking to improve this gem. Please see our Contribution Guidelines on how to properly submit issues and pull requests.

Legal

DockYard, LLC © 2013

@dockyard

Licensed under the MIT license

More Repositories

1

client_side_validations

Client Side Validations made easy for Ruby on Rails
Ruby
2,686
star
2

ember-validations

Validations for Ember Objects
JavaScript
832
star
3

postgres_ext

Adds support for missing PostgreSQL data types to ActiveRecord
Ruby
643
star
4

ember-easy-form

Easily build semantic forms in Ember
JavaScript
565
star
5

ruby-destroyed_at

ActiveRecord Mixin for Safe Destroys
Ruby
349
star
6

capybara-email

Test your ActionMailer and Mailer messages with Capybara
Ruby
339
star
7

postgres_ext-serializers

Ruby
324
star
8

client_side_validations-simple_form

Simple Form plugin for ClientSideValidations
JavaScript
254
star
9

ember-appkit-rails

Ember Appkit for Rails
Ruby
238
star
10

ember-suave

Make your Ember App Stylish
JavaScript
179
star
11

ember-one-way-controls

Native one way input
JavaScript
176
star
12

ember-data-route

Common teardown scenario for ember routes backed by a data model
JavaScript
120
star
13

ember-cli-i18n

Simple Internationalization support for ember-cli apps
JavaScript
112
star
14

dismissible_helpers

Ruby
96
star
15

es6_module_transpiler-rails

Transpile ES6 Modules in the Rails Asset Pipeline
JavaScript
87
star
16

capybara-extensions

Complements Capybara with additional finders and matchers.
Ruby
66
star
17

ruby-context_validations

Context Aware Validations for Rails
Ruby
65
star
18

pg_array_parser

Ruby
61
star
19

pages

Easy pages in Rails
Ruby
49
star
20

ember-skeleton

Show fast-loading temporary images in place of an eventual slow-loading image
JavaScript
41
star
21

ember-cli-proxy-fixtures

Ember CLI Proxy Fixtures
JavaScript
38
star
22

client_side_validations-mongoid

Mongoid plugin for ClientSideValidations
Ruby
28
star
23

ruby-easy_auth

Dead simple drop-in identity based Rails authentication
Ruby
28
star
24

ember-admin-bootstrap

Ember Admin with a Twitter Bootstrap Theme
CSS
25
star
25

client_side_validations-formtastic

Formtastic plugin for ClientSideValidations
Ruby
18
star
26

ember-wuphf

JavaScript
17
star
27

postgres_ext-postgis

Ruby
14
star
28

ember-cli-one-script

This addon combines your `vendor.js` and `<your-app-name>.js` into a single file called `app.js`
JavaScript
14
star
29

client_side_validations-turbolinks

Turbolinks Plugin for ClientSideValidations
Ruby
9
star
30

fixtory

Not quite fixtures, not quite factories
Ruby
9
star
31

ember-new-modules-shim

JavaScript
6
star
32

client_side_validations-backbone

Backbone plugin for ClientSideValidations
JavaScript
6
star
33

ember-cli-test-interactions

Ember acceptance test helpers.
JavaScript
3
star
34

minitest-moar

Moar Minitest Pluzsh!
Ruby
3
star
35

ruby-easy_auth-password

Password plugin for EasyAuth
Ruby
3
star
36

mail_congress

Ruby
2
star
37

ruby-easy_auth-oauth2

Ruby
1
star
38

ruby-easy_auth-twitter

Ruby
1
star
39

ruby-easy_auth-linked_in

Ruby
1
star
40

comet

Elixir
1
star