Git Product home page Git Product logo

redmine_hoptoad_server's Introduction

Hoptoad Server

This is a simple Redmine plugin that makes Redmine act like an Airbrake (airbrake.io/) (formerly known as Hoptoad) server. All exceptions caught and sent by HoptoadNotifier or Airbrake client libraries will create or update an issue in Redmine.

Installation & Configuration

Just install the Plugin following the general Redmine plugin installation instructions at www.redmine.org/wiki/redmine/Plugins.

Then, go to Administration -> Settings -> Incoming emails in your Redmine and generate an API key.

Now, install Airbrake following the excellent instructions at github.com/airbrake/airbrake.

The Redmine Hoptoad Server supports the older Hoptoad API (v1) as well as Hoptoad v2 / Airbrake.

When it comes to creating your config/initializers/airbrake.rb file, deviate from the standard and put in something like this:

Airbrake.configure do |config|
  config.api_key = {:project => 'my_redmine_project_identifier', # the identifier you specified for your project in Redmine
                    :tracker => 'Bug',                           # the name of your Tracker of choice in Redmine
                    :api_key => 'my_redmine_api_key',            # the key you generated before in Redmine (NOT YOUR HOPTOAD API KEY!)
                    :category => 'Development',                  # the name of a ticket category (optional.)
                    :assigned_to => 'admin',                     # the login of a user the ticket should get assigned to by default (optional.)
                    :priority => 5,                              # the default priority (use a number, not a name. optional.)
                    :environment => 'staging',                   # application environment, gets prepended to the issue's subject and is stored as a custom issue field. useful to distinguish errors on a test system from those on the production system (optional).
                    :repository_root => '/some/path'             # this optional argument overrides the project wide repository root setting (see below).
                   }.to_yaml
  config.host = 'my_redmine_host.com'                            # the hostname your Redmine runs at
  config.port = 443                                              # the port your Redmine runs at
  config.secure = true                                           # sends data to your server via SSL (optional.)
end

You’re done. You can start receiving your Exceptions in Redmine!

More Configuration (please read on!)

After you received your first exception in Redmine, you will notice two new custom fields in the project(s) you’ve received the exceptions for. Those are Backtrace filter and Repository root.

Backtrace filter

If you’d like to (and we really recommend you do!) filter the backtraces that Notifier reports, you can add comma separated strings to that field. Every line in a backtrace will be scanned against those strings and matching lines will be removed. I usually set my filter to “[GEM_ROOT]”, but if you’re using plugins which tend to clutter up your backtraces, you might want to include those as well. Like this for example: “[GEM_ROOT],/vendor/plugins/newrelic_rpm”.

Repository root

All Issues created will have a source link in their description which – provided that you have your source repository linked to your Redmine project – leads you directly to the file and line in your code that has caused the exception. Your repository structure most likely won’t match the structure of your deployed code, so you can add an additional repository root. Just use “trunk” for a general SVN setup for instance.

You may use the :repository_root option in your application’s airbrake.rb to override this setting with a custom value. This is helful in case you have multiple applications in the same repository reporting errors to the same Redmine project.

Dependencies

Safe YAML (github.com/dtao/safe_yaml). For parsing Airbrake v2 requests the plugin also depends on Nokogiri.

Add to your Redmine’s Gemfile.local:

gem 'safe_yaml'
gem 'nokogiri'

License

MIT

Author

Jan Schulz-Hofen, Planio GmbH (plan.io)

redmine_hoptoad_server's People

Contributors

edavis10 avatar jkraemer avatar meineerde avatar schmidt avatar thegcat avatar yeah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

redmine_hoptoad_server's Issues

handle NilClass if backtrace filter removes all lines

Here is another patch which deals with empty backtraces (for the case the filter removed all lines):

diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb
index 94ab336..7b4d7c4 100644
--- a/app/controllers/notices_controller.rb
+++ b/app/controllers/notices_controller.rb
@@ -38,8 +38,12 @@ class NoticesController < ApplicationController
       description = "Redmine Notifier reported an Error"
       if filtered_backtrace
         repo_root = project.custom_value_for(@repository_root_field).value.gsub(/\/$/,'') rescue nil
-        repo_file, repo_line = filtered_backtrace.first.split(':in').first.gsub('[RAILS_ROOT]','').gsub(/^\//,'').split(':')
-        description << " related to source:#{repo_root}/#{repo_file}#L#{repo_line}"
+        begin
+          repo_file, repo_line = filtered_backtrace.first.split(':in').first.gsub('[RAILS_ROOT]','').gsub(/^\//,'').split(':')
+          description << " related to source:#{repo_root}/#{repo_file}#L#{repo_line}"
+        rescue NoMethodError => e
+          description << " outside of application scope"
+        end
       end

       issue = Issue.find_by_subject_and_project_id_and_tracker_id_and_author_id(subject, project.id, tracker.id, author.id)

404 when accessing redmine's hoptoad server

When running the test rake task, the following error can be seen:

Raising 'HoptoadTestingException' to simulate application failure.                
Sending request to http://redmine.***.**/notifier_api/v2/notices/:           
[...data...]
** [Hoptoad] Failure: Net::HTTPNotFound
** [Hoptoad] Environment Info: [Ruby: 1.8.7] [Rails: 2.3.5] [Env: development]
** [Hoptoad] Response from Hoptoad:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>redMine 404 error</title>
[...]

broken with redmine 2.5

doesn't seem to work with remine 2.5 :(
should have probably checked before upgrading.

No such file to load -- issue_observer (LoadError)
  /home/app-user/.rvm/gems/ruby-1.9.3-p429/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
  /home/app-user/.rvm/gems/ruby-1.9.3-p429/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:312:in `depend_on'
  /home/app-user/.rvm/gems/ruby-1.9.3-p429/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:225:in `require_dependency'
  /var/rails/redmine-2.5.0/plugins/redmine_hoptoad_server/init.rb:16:in `block in <top (required)>'
  /home/app-user/.rvm/gems/ruby-1.9.3-p429/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:429:in `_run__1549838620132978835__prepare__2370503739884065606__callbacks'

Unauthorized Hoptoad API request

hi,
I'm using the very latest git version of this plugin (released some hour ago) and the most recent suggested version of hoptoad notifier, I'm also running redmine trunk (yesterday build)

rake hoptoad:test
Setting up the Controller.
Processing request.
Raising 'HoptoadTestingException' to simulate application failure.

on redmine this is what I get
Processing NoticesController#index (for 2.9.11.89 at 2009-12-26 15:19:04) [POST]
Parameters: {"action"=>"index", "controller"=>"notices"}
Unauthorized Hoptoad API request.
Completed in 8ms (View: 0, DB: 1) | 403 Forbidden [https://xxx/notices/]

of course I substituted my real host name to protect the innocent and I enabled ws.
anything I can do?
thanks

Broken with redmine 2.1.4 (LoadError - cannot load such file -- dispatcher)

With the latest redmine release (2.1.4) redmine_hoptoad_server is broken. The below exception is raised.
No other plugins are installed.

I already unsucessfully tried fixing init.rb as mentioned in the redmine forum

This then results in an error maybe caused by routing issues (in above thread those are also mentioned)?

Error message:
    cannot load such file -- dispatcher
Exception class:
    LoadError

Backtrace:
    #   File    Line    Location
    0   /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    251     in `require'
    1   /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    251     in `block in require'
    2   /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    236     in `load_dependency'
    3   /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    251     in `require'
    4   /var/www/projects-redmine/plugins/redmine_hoptoad_server/init.rb    2   in `'
    5   /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    251     in `require'
    6   /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    251     in `block in require'
    7   /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    236     in `load_dependency'
    8   /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    251     in `require'
    9   /var/www/projects-redmine/lib/redmine/plugin.rb     130     in `block in load'
    10  /var/www/projects-redmine/lib/redmine/plugin.rb     121     in `each'
    11  /var/www/projects-redmine/lib/redmine/plugin.rb     121     in `load'
    12  /var/www/projects-redmine/config/initializers/30-redmine.rb     13  in `'
    13  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    245     in `load'
    14  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    245     in `block in load'
    15  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    236     in `load_dependency'
    16  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/activesupport-3.2.8/lib/active_support/dependencies.rb    245     in `load'
    17  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/engine.rb    588     in `block (2 levels) in '
    18  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/engine.rb    587     in `each'
    19  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/engine.rb    587     in `block in '
    20  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/initializable.rb     30  in `instance_exec'
    21  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/initializable.rb     30  in `run'
    22  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/initializable.rb     55  in `block in run_initializers'
    23  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/initializable.rb     54  in `each'
    24  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/initializable.rb     54  in `run_initializers'
    25  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/application.rb   136     in `initialize!'
    26  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.8/lib/rails/railtie/configurable.rb  30  in `method_missing'
    27  /var/www/projects-redmine/config/environment.rb     14  in `'
    28  config.ru   3   in `require'
    29  config.ru   3   in `block in '
    30  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/lib/rack/builder.rb    51  in `instance_eval'
    31  /home/passenger/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/lib/rack/builder.rb    51  in `initialize'
    32  config.ru   1   in `new'
    33  config.ru   1   in `'

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.