failurous-rails 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +22 -0
- data/README.md +106 -0
- data/client/failurous.rb +7 -0
- data/client/failurous/config.rb +24 -0
- data/client/failurous/fail_middleware.rb +60 -0
- data/client/failurous/fail_notification.rb +62 -0
- data/client/failurous/fail_notifier.rb +13 -0
- metadata +107 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2010 Mikko Nylén, Tero Parviainen & Antti Forsell
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
|
4
|
+
obtaining a copy of this software and associated documentation
|
|
5
|
+
files (the "Software"), to deal in the Software without
|
|
6
|
+
restriction, including without limitation the rights to use,
|
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the
|
|
9
|
+
Software is furnished to do so, subject to the following
|
|
10
|
+
conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Failurous
|
|
2
|
+
|
|
3
|
+
Failurous is an open source webapp for monitoring exceptions in your
|
|
4
|
+
live applications.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
### Server
|
|
9
|
+
|
|
10
|
+
### Clients
|
|
11
|
+
|
|
12
|
+
#### Rails 3
|
|
13
|
+
|
|
14
|
+
To use Failurous from Rails 3 application, add this to your Gemfile:
|
|
15
|
+
|
|
16
|
+
gem 'failurous-rails', :git => 'git://github.com/railsrumble/rr10-team-256.git'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
Next you need to add the following under config/initializer/failurous.rb:
|
|
20
|
+
|
|
21
|
+
require 'failurous'
|
|
22
|
+
|
|
23
|
+
Failurous::Config.server_address = '<FAILUROUS-INSTALLATION>'
|
|
24
|
+
Failurous::Config.api_key = '<API-KEY-FOR-PROJECT>'
|
|
25
|
+
|
|
26
|
+
Rails.application.config.middleware.use Failurous::FailMiddleware
|
|
27
|
+
|
|
28
|
+
The middleware will automatically catch any exceptions your app raises and
|
|
29
|
+
deliver them to the Failurous service for later viewing.
|
|
30
|
+
|
|
31
|
+
#### Java
|
|
32
|
+
|
|
33
|
+
To integrate Failurous to a Java webapp, first add the Failurous Maven repository to your Maven POM:
|
|
34
|
+
|
|
35
|
+
<repository>
|
|
36
|
+
<id>failurous</id>
|
|
37
|
+
<url>http://failurous.r10.railsrumble.com/mvnrepo</url>
|
|
38
|
+
<snapshots>
|
|
39
|
+
<enabled>true</enabled>
|
|
40
|
+
</snapshots>
|
|
41
|
+
<releases>
|
|
42
|
+
<enabled>true</enabled>
|
|
43
|
+
</releases>
|
|
44
|
+
</repository>
|
|
45
|
+
|
|
46
|
+
Next, add a dependency to the Failurous Java client:
|
|
47
|
+
|
|
48
|
+
<dependency>
|
|
49
|
+
<groupId>failurous</groupId>
|
|
50
|
+
<artifactId>javaclient</artifactId>
|
|
51
|
+
<version>0.0.1-SNAPSHOT</version>
|
|
52
|
+
</dependency>
|
|
53
|
+
|
|
54
|
+
Finally, configure the Failurous Java client to intercept exceptions by adding it as a servlet filter to your web.xml:
|
|
55
|
+
|
|
56
|
+
<filter>
|
|
57
|
+
<filter-name>failurous</filter-name>
|
|
58
|
+
<filter-class>failurous.ClientFilter</filter-class>
|
|
59
|
+
<init-param>
|
|
60
|
+
<param-name>serverAddress</param-name>
|
|
61
|
+
<param-value><FAILUROUS-INSTALLATION></param-value>
|
|
62
|
+
</init-param>
|
|
63
|
+
<init-param>
|
|
64
|
+
<param-name>apiKey</param-name>
|
|
65
|
+
<param-value><API-KEY-FOR-PROJECT></param-value>
|
|
66
|
+
</init-param>
|
|
67
|
+
</filter>
|
|
68
|
+
|
|
69
|
+
<filter-mapping>
|
|
70
|
+
<filter-name>failurous</filter-name>
|
|
71
|
+
<url-pattern>/*</url-pattern>
|
|
72
|
+
</filter-mapping>
|
|
73
|
+
|
|
74
|
+
The filter will automatically catch any exceptions your app threw and deliver them to the Failurous service for later viewing.
|
|
75
|
+
|
|
76
|
+
Notice that the position of the filter-mapping element affects which exceptions Failurous will report. Any filter mappings appearing before the failurous filter mapping in web.xml will not be reported, since they are executed outside its scope.
|
|
77
|
+
|
|
78
|
+
## Sending fails
|
|
79
|
+
|
|
80
|
+
Often there's cases where it'd be desirable to be able to send debugging
|
|
81
|
+
information or notifications of "failurous" behaviour in your application. For
|
|
82
|
+
example, when someone tries to access protected content without proper access
|
|
83
|
+
rights.
|
|
84
|
+
|
|
85
|
+
Failurous comes in handy here, because it's not limited to only
|
|
86
|
+
exceptions: you can actually send any data you like.
|
|
87
|
+
|
|
88
|
+
### In Rails applications
|
|
89
|
+
|
|
90
|
+
To send your custom fails to Failurous, you can use the
|
|
91
|
+
`Failurous::FailNotification` to build your fail and send it. The syntax is
|
|
92
|
+
as follows:
|
|
93
|
+
|
|
94
|
+
Failurous::FailNotification.set_title('Title for your fail').
|
|
95
|
+
add_field(:section_name, :field_name, {:use_in_checksum => true | false}).
|
|
96
|
+
add_field(:another, :field, {...}).
|
|
97
|
+
send
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
Copyright (c) 2010 Mikko Nylén, Tero Parviainen & Antti Forsell
|
|
103
|
+
|
|
104
|
+
See LICENSE
|
|
105
|
+
|
|
106
|
+
|
data/client/failurous.rb
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
module Failurous
|
|
2
|
+
ROOT_PATH = File.dirname(__FILE__)
|
|
3
|
+
autoload :Config, "#{ROOT_PATH}/failurous/config"
|
|
4
|
+
autoload :FailNotification, "#{ROOT_PATH}/failurous/fail_notification"
|
|
5
|
+
autoload :FailNotifier, "#{ROOT_PATH}/failurous/fail_notifier"
|
|
6
|
+
autoload :FailMiddleware, "#{ROOT_PATH}/failurous/fail_middleware"
|
|
7
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Failurous
|
|
2
|
+
class Config
|
|
3
|
+
@@server_address = ""
|
|
4
|
+
@@api_key = ""
|
|
5
|
+
|
|
6
|
+
class << self
|
|
7
|
+
def server_address=(val)
|
|
8
|
+
@@server_address = val
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def server_address
|
|
12
|
+
@@server_address
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def api_key=(val)
|
|
16
|
+
@@api_key = val
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def api_key
|
|
20
|
+
@@api_key
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Based on exception_notification
|
|
2
|
+
# http://github.com/rails/exception_notification
|
|
3
|
+
# Copyright (c) 2005 Jamis Buck, released under the MIT license
|
|
4
|
+
|
|
5
|
+
require 'action_dispatch'
|
|
6
|
+
|
|
7
|
+
module Failurous
|
|
8
|
+
class FailMiddleware
|
|
9
|
+
def self.default_ignore_exceptions
|
|
10
|
+
[].tap do |exceptions|
|
|
11
|
+
exceptions << ::ActiveRecord::RecordNotFound if defined?(::ActiveRecord::RecordNotFound)
|
|
12
|
+
exceptions << ::AbstractController::ActionNotFound if defined?(::AbstractController::ActionNotFound)
|
|
13
|
+
exceptions << ::ActionController::RoutingError if defined?(::ActionController::RoutingError)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def initialize(app, options = {})
|
|
18
|
+
@app, @options = app, options
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def call(env)
|
|
22
|
+
@app.call(env)
|
|
23
|
+
rescue Exception => exception
|
|
24
|
+
unless FailMiddleware.default_ignore_exceptions.include?(exception.class)
|
|
25
|
+
send_exception_notification(env, exception)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
raise exception
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def send_exception_notification(env, exception)
|
|
34
|
+
@env = env
|
|
35
|
+
@exception = exception
|
|
36
|
+
@controller = env['action_controller.instance'] || MissingController.new
|
|
37
|
+
@request = ActionDispatch::Request.new(env)
|
|
38
|
+
@backtrace = clean_backtrace(exception)
|
|
39
|
+
|
|
40
|
+
notification = FailNotification.new.
|
|
41
|
+
from_exception(exception).
|
|
42
|
+
add_field(:request, :REQUEST_METHOD, @request.method, {:humanize_field_name => false}).
|
|
43
|
+
add_field(:request, :REQUEST_URI, @request.request_uri, {:humanize_field_name => false}).
|
|
44
|
+
add_field(:request, :REMOTE_ADDR, @request.remote_ip, {:humanize_field_name => false}).
|
|
45
|
+
add_field(:request, :HTTP_USER_AGENT, @request.headers["User-Agent"], {:humanize_field_name => false}).
|
|
46
|
+
add_field(:summary, :location, "#{@controller.controller_name}##{@controller.action_name}", {:use_in_checksum => true}).
|
|
47
|
+
add_field(:details, :params, @controller.params, {:use_in_checksum => false})
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
FailNotifier.send_fail(notification)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def clean_backtrace(exception)
|
|
54
|
+
Rails.respond_to?(:backtrace_cleaner) ?
|
|
55
|
+
Rails.backtrace_cleaner.send(:filter, exception.backtrace) :
|
|
56
|
+
exception.backtrace
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'active_support'
|
|
2
|
+
|
|
3
|
+
module Failurous
|
|
4
|
+
class FailNotification
|
|
5
|
+
attr_accessor :title
|
|
6
|
+
attr_accessor :data
|
|
7
|
+
|
|
8
|
+
# Builds a Notification from the given exception:
|
|
9
|
+
#
|
|
10
|
+
# Title: #{type}: #{message}
|
|
11
|
+
|
|
12
|
+
# Summary
|
|
13
|
+
# - type
|
|
14
|
+
# - message (not used when combining)
|
|
15
|
+
# - topmost line in backtrace
|
|
16
|
+
#
|
|
17
|
+
# Details:
|
|
18
|
+
# - full backtrace
|
|
19
|
+
#
|
|
20
|
+
def from_exception(exception)
|
|
21
|
+
self.set_title("#{exception.class}: #{exception.message}").
|
|
22
|
+
add_field(:summary, :type, exception.class.to_s, {:use_in_checksum => true}).
|
|
23
|
+
add_field(:summary, :message, exception.message, {:use_in_checksum => false}).
|
|
24
|
+
add_field(:summary, :topmost_line_in_backtrace, exception.backtrace[0], {:use_in_checksum => true}).
|
|
25
|
+
add_field(:details, :full_backtrace, exception.backtrace.join('\n'), {:use_in_checksum => false})
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def set_title(title)
|
|
29
|
+
@title = title
|
|
30
|
+
self
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def add_field(section_name, field_name, field_value, field_options = {})
|
|
34
|
+
@data ||= []
|
|
35
|
+
|
|
36
|
+
found = false
|
|
37
|
+
field = [field_name, field_value, field_options]
|
|
38
|
+
|
|
39
|
+
data.each do |existing_section|
|
|
40
|
+
if existing_section[0] == section_name
|
|
41
|
+
existing_section[1] << field
|
|
42
|
+
found = true
|
|
43
|
+
break
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
unless found
|
|
48
|
+
data << [section_name, [field]]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
self
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def to_json
|
|
55
|
+
ActiveSupport::JSON.encode({:title => @title, :data => @data})
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def send
|
|
59
|
+
FailNotifier.send_fail(self)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'uri'
|
|
3
|
+
|
|
4
|
+
module Failurous
|
|
5
|
+
class FailNotifier
|
|
6
|
+
def self.send_fail(notification)
|
|
7
|
+
server_address, api_key = [Failurous::Config.server_address, Failurous::Config.api_key]
|
|
8
|
+
post_address = "#{server_address}/api/projects/#{api_key}/fails"
|
|
9
|
+
|
|
10
|
+
p Net::HTTP.post_form URI.parse(post_address), {:data => notification.to_json}
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: failurous-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 21
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 1
|
|
9
|
+
- 7
|
|
10
|
+
version: 0.1.7
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- "Mikko Nyl\xC3\xA9n"
|
|
14
|
+
- Tero Parviainen
|
|
15
|
+
- Antti Forsell
|
|
16
|
+
autorequire:
|
|
17
|
+
bindir: bin
|
|
18
|
+
cert_chain: []
|
|
19
|
+
|
|
20
|
+
date: 2010-10-17 00:00:00 +03:00
|
|
21
|
+
default_executable:
|
|
22
|
+
dependencies:
|
|
23
|
+
- !ruby/object:Gem::Dependency
|
|
24
|
+
type: :runtime
|
|
25
|
+
prerelease: false
|
|
26
|
+
name: activesupport
|
|
27
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
hash: 9
|
|
33
|
+
segments:
|
|
34
|
+
- 2
|
|
35
|
+
- 3
|
|
36
|
+
- 5
|
|
37
|
+
version: 2.3.5
|
|
38
|
+
requirement: *id001
|
|
39
|
+
- !ruby/object:Gem::Dependency
|
|
40
|
+
type: :runtime
|
|
41
|
+
prerelease: false
|
|
42
|
+
name: actionpack
|
|
43
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
|
44
|
+
none: false
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
hash: 9
|
|
49
|
+
segments:
|
|
50
|
+
- 2
|
|
51
|
+
- 3
|
|
52
|
+
- 5
|
|
53
|
+
version: 2.3.5
|
|
54
|
+
requirement: *id002
|
|
55
|
+
description: Failurous is an open source webapp for monitoring exceptions in your live applications. failurous-rails is a Rails plugin that allows you to send easily notifications of new fails to your Failurous installation.
|
|
56
|
+
email:
|
|
57
|
+
executables: []
|
|
58
|
+
|
|
59
|
+
extensions: []
|
|
60
|
+
|
|
61
|
+
extra_rdoc_files:
|
|
62
|
+
- LICENSE
|
|
63
|
+
- README.md
|
|
64
|
+
files:
|
|
65
|
+
- client/failurous.rb
|
|
66
|
+
- client/failurous/config.rb
|
|
67
|
+
- client/failurous/fail_middleware.rb
|
|
68
|
+
- client/failurous/fail_notification.rb
|
|
69
|
+
- client/failurous/fail_notifier.rb
|
|
70
|
+
- LICENSE
|
|
71
|
+
- README.md
|
|
72
|
+
has_rdoc: true
|
|
73
|
+
homepage: http://github.com/railsrumble/rr10-team-256
|
|
74
|
+
licenses: []
|
|
75
|
+
|
|
76
|
+
post_install_message:
|
|
77
|
+
rdoc_options:
|
|
78
|
+
- --charset=UTF-8
|
|
79
|
+
require_paths:
|
|
80
|
+
- client
|
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
|
+
none: false
|
|
83
|
+
requirements:
|
|
84
|
+
- - ">="
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
hash: 3
|
|
87
|
+
segments:
|
|
88
|
+
- 0
|
|
89
|
+
version: "0"
|
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
|
+
none: false
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
hash: 3
|
|
96
|
+
segments:
|
|
97
|
+
- 0
|
|
98
|
+
version: "0"
|
|
99
|
+
requirements: []
|
|
100
|
+
|
|
101
|
+
rubyforge_project:
|
|
102
|
+
rubygems_version: 1.3.7
|
|
103
|
+
signing_key:
|
|
104
|
+
specification_version: 3
|
|
105
|
+
summary: Notifier for sending fails to Failurous installation
|
|
106
|
+
test_files: []
|
|
107
|
+
|