failbot 1.0.0 → 1.1.0
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.
- checksums.yaml +4 -4
- data/lib/failbot.rb +55 -0
- data/lib/failbot/middleware.rb +8 -1
- data/lib/failbot/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05b8062afa435bd8569bfed53ea09bf86a1ae64c
|
4
|
+
data.tar.gz: a2a41bd715001268b3ea1265e7d477ec7434aaa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b155496369bb447e379416aee98d77c8f0b120b351cfd7dbb05f672679ac57e6d0800141173901dcbd8dd2d1917f50ae3e1354cceeb1b205895c0ff00052e76
|
7
|
+
data.tar.gz: 1675c9ac35f5feaf94920c888d29d151c8fd23e6c3ab93284425334b2737f0f95bf735f189f5f8f01aa5510008b8ebb6a1dc75b69851a1d743368ce377d64518
|
data/lib/failbot.rb
CHANGED
@@ -21,6 +21,24 @@ module Failbot
|
|
21
21
|
autoload :MemoryBackend, 'failbot/memory_backend'
|
22
22
|
autoload :JSONBackend, 'failbot/json_backend'
|
23
23
|
|
24
|
+
# Public: Set an instrumenter to be called when exceptions are reported.
|
25
|
+
#
|
26
|
+
# class CustomInstrumenter
|
27
|
+
# def instrument(name, payload = {})
|
28
|
+
# warn "Exception: #{payload["class"]}\n#{payload.inspect}"
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# Failbot.instrumenter = CustomInstrumenter
|
33
|
+
#
|
34
|
+
# The instrumenter must conform to the `ActiveSupport::Notifications`
|
35
|
+
# interface, which defines `#instrument` and accepts:
|
36
|
+
#
|
37
|
+
# name - the String name of the event (e.g. "report.failbot")
|
38
|
+
# payload - a Hash of the exception context.
|
39
|
+
#
|
40
|
+
attr_accessor :instrumenter
|
41
|
+
|
24
42
|
# prevent recursive calls to Failbot.report!
|
25
43
|
attr_accessor :already_reporting
|
26
44
|
|
@@ -142,6 +160,7 @@ module Failbot
|
|
142
160
|
|
143
161
|
self.already_reporting = true
|
144
162
|
backend.report(data)
|
163
|
+
instrument("report.failbot", data)
|
145
164
|
rescue Object => i
|
146
165
|
# don't fail for any reason
|
147
166
|
logger.debug "FAILBOT: #{data.inspect}" rescue nil
|
@@ -153,6 +172,35 @@ module Failbot
|
|
153
172
|
self.already_reporting = false
|
154
173
|
end
|
155
174
|
|
175
|
+
# Public: Disable exception reporting. This is equivalent to calling
|
176
|
+
# `Failbot.setup("FAILBOT_REPORT" => 0)`, but can be called after setup.
|
177
|
+
#
|
178
|
+
# Failbot.disable do
|
179
|
+
# something_that_might_go_kaboom
|
180
|
+
# end
|
181
|
+
#
|
182
|
+
# block - an optional block to perform while reporting is disabled. If a block
|
183
|
+
# is passed, reporting will be re-enabled after the block is called.
|
184
|
+
def disable(&block)
|
185
|
+
original_report_errors = @report_errors
|
186
|
+
@report_errors = false
|
187
|
+
|
188
|
+
if block
|
189
|
+
begin
|
190
|
+
block.call
|
191
|
+
ensure
|
192
|
+
@report_errors = original_report_errors
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Public: Enable exception reporting. Reporting is enabled by default, but
|
198
|
+
# this can be called if it is explicitly disabled by calling `Failbot.disable`
|
199
|
+
# or setting `FAILBOT_REPORTING => "0"` in `Failbot.setup`.
|
200
|
+
def enable
|
201
|
+
@report_errors = true
|
202
|
+
end
|
203
|
+
|
156
204
|
# Public: exceptions that were reported. Only available when using the
|
157
205
|
# memory and file backends.
|
158
206
|
#
|
@@ -235,6 +283,13 @@ module Failbot
|
|
235
283
|
@hostname ||= Socket.gethostname
|
236
284
|
end
|
237
285
|
|
286
|
+
private
|
287
|
+
|
288
|
+
# Internal: Publish an event to the instrumenter
|
289
|
+
def instrument(name, payload = {})
|
290
|
+
Failbot.instrumenter.instrument(name, payload) if Failbot.instrumenter
|
291
|
+
end
|
292
|
+
|
238
293
|
extend self
|
239
294
|
|
240
295
|
# If the library was lazy loaded due to failbot/exit_hook.rb and a delayed
|
data/lib/failbot/middleware.rb
CHANGED
@@ -24,10 +24,17 @@ module Failbot
|
|
24
24
|
|
25
25
|
def self.context(env)
|
26
26
|
request = Rack::Request.new(env.dup)
|
27
|
+
params = {}
|
28
|
+
begin
|
29
|
+
params = request.params
|
30
|
+
rescue
|
31
|
+
env["rack.input"].rewind
|
32
|
+
end
|
33
|
+
|
27
34
|
{
|
28
35
|
:method => request.request_method,
|
29
36
|
:user_agent => env['HTTP_USER_AGENT'],
|
30
|
-
:params => filtered_parameters(env,
|
37
|
+
:params => filtered_parameters(env, params),
|
31
38
|
:session => (request.session.to_hash rescue nil),
|
32
39
|
:referrer => request.referrer,
|
33
40
|
:remote_ip => request.ip,
|
data/lib/failbot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: failbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "@rtomayko"
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: yajl-ruby
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0
|
35
|
+
version: '10.0'
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0
|
42
|
+
version: '10.0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rack-test
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0.6'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: minitest
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '5.0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '5.0'
|
57
71
|
description: "..."
|
58
72
|
email:
|
59
73
|
- github+failbot@lists.github.com
|