exceptiontrap 0.0.1.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +71 -0
- data/Rakefile +1 -0
- data/exceptiontrap.gemspec +20 -0
- data/generators/exceptiontrap/USAGE +11 -0
- data/generators/exceptiontrap/exceptiontrap_generator.rb +21 -0
- data/generators/exceptiontrap/templates/exceptiontrap.yml +15 -0
- data/init.rb +9 -0
- data/install.rb +1 -0
- data/lib/exceptiontrap/catcher.rb +35 -0
- data/lib/exceptiontrap/config.rb +74 -0
- data/lib/exceptiontrap/data.rb +131 -0
- data/lib/exceptiontrap/notifier.rb +34 -0
- data/lib/exceptiontrap/rack.rb +22 -0
- data/lib/exceptiontrap/railtie.rb +15 -0
- data/lib/exceptiontrap/version.rb +3 -0
- data/lib/exceptiontrap.rb +38 -0
- data/lib/generators/exceptiontrap/exceptiontrap_generator.rb +28 -0
- data/lib/generators/exceptiontrap/templates/exceptiontrap.yml +15 -0
- data/rails/init.rb +1 -0
- data/tasks/exceptiontrap_tasks.rake +4 -0
- data/test/exceptiontrap_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- data/uninstall.rb +1 -0
- metadata +97 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 [Torsten Bühl]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Exceptiontrap
|
2
|
+
|
3
|
+
This gem is used to report your Ruby on Rails applications exceptions to the [Exceptiontrap](https://alpha.exceptiontrap.com) webservice.
|
4
|
+
|
5
|
+
The gem is compatible with the following Rails versions
|
6
|
+
|
7
|
+
- >= 2.3
|
8
|
+
- >= 3
|
9
|
+
|
10
|
+
**This is an Alpha Release**
|
11
|
+
|
12
|
+
## Setup
|
13
|
+
|
14
|
+
### Rails 3
|
15
|
+
|
16
|
+
#### 1. Install
|
17
|
+
|
18
|
+
Install the Exceptiontrap gem by putting this line to your `Gemfile`
|
19
|
+
|
20
|
+
gem 'exceptiontrap'
|
21
|
+
|
22
|
+
then run `bundle`
|
23
|
+
|
24
|
+
#### 2. Configure
|
25
|
+
|
26
|
+
Now generate the `config/exceptiontrap.yml` file with
|
27
|
+
|
28
|
+
rails generate exceptiontrap --api-key YOUR_API_KEY
|
29
|
+
|
30
|
+
and you should be fine.
|
31
|
+
|
32
|
+
### Rails 2.3
|
33
|
+
|
34
|
+
#### 1a. Install (with Bundler)
|
35
|
+
|
36
|
+
Install the Exceptiontrap gem by putting this line to your `Gemfile`
|
37
|
+
|
38
|
+
gem 'exceptiontrap'
|
39
|
+
|
40
|
+
then run `bundle`
|
41
|
+
|
42
|
+
#### 1b. Install (without Bundler)
|
43
|
+
|
44
|
+
Install the Exceptiontrap gem by putting this line to your `config/environment.rb` file
|
45
|
+
|
46
|
+
config.gem 'exceptiontrap'
|
47
|
+
|
48
|
+
then run `rake gems:install`
|
49
|
+
|
50
|
+
#### 2. Configure
|
51
|
+
|
52
|
+
Now generate the `config/exceptiontrap.yml` file with
|
53
|
+
|
54
|
+
script/generate exceptiontrap --api-key YOUR_API_KEY
|
55
|
+
|
56
|
+
and you should be fine.
|
57
|
+
|
58
|
+
## Information / Further Configuration
|
59
|
+
|
60
|
+
You can find your API-Key by login to your [Exceptiontrap Account](https://alpha.exceptiontrap.com/login), select the application and follow the `Setup` Link.
|
61
|
+
|
62
|
+
## Known Issues / Todo
|
63
|
+
|
64
|
+
At the moment ActionController::RoutingError's are not catched in Rails 3 applications.
|
65
|
+
|
66
|
+
SSL-Support is not included.
|
67
|
+
|
68
|
+
Optimize and insert the test suite to the gem.
|
69
|
+
|
70
|
+
|
71
|
+
Copyright (c) 2012 [Torsten Bühl], released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "exceptiontrap/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "exceptiontrap"
|
7
|
+
s.version = Exceptiontrap::VERSION
|
8
|
+
s.authors = ["tbuehl"]
|
9
|
+
s.email = ["tbuehl@itm-labs.de"]
|
10
|
+
s.homepage = "http://exceptiontrap.com"
|
11
|
+
s.summary = %q{Used to report your apps exceptions to the exceptiontrap webservice}
|
12
|
+
s.description = %q{The gem catches your applications exceptionts and sends those to the exceptiontrap webservice}
|
13
|
+
|
14
|
+
s.rubyforge_project = "exceptiontrap"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Description:
|
2
|
+
Run this generator to create the Exceptiontrap config file
|
3
|
+
|
4
|
+
Example:
|
5
|
+
Rails 2
|
6
|
+
./script/generate exceptiontrap --api-key YOUR_API_KEY
|
7
|
+
Rails 3
|
8
|
+
rails generate exceptiontrap --api-key YOUR_API_KEY
|
9
|
+
|
10
|
+
This will create:
|
11
|
+
The Exceptiontrap config file in your applications config directory
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class ExceptiontrapGenerator < Rails::Generator::Base
|
2
|
+
def add_options!(opt)
|
3
|
+
opt.on('-k', '--api-key=key', String, "Your Exceptiontrap API key") {|v| options[:api_key] = v}
|
4
|
+
end
|
5
|
+
|
6
|
+
def manifest
|
7
|
+
if !options[:api_key]
|
8
|
+
puts "You have to pass --api-key or create config/exceptiontrap.yml manually"
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
12
|
+
record do |m|
|
13
|
+
m.template 'exceptiontrap.yml', 'config/exceptiontrap.yml', :assigns => {:api_key => api_key}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def api_key
|
18
|
+
return "#{options[:api_key]}"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Exceptiontrap Config File
|
2
|
+
api-key: <%= api_key %>
|
3
|
+
ssl: false
|
4
|
+
timeout: 5000
|
5
|
+
enabledEnvironments:
|
6
|
+
- 'production'
|
7
|
+
ignoreExceptions:
|
8
|
+
- 'ActiveRecord::RecordNotFound'
|
9
|
+
- 'ActionController::RoutingError'
|
10
|
+
- 'ActionController::InvalidAuthenticityToken'
|
11
|
+
- 'CGI::Session::CookieStore::TamperedWithCookie'
|
12
|
+
- 'ActionController::UnknownAction'
|
13
|
+
filterParams:
|
14
|
+
- 'password'
|
15
|
+
- 's3-key'
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Exceptiontrap
|
2
|
+
module Catcher
|
3
|
+
def self.included(base)
|
4
|
+
# Uses the public rescue method
|
5
|
+
base.send(:alias_method, :original_rescue_action_in_public, :rescue_action_in_public)
|
6
|
+
base.send(:alias_method, :rescue_action_in_public, :rescue_action_public_exceptiontrap)
|
7
|
+
|
8
|
+
# Uses the local rescue method
|
9
|
+
base.send(:alias_method, :original_rescue_action_locally, :rescue_action)
|
10
|
+
base.send(:alias_method, :rescue_action, :rescue_action_local_exceptiontrap)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
# When the exception occured in public
|
15
|
+
def rescue_action_public_exceptiontrap(exception)
|
16
|
+
handle_with_exceptiontrap(exception)
|
17
|
+
original_rescue_action_in_public(exception) # to rails again
|
18
|
+
end
|
19
|
+
|
20
|
+
# When the exception occured locally
|
21
|
+
def rescue_action_local_exceptiontrap(exception)
|
22
|
+
handle_with_exceptiontrap(exception)
|
23
|
+
original_rescue_action_locally(exception) # to rails again
|
24
|
+
end
|
25
|
+
|
26
|
+
# Sends the exception to exceptiontrap
|
27
|
+
def handle_with_exceptiontrap(exception)
|
28
|
+
# puts "DEBUG: Raised Exceptiontrap::Catcher::Exception"
|
29
|
+
data = Exceptiontrap::Data.rails2_data(exception, request, session, response)
|
30
|
+
Exceptiontrap::Notifier.notify(data)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Exceptiontrap
|
2
|
+
class Config
|
3
|
+
class << self
|
4
|
+
DEFAULTS = {
|
5
|
+
:ssl => false,
|
6
|
+
:disabled_by_default => %w(development test)
|
7
|
+
}
|
8
|
+
|
9
|
+
attr_accessor :api_key, :enabled, :ssl
|
10
|
+
|
11
|
+
def load(config_file=nil)
|
12
|
+
if (config_file && File.file?(config_file))
|
13
|
+
begin
|
14
|
+
config = YAML::load(File.open(config_file))
|
15
|
+
env_config = config[application_environment] || {}
|
16
|
+
|
17
|
+
@api_key = config['api-key'] || env_config['api-key']
|
18
|
+
@ssl = config['ssl'] || env_config['ssl']
|
19
|
+
@ignoreExceptions = config['ignoreExceptions']
|
20
|
+
@filterParams = config['filterParams']
|
21
|
+
@enabledEnvironments = config['enabledEnvironments']
|
22
|
+
rescue Exception => e
|
23
|
+
raise ConfigException.new("Unable to load configuration #{config_file} for environment #{application_environment} : #{e.message}")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def api_key
|
29
|
+
return @api_key unless @api_key.nil?
|
30
|
+
end
|
31
|
+
|
32
|
+
def enabled_environments
|
33
|
+
@enabledEnvironments ||= [""]
|
34
|
+
end
|
35
|
+
|
36
|
+
def ignored_exceptions
|
37
|
+
@ignoreExceptions ||= [""]
|
38
|
+
end
|
39
|
+
|
40
|
+
def filtered_params
|
41
|
+
@filterParams || nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def application_environment
|
45
|
+
ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
|
46
|
+
end
|
47
|
+
|
48
|
+
def should_send_to_api?
|
49
|
+
@enabled ||= DEFAULTS[:disabled_by_default].include?(application_environment) ? false : true
|
50
|
+
end
|
51
|
+
|
52
|
+
def application_root
|
53
|
+
defined?(Rails.root) ? Rails.root : Dir.pwd
|
54
|
+
end
|
55
|
+
|
56
|
+
def ssl?
|
57
|
+
@ssl ||= DEFAULTS[:ssl]
|
58
|
+
end
|
59
|
+
|
60
|
+
def remote_host
|
61
|
+
@remote_host ||= DEFAULTS[:remote_host_http]
|
62
|
+
end
|
63
|
+
|
64
|
+
def remote_port
|
65
|
+
@remote_port ||= ssl? ? 443 : 80
|
66
|
+
end
|
67
|
+
|
68
|
+
def reset
|
69
|
+
@enabled = @ssl = @api_key = nil
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
module Exceptiontrap
|
2
|
+
class Data
|
3
|
+
class << self
|
4
|
+
# TODO: Remove the duplication
|
5
|
+
# Creates Notification Data for action controller requests (Rails 2)
|
6
|
+
def rails2_data(exception, request, session, response)
|
7
|
+
data = {
|
8
|
+
'notifier' => NOTIFIER_NAME,
|
9
|
+
'api-key' => Config.api_key,
|
10
|
+
'name' => exception.class.name,
|
11
|
+
'message' => exception.message,
|
12
|
+
'root' => application_root,
|
13
|
+
'app-environment' => application_environment,
|
14
|
+
'request-uri' => request.url || REQUEST_URI,
|
15
|
+
'request-params' => clean_params(request.params),
|
16
|
+
'request-session' => clean_params(extrap_session_data(session)),
|
17
|
+
'environment' => clean_params(request.env),
|
18
|
+
'trace' => clean_backtrace(exception).join("\n"),
|
19
|
+
'request-components' => { :controller => request.params[:controller], :action => request.params[:action] }
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
# Creates Notification Data for rack requests (Rails 3)
|
24
|
+
def rack_data(exception, env)
|
25
|
+
components = { }
|
26
|
+
if env["action_dispatch.request.parameters"] != nil
|
27
|
+
components[:controller] = env["action_dispatch.request.parameters"][:controller] || nil
|
28
|
+
components[:action] = env["action_dispatch.request.parameters"][:action] || nil
|
29
|
+
components[:module] = env["action_dispatch.request.parameters"][:module] || nil
|
30
|
+
end
|
31
|
+
|
32
|
+
data = {
|
33
|
+
'notifier' => NOTIFIER_NAME,
|
34
|
+
'api-key' => Config.api_key,
|
35
|
+
'name' => exception.class.name,
|
36
|
+
'message' => exception.message,
|
37
|
+
'root' => application_root,
|
38
|
+
'app-environment' => application_environment,
|
39
|
+
'request-uri' => env["REQUEST_URI"],
|
40
|
+
'request-params' => clean_params(env["action_dispatch.request.parameters"]),
|
41
|
+
'request-session' => clean_params(extrap_session_data(env["rack.session"])),
|
42
|
+
'environment' => clean_params(env),
|
43
|
+
'trace' => clean_backtrace(exception).join("\n"),
|
44
|
+
'request-components' => components
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
### Cleanup
|
49
|
+
def clean_params(params)
|
50
|
+
return if params == nil
|
51
|
+
|
52
|
+
params = normalize_data(params)
|
53
|
+
params = filter_params(params)
|
54
|
+
params
|
55
|
+
end
|
56
|
+
|
57
|
+
# Deletes params from env / set in config file
|
58
|
+
def remove_params
|
59
|
+
remove_params = ["rack.request.form_hash", "rack.request.form_vars", "rack.request.form_hash"]
|
60
|
+
end
|
61
|
+
|
62
|
+
# Trims first underscore from keys, to prevent "malformed" rails XML-tags
|
63
|
+
def normalize_data(hash)
|
64
|
+
new_hash = {}
|
65
|
+
|
66
|
+
# TODO: Do this nicer
|
67
|
+
hash.each do |key, value|
|
68
|
+
key_s = key.to_s.dup
|
69
|
+
key_s.sub!("_", "") if key_s[0].chr == "_"
|
70
|
+
key_s.sub!("_", "") if key_s[0].chr == "_"
|
71
|
+
|
72
|
+
if value.respond_to?(:to_hash) # if hash, normalize these too
|
73
|
+
new_hash[key_s] = normalize_data(value.to_hash)
|
74
|
+
else
|
75
|
+
new_hash[key_s] = value.to_s
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
new_hash
|
80
|
+
end
|
81
|
+
|
82
|
+
# Replaces parameter values with a string / set in config file
|
83
|
+
def filter_params(params)
|
84
|
+
if Config.filtered_params
|
85
|
+
params.each do |key, value|
|
86
|
+
if filter_key?(key)
|
87
|
+
params[key] = "[FILTERED]"
|
88
|
+
elsif value.respond_to?(:to_hash)
|
89
|
+
filter_params(params[key])
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
params
|
94
|
+
end
|
95
|
+
|
96
|
+
# Check, if a key should be filtered
|
97
|
+
def filter_key?(key)
|
98
|
+
Config.filtered_params.any? do |filter|
|
99
|
+
key.to_s.include?(filter.to_s)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
### Getter
|
104
|
+
def extrap_session_data(session)
|
105
|
+
return if session == nil
|
106
|
+
if session.respond_to?(:to_hash)
|
107
|
+
session.to_hash
|
108
|
+
else
|
109
|
+
session.data
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def application_environment
|
114
|
+
ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
|
115
|
+
end
|
116
|
+
|
117
|
+
def application_root
|
118
|
+
defined?(Rails.root) ? Rails.root : Dir.pwd
|
119
|
+
end
|
120
|
+
|
121
|
+
def clean_backtrace(exception)
|
122
|
+
if Rails.respond_to?(:backtrace_cleaner)
|
123
|
+
Rails.backtrace_cleaner.send(:filter, exception.backtrace)
|
124
|
+
else
|
125
|
+
exception.backtrace
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Exceptiontrap
|
2
|
+
class Notifier
|
3
|
+
class << self
|
4
|
+
def notify(data)
|
5
|
+
puts "DEBUG: Notify Exception"
|
6
|
+
|
7
|
+
@data = data
|
8
|
+
xml_data = data.to_xml({:root => 'problem', :skip_types => true}).to_s
|
9
|
+
send_problem(xml_data) if !ignore_exception?
|
10
|
+
end
|
11
|
+
|
12
|
+
def send_problem(xml_data)
|
13
|
+
puts "DEBUG: Send Exception"
|
14
|
+
|
15
|
+
url = URI.parse(NOTIFICATION_URL)
|
16
|
+
http = Net::HTTP.new(url.host, url.port)
|
17
|
+
|
18
|
+
response = begin
|
19
|
+
http.post(url.path, xml_data, HEADERS)
|
20
|
+
rescue TimeoutError => e
|
21
|
+
puts "ERROR: Timeout while contacting Exceptiontrap."
|
22
|
+
nil
|
23
|
+
rescue Exception => e
|
24
|
+
puts "ERROR: Error on sending: #{e.class} - #{e.message}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def ignore_exception?
|
29
|
+
Config.ignored_exceptions.include?(@data['name'])
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Exceptiontrap
|
2
|
+
class Rack
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
begin
|
9
|
+
puts "DEBUG: Begin Exceptiontrap::Rack"
|
10
|
+
response = @app.call(env)
|
11
|
+
rescue Exception => raised
|
12
|
+
puts "DEBUG: Raised Exceptiontrap::Rack::Exception"
|
13
|
+
data = Exceptiontrap::Data.rack_data(raised, env)
|
14
|
+
Exceptiontrap::Notifier.notify(data)
|
15
|
+
raise
|
16
|
+
end
|
17
|
+
|
18
|
+
response
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'exceptiontrap'
|
2
|
+
require 'exceptiontrap/data'
|
3
|
+
require 'rails'
|
4
|
+
|
5
|
+
module Exceptiontrap
|
6
|
+
class ExceptiontrapRailtie < Rails::Railtie
|
7
|
+
initializer "exceptiontrap.middleware" do |app|
|
8
|
+
Exceptiontrap::Config.load(File.join(Rails.root, "/config/exceptiontrap.yml"))
|
9
|
+
if Config.enabled_environments.include?(Exceptiontrap::Data.application_environment)
|
10
|
+
# puts "-> Activated Exceptiontrap::Rack for Rails 3 (Railtie)"
|
11
|
+
app.config.middleware.insert_after 'ActionDispatch::ShowExceptions', 'Exceptiontrap::Rack'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
require "exceptiontrap/version"
|
6
|
+
require "exceptiontrap/config"
|
7
|
+
require 'exceptiontrap/notifier'
|
8
|
+
require 'exceptiontrap/rack'
|
9
|
+
|
10
|
+
# Use Rack Middleware for Rails 3
|
11
|
+
require 'exceptiontrap/railtie' if defined?(Rails::Railtie)
|
12
|
+
|
13
|
+
# Exceptiontrap
|
14
|
+
module Exceptiontrap
|
15
|
+
API_VERSION = "0.1"
|
16
|
+
NOTIFIER_NAME = "exceptiontrap-rails"
|
17
|
+
# NOTIFICATION_URL = "http://localhost:3000/problems"
|
18
|
+
NOTIFICATION_URL = "http://alpha.exceptiontrap.com/problems"
|
19
|
+
|
20
|
+
HEADERS = {
|
21
|
+
'Content-type' => 'text/xml',
|
22
|
+
'Accept' => 'text/xml, application/xml'
|
23
|
+
}
|
24
|
+
|
25
|
+
# Load for Rails 2.3 (Rack and Exceptiontrap::Catcher)
|
26
|
+
if !defined?(Rails::Railtie) && defined?(Rails.configuration) && Rails.configuration.respond_to?(:middleware)
|
27
|
+
Exceptiontrap::Config.load(File.join(Rails.root, "/config/exceptiontrap.yml"))
|
28
|
+
|
29
|
+
if Config.enabled_environments.include?(Exceptiontrap::Data.application_environment)
|
30
|
+
if defined?(ActionController::Base) && !ActionController::Base.include?(Exceptiontrap::Catcher)
|
31
|
+
ActionController::Base.send(:include, Exceptiontrap::Catcher) # puts "-> Activated Exceptiontrap::Catcher for Rails 2"
|
32
|
+
end
|
33
|
+
|
34
|
+
Rails.configuration.middleware.use 'Exceptiontrap::Rack' # puts "-> Activated Exceptiontrap::Rack for Rails 2.3+"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class ExceptiontrapGenerator < Rails::Generators::Base
|
4
|
+
desc "Run this generator to create the Exceptiontrap config file"
|
5
|
+
|
6
|
+
class_option :api_key, :aliases => "-k", :type => :string, :desc => "Your Exceptiontrap API key"
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
10
|
+
end
|
11
|
+
|
12
|
+
def install
|
13
|
+
if !options[:api_key]
|
14
|
+
puts "You have to pass --api-key or create config/exceptiontrap.yml manually"
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
#copy_config
|
18
|
+
end
|
19
|
+
|
20
|
+
def api_key
|
21
|
+
s = "#{options[:api_key]}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy_config
|
25
|
+
puts "Copying config file to your app"
|
26
|
+
template 'exceptiontrap.yml', 'config/exceptiontrap.yml'
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Exceptiontrap Config File
|
2
|
+
api-key: <%= api_key %>
|
3
|
+
ssl: false
|
4
|
+
timeout: 5000
|
5
|
+
enabledEnvironments:
|
6
|
+
- 'production'
|
7
|
+
ignoreExceptions:
|
8
|
+
- 'ActiveRecord::RecordNotFound'
|
9
|
+
- 'ActionController::RoutingError'
|
10
|
+
- 'ActionController::InvalidAuthenticityToken'
|
11
|
+
- 'CGI::Session::CookieStore::TamperedWithCookie'
|
12
|
+
- 'ActionController::UnknownAction'
|
13
|
+
filterParams:
|
14
|
+
- 'password'
|
15
|
+
- 's3-key'
|
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__) , '../init.rb')
|
data/test/test_helper.rb
ADDED
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: exceptiontrap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 296151482
|
5
|
+
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
- alpha
|
11
|
+
version: 0.0.1.alpha
|
12
|
+
platform: ruby
|
13
|
+
authors:
|
14
|
+
- tbuehl
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2012-01-04 00:00:00 +01:00
|
20
|
+
default_executable:
|
21
|
+
dependencies: []
|
22
|
+
|
23
|
+
description: The gem catches your applications exceptionts and sends those to the exceptiontrap webservice
|
24
|
+
email:
|
25
|
+
- tbuehl@itm-labs.de
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- MIT-LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- exceptiontrap.gemspec
|
39
|
+
- generators/exceptiontrap/USAGE
|
40
|
+
- generators/exceptiontrap/exceptiontrap_generator.rb
|
41
|
+
- generators/exceptiontrap/templates/exceptiontrap.yml
|
42
|
+
- init.rb
|
43
|
+
- install.rb
|
44
|
+
- lib/exceptiontrap.rb
|
45
|
+
- lib/exceptiontrap/catcher.rb
|
46
|
+
- lib/exceptiontrap/config.rb
|
47
|
+
- lib/exceptiontrap/data.rb
|
48
|
+
- lib/exceptiontrap/notifier.rb
|
49
|
+
- lib/exceptiontrap/rack.rb
|
50
|
+
- lib/exceptiontrap/railtie.rb
|
51
|
+
- lib/exceptiontrap/version.rb
|
52
|
+
- lib/generators/exceptiontrap/exceptiontrap_generator.rb
|
53
|
+
- lib/generators/exceptiontrap/templates/exceptiontrap.yml
|
54
|
+
- rails/init.rb
|
55
|
+
- tasks/exceptiontrap_tasks.rake
|
56
|
+
- test/exceptiontrap_test.rb
|
57
|
+
- test/test_helper.rb
|
58
|
+
- uninstall.rb
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://exceptiontrap.com
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
hash: 25
|
83
|
+
segments:
|
84
|
+
- 1
|
85
|
+
- 3
|
86
|
+
- 1
|
87
|
+
version: 1.3.1
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project: exceptiontrap
|
91
|
+
rubygems_version: 1.6.2
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Used to report your apps exceptions to the exceptiontrap webservice
|
95
|
+
test_files:
|
96
|
+
- test/exceptiontrap_test.rb
|
97
|
+
- test/test_helper.rb
|