failbot 1.2.0 → 1.3.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 +39 -20
- data/lib/failbot/json_backend.rb +1 -1
- data/lib/failbot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d710f1c5942b7b228fb70cebf33d7bfbcc5f3bbf
|
4
|
+
data.tar.gz: 0ab8adce8358db0ebd4745a12b497c33eabf9b3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db3c86ddad1bf8070b74ad1d5081b568164be50cc527272177f41515a75c106ded9634fb71f7a2cff69a20c042873b37cfae760122d635f94975b81578d2a26a
|
7
|
+
data.tar.gz: 5f94db35e19e527a0c0d3f6f9b86f1318d08d30dd7eab9d8463986f467671009159501a5fac999deeec9eecfe716ac1253fa9a1cdb7a70491519b583e34a5fd9
|
data/lib/failbot.rb
CHANGED
@@ -148,6 +148,40 @@ module Failbot
|
|
148
148
|
@before_report = nil
|
149
149
|
end
|
150
150
|
|
151
|
+
# Specify a custom block for calculating rollups. It should accept:
|
152
|
+
#
|
153
|
+
# exception - The exception object
|
154
|
+
# context - The context hash
|
155
|
+
#
|
156
|
+
# The block must return a String.
|
157
|
+
#
|
158
|
+
# If a `rollup` attribute is supplied at the time of reporting, either via
|
159
|
+
# the `failbot_context` method on an exception, or passed to `Failbot.report`,
|
160
|
+
# it will be used as the rollup and this block will not be called.
|
161
|
+
def rollup(&block)
|
162
|
+
@rollup = block
|
163
|
+
end
|
164
|
+
|
165
|
+
# Default rollup for an exception. Exceptions with the same rollup are
|
166
|
+
# grouped together in Haystack. The rollup is an MD5 hash of the exception
|
167
|
+
# class and the raising file, line, and method.
|
168
|
+
DEFAULT_ROLLUP = lambda do |exception, context|
|
169
|
+
backtrace_line = Array(exception.backtrace).first || ""
|
170
|
+
# We want all exceptions from foo.html.erb:123 to be grouped together, no
|
171
|
+
# matter what wacky generated ERB method name is attached to it.
|
172
|
+
cleaned_line = backtrace_line.sub(/_erb__[_\d]+'\z/, "_erb'")
|
173
|
+
|
174
|
+
Digest::MD5.hexdigest("#{exception.class}#{cleaned_line}")
|
175
|
+
end
|
176
|
+
|
177
|
+
private_constant :DEFAULT_ROLLUP
|
178
|
+
|
179
|
+
def use_default_rollup
|
180
|
+
rollup(&DEFAULT_ROLLUP)
|
181
|
+
end
|
182
|
+
|
183
|
+
use_default_rollup
|
184
|
+
|
151
185
|
# Public: Sends an exception to the exception tracking service along
|
152
186
|
# with a hash of custom attributes to be included with the report. When the
|
153
187
|
# raise_errors option is set, this method raises the exception instead of
|
@@ -178,6 +212,10 @@ module Failbot
|
|
178
212
|
return unless @report_errors
|
179
213
|
data = squash_contexts(context, exception_info(e), other)
|
180
214
|
|
215
|
+
if !data.has_key?("rollup")
|
216
|
+
data = data.merge("rollup" => @rollup.call(e, data))
|
217
|
+
end
|
218
|
+
|
181
219
|
if @before_report
|
182
220
|
data = squash_contexts(data, @before_report.call(e, data))
|
183
221
|
end
|
@@ -293,9 +331,7 @@ module Failbot
|
|
293
331
|
#
|
294
332
|
# e - The exception object to turn into a Hash.
|
295
333
|
#
|
296
|
-
# Returns a Hash including a 'class', 'message', 'backtrace'
|
297
|
-
# keys. The rollup value is an MD5 hash of the exception class and the
|
298
|
-
# raising file, line, and method.
|
334
|
+
# Returns a Hash including a 'class', 'message', 'backtrace' keys.
|
299
335
|
def exception_info(e)
|
300
336
|
backtrace = Array(e.backtrace)[0, 500]
|
301
337
|
|
@@ -304,7 +340,6 @@ module Failbot
|
|
304
340
|
'message' => e.message,
|
305
341
|
'backtrace' => backtrace.join("\n"),
|
306
342
|
'ruby' => RUBY_DESCRIPTION,
|
307
|
-
'rollup' => rollup(e),
|
308
343
|
'created_at' => Time.now.utc.iso8601(6)
|
309
344
|
}
|
310
345
|
|
@@ -343,22 +378,6 @@ module Failbot
|
|
343
378
|
Failbot.instrumenter.instrument(name, payload) if Failbot.instrumenter
|
344
379
|
end
|
345
380
|
|
346
|
-
# Generate a rollup for an exception. Exceptions with the same rollup are
|
347
|
-
# grouped together in Haystack. The rollup is an MD5 hash of the exception
|
348
|
-
# class and the raising file, line, and method.
|
349
|
-
#
|
350
|
-
# e - The exception object
|
351
|
-
#
|
352
|
-
# Returns a String.
|
353
|
-
def rollup(e)
|
354
|
-
backtrace_line = Array(e.backtrace).first || ""
|
355
|
-
# We want all exceptions from foo.html.erb:123 to be grouped together, no
|
356
|
-
# matter what wacky generated ERB method name is attached to it.
|
357
|
-
cleaned_line = backtrace_line.sub(/_erb__[_\d]+'\z/, "_erb'")
|
358
|
-
|
359
|
-
Digest::MD5.hexdigest("#{e.class}#{cleaned_line}")
|
360
|
-
end
|
361
|
-
|
362
381
|
extend self
|
363
382
|
|
364
383
|
# If the library was lazy loaded due to failbot/exit_hook.rb and a delayed
|
data/lib/failbot/json_backend.rb
CHANGED
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.3.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: 2015-
|
13
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: yajl-ruby
|