failbot 2.4.2 → 2.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/failbot.rb +22 -0
- data/lib/failbot/default_backtrace_parser.rb +23 -0
- data/lib/failbot/exception_format/structured.rb +6 -17
- data/lib/failbot/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5d1f28105f9f590c7c9160004bfa4a15101da5a1372ee0e40e882c493dad5fd
|
4
|
+
data.tar.gz: 5b09392f7d2243343a7982c6ae031f80d8501eb946d687490be6ad88e7321b1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 011af8c261c0826685972133268b52b85dcd358c402ee662575ef853b36f7c8ea6ff527673f2ec1210316d9cefc053aa8a20b119bfd55c09cf9666cbd6a0eeb8
|
7
|
+
data.tar.gz: 58bc429f5b2e27ef75f570eb2d194d2e956dc935bc5ec471042a0029ae8e14a929ee486abe25d2bd9e52ee9f052eccec559b18f31bf3ee292441e51820880bf1
|
data/lib/failbot.rb
CHANGED
@@ -11,6 +11,7 @@ require "failbot/compat"
|
|
11
11
|
require "failbot/sensitive_data_scrubber"
|
12
12
|
require "failbot/exception_format/haystack"
|
13
13
|
require "failbot/exception_format/structured"
|
14
|
+
require "failbot/default_backtrace_parser"
|
14
15
|
|
15
16
|
# Failbot asynchronously takes exceptions and reports them to the
|
16
17
|
# exception logger du jour. Keeps the main app from failing or lagging if
|
@@ -84,6 +85,27 @@ module Failbot
|
|
84
85
|
# apps opt in to the newer version.
|
85
86
|
self.exception_format = :haystack
|
86
87
|
|
88
|
+
# Set a callable that is responsible for parsing and formatting ruby
|
89
|
+
# backtraces. This is only necessary to set if your app deals with
|
90
|
+
# exceptions that are manipulated to contain something other than actual
|
91
|
+
# stackframe strings in the format produced by `caller`. The argument passed
|
92
|
+
# must respond to `call` with an arity of 1. The callable expects to be
|
93
|
+
# passed Exception instances as its argument.
|
94
|
+
def self.backtrace_parser=(callable)
|
95
|
+
unless callable.respond_to?(:call)
|
96
|
+
raise ArgumentError, "backtrace_parser= passed #{callable.inspect}, which is not callable"
|
97
|
+
end
|
98
|
+
if callable.method(:call).arity != 1
|
99
|
+
raise ArgumentError, "backtrace_parser= passed #{callable.inspect}, whose `#call` has arity =! 1"
|
100
|
+
end
|
101
|
+
@backtrace_parser = callable
|
102
|
+
end
|
103
|
+
|
104
|
+
attr_reader :backtrace_parser
|
105
|
+
|
106
|
+
# Default backtrace parser is provided:
|
107
|
+
self.backtrace_parser = ::Failbot::DefaultBacktraceParser
|
108
|
+
|
87
109
|
# Helpers needed to parse hashes included in e.g. Failbot.reports.
|
88
110
|
def self.exception_message_from_hash(hash)
|
89
111
|
@exception_formatter.exception_message_from_hash(hash)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Failbot
|
2
|
+
# This is the default backtrace parser for the Structured formatter.
|
3
|
+
module DefaultBacktraceParser
|
4
|
+
EMPTY_ARRAY = [].freeze
|
5
|
+
|
6
|
+
# Takes an Exception instance, returns an array of hashes with the keys
|
7
|
+
# that the Structured formatter expects.
|
8
|
+
def self.call(exception)
|
9
|
+
if exception.backtrace
|
10
|
+
Backtrace.parse(exception.backtrace).frames.reverse.map do |line|
|
11
|
+
{
|
12
|
+
"filename" => line.file_name,
|
13
|
+
"abs_path" => line.abs_path,
|
14
|
+
"lineno" => line.line_number,
|
15
|
+
"function" => line.method
|
16
|
+
}
|
17
|
+
end
|
18
|
+
else
|
19
|
+
EMPTY_ARRAY
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -13,16 +13,18 @@ module Failbot
|
|
13
13
|
# Format an exception.
|
14
14
|
def self.call(e)
|
15
15
|
message = e.message.to_s
|
16
|
+
class_name = e.class.to_s
|
16
17
|
stacktrace = begin
|
17
|
-
|
18
|
-
rescue
|
19
|
-
message += "\nUnable to parse backtrace
|
18
|
+
Failbot.backtrace_parser.call(e)
|
19
|
+
rescue => ex
|
20
|
+
message += "\nUnable to parse backtrace (#{ex.inspect})\nDon't put non-backtrace text in Exception#backtrace please!\nSo-called backtrace follows:\n#{e.backtrace.join("\n")}"
|
21
|
+
class_name += " (backtrace failed to parse)"
|
20
22
|
EMPTY_ARRAY
|
21
23
|
end
|
22
24
|
{
|
23
25
|
"exception_detail" => [ # TODO Once supported in failbotg, this should be an array of
|
24
26
|
{ # hashes generated from subsequent calls to Exception#cause.
|
25
|
-
"type" =>
|
27
|
+
"type" => class_name,
|
26
28
|
"value" => message,
|
27
29
|
"stacktrace" => stacktrace
|
28
30
|
}
|
@@ -41,19 +43,6 @@ module Failbot
|
|
41
43
|
def self.exception_classname_from_hash(hash)
|
42
44
|
hash.dig("exception_detail", 0, "type")
|
43
45
|
end
|
44
|
-
|
45
|
-
def self.formatted_backtrace(e)
|
46
|
-
if e.backtrace
|
47
|
-
Backtrace.parse(e.backtrace).frames.reverse.map do |line|
|
48
|
-
{
|
49
|
-
"filename" => line.file_name,
|
50
|
-
"abs_path" => line.abs_path,
|
51
|
-
"lineno" => line.line_number,
|
52
|
-
"function" => line.method
|
53
|
-
}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
46
|
end
|
58
47
|
end
|
59
48
|
end
|
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: 2.4.
|
4
|
+
version: 2.4.3
|
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: 2020-03-
|
13
|
+
date: 2020-03-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/failbot/backtrace.rb
|
94
94
|
- lib/failbot/compat.rb
|
95
95
|
- lib/failbot/console_backend.rb
|
96
|
+
- lib/failbot/default_backtrace_parser.rb
|
96
97
|
- lib/failbot/exception_format/haystack.rb
|
97
98
|
- lib/failbot/exception_format/structured.rb
|
98
99
|
- lib/failbot/exit_hook.rb
|