honeybadger 5.0.2 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +718 -701
- data/LICENSE +19 -19
- data/README.md +57 -57
- data/TROUBLESHOOTING.md +3 -3
- data/bin/honeybadger +5 -5
- data/lib/honeybadger/agent.rb +488 -488
- data/lib/honeybadger/backend/base.rb +116 -116
- data/lib/honeybadger/backend/debug.rb +22 -22
- data/lib/honeybadger/backend/null.rb +29 -29
- data/lib/honeybadger/backend/server.rb +62 -62
- data/lib/honeybadger/backend/test.rb +46 -46
- data/lib/honeybadger/backend.rb +27 -27
- data/lib/honeybadger/backtrace.rb +181 -181
- data/lib/honeybadger/breadcrumbs/active_support.rb +119 -119
- data/lib/honeybadger/breadcrumbs/breadcrumb.rb +53 -53
- data/lib/honeybadger/breadcrumbs/collector.rb +82 -82
- data/lib/honeybadger/breadcrumbs/logging.rb +55 -51
- data/lib/honeybadger/breadcrumbs/ring_buffer.rb +44 -44
- data/lib/honeybadger/breadcrumbs.rb +8 -8
- data/lib/honeybadger/cli/deploy.rb +43 -43
- data/lib/honeybadger/cli/exec.rb +143 -143
- data/lib/honeybadger/cli/helpers.rb +28 -28
- data/lib/honeybadger/cli/heroku.rb +129 -129
- data/lib/honeybadger/cli/install.rb +101 -101
- data/lib/honeybadger/cli/main.rb +237 -237
- data/lib/honeybadger/cli/notify.rb +67 -67
- data/lib/honeybadger/cli/test.rb +267 -267
- data/lib/honeybadger/cli.rb +14 -14
- data/lib/honeybadger/config/defaults.rb +336 -333
- data/lib/honeybadger/config/env.rb +42 -42
- data/lib/honeybadger/config/ruby.rb +146 -146
- data/lib/honeybadger/config/yaml.rb +76 -76
- data/lib/honeybadger/config.rb +416 -413
- data/lib/honeybadger/const.rb +20 -20
- data/lib/honeybadger/context_manager.rb +55 -55
- data/lib/honeybadger/conversions.rb +16 -16
- data/lib/honeybadger/init/hanami.rb +19 -0
- data/lib/honeybadger/init/rails.rb +38 -38
- data/lib/honeybadger/init/rake.rb +66 -66
- data/lib/honeybadger/init/ruby.rb +11 -11
- data/lib/honeybadger/init/sinatra.rb +57 -51
- data/lib/honeybadger/logging.rb +177 -177
- data/lib/honeybadger/notice.rb +579 -568
- data/lib/honeybadger/plugin.rb +210 -210
- data/lib/honeybadger/plugins/breadcrumbs.rb +111 -111
- data/lib/honeybadger/plugins/delayed_job/plugin.rb +56 -56
- data/lib/honeybadger/plugins/delayed_job.rb +22 -22
- data/lib/honeybadger/plugins/faktory.rb +52 -52
- data/lib/honeybadger/plugins/lambda.rb +71 -71
- data/lib/honeybadger/plugins/local_variables.rb +44 -44
- data/lib/honeybadger/plugins/passenger.rb +23 -23
- data/lib/honeybadger/plugins/rails.rb +72 -63
- data/lib/honeybadger/plugins/resque.rb +72 -72
- data/lib/honeybadger/plugins/shoryuken.rb +52 -52
- data/lib/honeybadger/plugins/sidekiq.rb +71 -62
- data/lib/honeybadger/plugins/sucker_punch.rb +18 -18
- data/lib/honeybadger/plugins/thor.rb +32 -32
- data/lib/honeybadger/plugins/warden.rb +19 -19
- data/lib/honeybadger/rack/error_notifier.rb +92 -92
- data/lib/honeybadger/rack/user_feedback.rb +88 -88
- data/lib/honeybadger/rack/user_informer.rb +45 -45
- data/lib/honeybadger/ruby.rb +2 -2
- data/lib/honeybadger/singleton.rb +103 -103
- data/lib/honeybadger/tasks.rb +22 -22
- data/lib/honeybadger/templates/feedback_form.erb +84 -84
- data/lib/honeybadger/util/http.rb +92 -92
- data/lib/honeybadger/util/lambda.rb +32 -32
- data/lib/honeybadger/util/request_hash.rb +73 -73
- data/lib/honeybadger/util/request_payload.rb +41 -41
- data/lib/honeybadger/util/revision.rb +39 -39
- data/lib/honeybadger/util/sanitizer.rb +214 -214
- data/lib/honeybadger/util/sql.rb +34 -34
- data/lib/honeybadger/util/stats.rb +50 -50
- data/lib/honeybadger/version.rb +4 -4
- data/lib/honeybadger/worker.rb +253 -253
- data/lib/honeybadger.rb +13 -11
- data/resources/ca-bundle.crt +3376 -3376
- data/vendor/capistrano-honeybadger/lib/capistrano/honeybadger.rb +5 -5
- data/vendor/capistrano-honeybadger/lib/capistrano/tasks/deploy.cap +89 -89
- data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano/legacy.rb +47 -47
- data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano.rb +2 -2
- data/vendor/cli/inifile.rb +628 -628
- data/vendor/cli/thor/actions/create_file.rb +103 -103
- data/vendor/cli/thor/actions/create_link.rb +59 -59
- data/vendor/cli/thor/actions/directory.rb +118 -118
- data/vendor/cli/thor/actions/empty_directory.rb +135 -135
- data/vendor/cli/thor/actions/file_manipulation.rb +316 -316
- data/vendor/cli/thor/actions/inject_into_file.rb +107 -107
- data/vendor/cli/thor/actions.rb +319 -319
- data/vendor/cli/thor/base.rb +656 -656
- data/vendor/cli/thor/command.rb +133 -133
- data/vendor/cli/thor/core_ext/hash_with_indifferent_access.rb +77 -77
- data/vendor/cli/thor/core_ext/io_binary_read.rb +10 -10
- data/vendor/cli/thor/core_ext/ordered_hash.rb +98 -98
- data/vendor/cli/thor/error.rb +32 -32
- data/vendor/cli/thor/group.rb +281 -281
- data/vendor/cli/thor/invocation.rb +178 -178
- data/vendor/cli/thor/line_editor/basic.rb +35 -35
- data/vendor/cli/thor/line_editor/readline.rb +88 -88
- data/vendor/cli/thor/line_editor.rb +17 -17
- data/vendor/cli/thor/parser/argument.rb +73 -73
- data/vendor/cli/thor/parser/arguments.rb +175 -175
- data/vendor/cli/thor/parser/option.rb +125 -125
- data/vendor/cli/thor/parser/options.rb +218 -218
- data/vendor/cli/thor/parser.rb +4 -4
- data/vendor/cli/thor/rake_compat.rb +71 -71
- data/vendor/cli/thor/runner.rb +322 -322
- data/vendor/cli/thor/shell/basic.rb +421 -421
- data/vendor/cli/thor/shell/color.rb +149 -149
- data/vendor/cli/thor/shell/html.rb +126 -126
- data/vendor/cli/thor/shell.rb +81 -81
- data/vendor/cli/thor/util.rb +267 -267
- data/vendor/cli/thor/version.rb +3 -3
- data/vendor/cli/thor.rb +484 -484
- metadata +11 -5
@@ -1,181 +1,181 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module Honeybadger
|
4
|
-
# @api private
|
5
|
-
# Front end to parsing the backtrace for each notice.
|
6
|
-
class Backtrace
|
7
|
-
# Handles backtrace parsing line by line.
|
8
|
-
class Line
|
9
|
-
# Backtrace line regexp (optionally allowing leading X: for windows support).
|
10
|
-
INPUT_FORMAT = %r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$}.freeze
|
11
|
-
|
12
|
-
# The file portion of the line (such as app/models/user.rb).
|
13
|
-
attr_reader :file
|
14
|
-
|
15
|
-
# The line number portion of the line.
|
16
|
-
attr_reader :number
|
17
|
-
|
18
|
-
# The method of the line (such as index).
|
19
|
-
attr_reader :method
|
20
|
-
|
21
|
-
# Filtered representations
|
22
|
-
attr_reader :filtered_file, :filtered_number, :filtered_method
|
23
|
-
|
24
|
-
# Parses a single line of a given backtrace
|
25
|
-
#
|
26
|
-
# @param [String] unparsed_line The raw line from +caller+ or some backtrace.
|
27
|
-
#
|
28
|
-
# @return The parsed backtrace line.
|
29
|
-
def self.parse(unparsed_line, opts = {})
|
30
|
-
filters = opts[:filters] || []
|
31
|
-
filtered_line = filters.reduce(unparsed_line) do |line, proc|
|
32
|
-
# TODO: Break if nil
|
33
|
-
if proc.arity == 2
|
34
|
-
proc.call(line, opts[:config])
|
35
|
-
else
|
36
|
-
proc.call(line)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
if filtered_line
|
41
|
-
match = unparsed_line.match(INPUT_FORMAT) || [].freeze
|
42
|
-
fmatch = filtered_line.match(INPUT_FORMAT) || [].freeze
|
43
|
-
|
44
|
-
file, number, method = match[1], match[2], match[3]
|
45
|
-
filtered_args = [fmatch[1], fmatch[2], fmatch[3]]
|
46
|
-
new(file, number, method, *filtered_args, opts.fetch(:source_radius, 2))
|
47
|
-
else
|
48
|
-
nil
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def initialize(file, number, method, filtered_file = file,
|
53
|
-
filtered_number = number, filtered_method = method,
|
54
|
-
source_radius = 2)
|
55
|
-
self.filtered_file = filtered_file
|
56
|
-
self.filtered_number = filtered_number
|
57
|
-
self.filtered_method = filtered_method
|
58
|
-
self.file = file
|
59
|
-
self.number = number
|
60
|
-
self.method = method
|
61
|
-
self.source_radius = source_radius
|
62
|
-
end
|
63
|
-
|
64
|
-
# Reconstructs the line in a readable fashion.
|
65
|
-
def to_s
|
66
|
-
"#{filtered_file}:#{filtered_number}:in `#{filtered_method}'"
|
67
|
-
end
|
68
|
-
|
69
|
-
def ==(other)
|
70
|
-
to_s == other.to_s
|
71
|
-
end
|
72
|
-
|
73
|
-
def inspect
|
74
|
-
"<Line:#{to_s}>"
|
75
|
-
end
|
76
|
-
|
77
|
-
# Determines if this line is part of the application trace or not.
|
78
|
-
def application?
|
79
|
-
(filtered_file =~ /^\[PROJECT_ROOT\]/i) && !(filtered_file =~ /^\[PROJECT_ROOT\]\/vendor/i)
|
80
|
-
end
|
81
|
-
|
82
|
-
def source
|
83
|
-
@source ||= get_source(file, number, source_radius)
|
84
|
-
end
|
85
|
-
|
86
|
-
private
|
87
|
-
|
88
|
-
attr_writer :file, :number, :method, :filtered_file, :filtered_number, :filtered_method
|
89
|
-
|
90
|
-
attr_accessor :source_radius
|
91
|
-
|
92
|
-
# Open source file and read line(s).
|
93
|
-
#
|
94
|
-
# Returns an array of line(s) from source file.
|
95
|
-
def get_source(file, number, radius = 2)
|
96
|
-
if file && File.exist?(file)
|
97
|
-
before = after = radius
|
98
|
-
start = (number.to_i - 1) - before
|
99
|
-
start = 0 and before = 1 if start <= 0
|
100
|
-
duration = before + 1 + after
|
101
|
-
|
102
|
-
l = 0
|
103
|
-
File.open(file) do |f|
|
104
|
-
start.times { f.gets ; l += 1 }
|
105
|
-
return Hash[duration.times.map { (line = f.gets) ? [(l += 1), line] : nil }.compact]
|
106
|
-
end
|
107
|
-
else
|
108
|
-
{}
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
# Holder for an Array of Backtrace::Line instances.
|
114
|
-
attr_reader :lines, :application_lines
|
115
|
-
|
116
|
-
def self.parse(ruby_backtrace, opts = {})
|
117
|
-
ruby_lines = split_multiline_backtrace(ruby_backtrace.to_a)
|
118
|
-
|
119
|
-
lines = ruby_lines.collect do |unparsed_line|
|
120
|
-
Line.parse(unparsed_line.to_s, opts)
|
121
|
-
end.compact
|
122
|
-
|
123
|
-
instance = new(lines)
|
124
|
-
end
|
125
|
-
|
126
|
-
def initialize(lines)
|
127
|
-
self.lines = lines
|
128
|
-
self.application_lines = lines.select(&:application?)
|
129
|
-
end
|
130
|
-
|
131
|
-
# Convert Backtrace to arry.
|
132
|
-
#
|
133
|
-
# Returns array containing backtrace lines.
|
134
|
-
def to_ary
|
135
|
-
lines.take(1000).map { |l| { :number => l.filtered_number, :file => l.filtered_file, :method => l.filtered_method, :source => l.source } }
|
136
|
-
end
|
137
|
-
alias :to_a :to_ary
|
138
|
-
|
139
|
-
# JSON support.
|
140
|
-
#
|
141
|
-
# Returns JSON representation of backtrace.
|
142
|
-
def as_json(options = {})
|
143
|
-
to_ary
|
144
|
-
end
|
145
|
-
|
146
|
-
# Creates JSON.
|
147
|
-
#
|
148
|
-
# Returns valid JSON representation of backtrace.
|
149
|
-
def to_json(*a)
|
150
|
-
as_json.to_json(*a)
|
151
|
-
end
|
152
|
-
|
153
|
-
def to_s
|
154
|
-
lines.map(&:to_s).join("\n")
|
155
|
-
end
|
156
|
-
|
157
|
-
def inspect
|
158
|
-
"<Backtrace: " + lines.collect { |line| line.inspect }.join(", ") + ">"
|
159
|
-
end
|
160
|
-
|
161
|
-
def ==(other)
|
162
|
-
if other.respond_to?(:to_json)
|
163
|
-
to_json == other.to_json
|
164
|
-
else
|
165
|
-
false
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
private
|
170
|
-
|
171
|
-
attr_writer :lines, :application_lines
|
172
|
-
|
173
|
-
def self.split_multiline_backtrace(backtrace)
|
174
|
-
if backtrace.size == 1
|
175
|
-
backtrace.first.to_s.split(/\n\s*/)
|
176
|
-
else
|
177
|
-
backtrace
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Honeybadger
|
4
|
+
# @api private
|
5
|
+
# Front end to parsing the backtrace for each notice.
|
6
|
+
class Backtrace
|
7
|
+
# Handles backtrace parsing line by line.
|
8
|
+
class Line
|
9
|
+
# Backtrace line regexp (optionally allowing leading X: for windows support).
|
10
|
+
INPUT_FORMAT = %r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$}.freeze
|
11
|
+
|
12
|
+
# The file portion of the line (such as app/models/user.rb).
|
13
|
+
attr_reader :file
|
14
|
+
|
15
|
+
# The line number portion of the line.
|
16
|
+
attr_reader :number
|
17
|
+
|
18
|
+
# The method of the line (such as index).
|
19
|
+
attr_reader :method
|
20
|
+
|
21
|
+
# Filtered representations
|
22
|
+
attr_reader :filtered_file, :filtered_number, :filtered_method
|
23
|
+
|
24
|
+
# Parses a single line of a given backtrace
|
25
|
+
#
|
26
|
+
# @param [String] unparsed_line The raw line from +caller+ or some backtrace.
|
27
|
+
#
|
28
|
+
# @return The parsed backtrace line.
|
29
|
+
def self.parse(unparsed_line, opts = {})
|
30
|
+
filters = opts[:filters] || []
|
31
|
+
filtered_line = filters.reduce(unparsed_line) do |line, proc|
|
32
|
+
# TODO: Break if nil
|
33
|
+
if proc.arity == 2
|
34
|
+
proc.call(line, opts[:config])
|
35
|
+
else
|
36
|
+
proc.call(line)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
if filtered_line
|
41
|
+
match = unparsed_line.match(INPUT_FORMAT) || [].freeze
|
42
|
+
fmatch = filtered_line.match(INPUT_FORMAT) || [].freeze
|
43
|
+
|
44
|
+
file, number, method = match[1], match[2], match[3]
|
45
|
+
filtered_args = [fmatch[1], fmatch[2], fmatch[3]]
|
46
|
+
new(file, number, method, *filtered_args, opts.fetch(:source_radius, 2))
|
47
|
+
else
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def initialize(file, number, method, filtered_file = file,
|
53
|
+
filtered_number = number, filtered_method = method,
|
54
|
+
source_radius = 2)
|
55
|
+
self.filtered_file = filtered_file
|
56
|
+
self.filtered_number = filtered_number
|
57
|
+
self.filtered_method = filtered_method
|
58
|
+
self.file = file
|
59
|
+
self.number = number
|
60
|
+
self.method = method
|
61
|
+
self.source_radius = source_radius
|
62
|
+
end
|
63
|
+
|
64
|
+
# Reconstructs the line in a readable fashion.
|
65
|
+
def to_s
|
66
|
+
"#{filtered_file}:#{filtered_number}:in `#{filtered_method}'"
|
67
|
+
end
|
68
|
+
|
69
|
+
def ==(other)
|
70
|
+
to_s == other.to_s
|
71
|
+
end
|
72
|
+
|
73
|
+
def inspect
|
74
|
+
"<Line:#{to_s}>"
|
75
|
+
end
|
76
|
+
|
77
|
+
# Determines if this line is part of the application trace or not.
|
78
|
+
def application?
|
79
|
+
(filtered_file =~ /^\[PROJECT_ROOT\]/i) && !(filtered_file =~ /^\[PROJECT_ROOT\]\/vendor/i)
|
80
|
+
end
|
81
|
+
|
82
|
+
def source
|
83
|
+
@source ||= get_source(file, number, source_radius)
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
attr_writer :file, :number, :method, :filtered_file, :filtered_number, :filtered_method
|
89
|
+
|
90
|
+
attr_accessor :source_radius
|
91
|
+
|
92
|
+
# Open source file and read line(s).
|
93
|
+
#
|
94
|
+
# Returns an array of line(s) from source file.
|
95
|
+
def get_source(file, number, radius = 2)
|
96
|
+
if file && File.exist?(file)
|
97
|
+
before = after = radius
|
98
|
+
start = (number.to_i - 1) - before
|
99
|
+
start = 0 and before = 1 if start <= 0
|
100
|
+
duration = before + 1 + after
|
101
|
+
|
102
|
+
l = 0
|
103
|
+
File.open(file) do |f|
|
104
|
+
start.times { f.gets ; l += 1 }
|
105
|
+
return Hash[duration.times.map { (line = f.gets) ? [(l += 1), line] : nil }.compact]
|
106
|
+
end
|
107
|
+
else
|
108
|
+
{}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Holder for an Array of Backtrace::Line instances.
|
114
|
+
attr_reader :lines, :application_lines
|
115
|
+
|
116
|
+
def self.parse(ruby_backtrace, opts = {})
|
117
|
+
ruby_lines = split_multiline_backtrace(ruby_backtrace.to_a)
|
118
|
+
|
119
|
+
lines = ruby_lines.collect do |unparsed_line|
|
120
|
+
Line.parse(unparsed_line.to_s, opts)
|
121
|
+
end.compact
|
122
|
+
|
123
|
+
instance = new(lines)
|
124
|
+
end
|
125
|
+
|
126
|
+
def initialize(lines)
|
127
|
+
self.lines = lines
|
128
|
+
self.application_lines = lines.select(&:application?)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Convert Backtrace to arry.
|
132
|
+
#
|
133
|
+
# Returns array containing backtrace lines.
|
134
|
+
def to_ary
|
135
|
+
lines.take(1000).map { |l| { :number => l.filtered_number, :file => l.filtered_file, :method => l.filtered_method, :source => l.source } }
|
136
|
+
end
|
137
|
+
alias :to_a :to_ary
|
138
|
+
|
139
|
+
# JSON support.
|
140
|
+
#
|
141
|
+
# Returns JSON representation of backtrace.
|
142
|
+
def as_json(options = {})
|
143
|
+
to_ary
|
144
|
+
end
|
145
|
+
|
146
|
+
# Creates JSON.
|
147
|
+
#
|
148
|
+
# Returns valid JSON representation of backtrace.
|
149
|
+
def to_json(*a)
|
150
|
+
as_json.to_json(*a)
|
151
|
+
end
|
152
|
+
|
153
|
+
def to_s
|
154
|
+
lines.map(&:to_s).join("\n")
|
155
|
+
end
|
156
|
+
|
157
|
+
def inspect
|
158
|
+
"<Backtrace: " + lines.collect { |line| line.inspect }.join(", ") + ">"
|
159
|
+
end
|
160
|
+
|
161
|
+
def ==(other)
|
162
|
+
if other.respond_to?(:to_json)
|
163
|
+
to_json == other.to_json
|
164
|
+
else
|
165
|
+
false
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
private
|
170
|
+
|
171
|
+
attr_writer :lines, :application_lines
|
172
|
+
|
173
|
+
def self.split_multiline_backtrace(backtrace)
|
174
|
+
if backtrace.size == 1
|
175
|
+
backtrace.first.to_s.split(/\n\s*/)
|
176
|
+
else
|
177
|
+
backtrace
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -1,119 +1,119 @@
|
|
1
|
-
require 'honeybadger/util/sql'
|
2
|
-
|
3
|
-
module Honeybadger
|
4
|
-
module Breadcrumbs
|
5
|
-
class ActiveSupport
|
6
|
-
def self.default_notifications
|
7
|
-
{
|
8
|
-
# ActiveRecord Actions
|
9
|
-
#
|
10
|
-
"sql.active_record" => {
|
11
|
-
message: lambda do |data|
|
12
|
-
# Disregard empty string names
|
13
|
-
name = data[:name] if data[:name] && !data[:name].strip.empty?
|
14
|
-
|
15
|
-
["Active Record", name].compact.join(" - ")
|
16
|
-
end,
|
17
|
-
category: "query",
|
18
|
-
select_keys: [:sql, :name, :connection, :connection_id, :cached],
|
19
|
-
transform: lambda do |data|
|
20
|
-
if data[:sql]
|
21
|
-
connection = data.delete(:connection)
|
22
|
-
adapter = (connection && connection.adapter_name.downcase) || active_record_connection_db_config[:adapter]
|
23
|
-
data[:sql] = Util::SQL.obfuscate(data[:sql], adapter)
|
24
|
-
end
|
25
|
-
data
|
26
|
-
end,
|
27
|
-
exclude_when: lambda do |data|
|
28
|
-
# Ignore schema, begin, and commit transaction queries
|
29
|
-
data[:name] == "SCHEMA" ||
|
30
|
-
(data[:sql] && (Util::SQL.force_utf_8(data[:sql].dup) =~ /^(begin|commit)( transaction)?$/i))
|
31
|
-
end
|
32
|
-
},
|
33
|
-
|
34
|
-
# ActionCable Actions
|
35
|
-
#
|
36
|
-
"perform_action.action_cable" => {
|
37
|
-
message: "Action Cable Perform Action",
|
38
|
-
select_keys: [:channel_class, :action],
|
39
|
-
category: "render"
|
40
|
-
},
|
41
|
-
|
42
|
-
# ActiveJob Actions
|
43
|
-
#
|
44
|
-
"enqueue.active_job" => {
|
45
|
-
message: "Active Job Enqueue",
|
46
|
-
select_keys: [],
|
47
|
-
category: "job"
|
48
|
-
},
|
49
|
-
"perform_start.active_job" => {
|
50
|
-
message: "Active Job Perform Start",
|
51
|
-
select_keys: [],
|
52
|
-
category: "job",
|
53
|
-
},
|
54
|
-
|
55
|
-
# ActiveSupport Actions
|
56
|
-
#
|
57
|
-
"cache_read.active_support" => {
|
58
|
-
message: "Active Support Cache Read",
|
59
|
-
category: "query"
|
60
|
-
},
|
61
|
-
"cache_fetch_hit.active_support" => {
|
62
|
-
message: "Active Support Cache Fetch Hit",
|
63
|
-
category: "query"
|
64
|
-
},
|
65
|
-
|
66
|
-
# Controller Actions
|
67
|
-
#
|
68
|
-
"halted_callback.action_controller" => {
|
69
|
-
message: "Action Controller Callback Halted",
|
70
|
-
category: "request",
|
71
|
-
},
|
72
|
-
"process_action.action_controller" => {
|
73
|
-
message: "Action Controller Action Process",
|
74
|
-
select_keys: [:controller, :action, :format, :method, :path, :status, :view_runtime, :db_runtime],
|
75
|
-
category: "request",
|
76
|
-
},
|
77
|
-
"start_processing.action_controller" => {
|
78
|
-
message: "Action Controller Start Process",
|
79
|
-
select_keys: [:controller, :action, :format, :method, :path],
|
80
|
-
category: "request",
|
81
|
-
},
|
82
|
-
"redirect_to.action_controller" => {
|
83
|
-
message: "Action Controller Redirect",
|
84
|
-
category: "request",
|
85
|
-
},
|
86
|
-
|
87
|
-
# View Actions
|
88
|
-
#
|
89
|
-
"render_template.action_view" => {
|
90
|
-
message: "Action View Template Render",
|
91
|
-
category: "render",
|
92
|
-
},
|
93
|
-
"render_partial.action_view" => {
|
94
|
-
message: "Action View Partial Render",
|
95
|
-
category: "render",
|
96
|
-
},
|
97
|
-
|
98
|
-
# Mailer actions
|
99
|
-
#
|
100
|
-
"deliver.action_mailer" => {
|
101
|
-
message: "Action Mailer Deliver",
|
102
|
-
select_keys: [:mailer, :message_id, :from, :date],
|
103
|
-
category: "render"
|
104
|
-
}
|
105
|
-
}
|
106
|
-
end
|
107
|
-
|
108
|
-
private_class_method def self.active_record_connection_db_config
|
109
|
-
if ::ActiveRecord::Base.respond_to?(:connection_db_config)
|
110
|
-
# >= Rails 6.1
|
111
|
-
::ActiveRecord::Base.connection_db_config.configuration_hash
|
112
|
-
else
|
113
|
-
# < Rails 6.1
|
114
|
-
::ActiveRecord::Base.connection_config
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
1
|
+
require 'honeybadger/util/sql'
|
2
|
+
|
3
|
+
module Honeybadger
|
4
|
+
module Breadcrumbs
|
5
|
+
class ActiveSupport
|
6
|
+
def self.default_notifications
|
7
|
+
{
|
8
|
+
# ActiveRecord Actions
|
9
|
+
#
|
10
|
+
"sql.active_record" => {
|
11
|
+
message: lambda do |data|
|
12
|
+
# Disregard empty string names
|
13
|
+
name = data[:name] if data[:name] && !data[:name].strip.empty?
|
14
|
+
|
15
|
+
["Active Record", name].compact.join(" - ")
|
16
|
+
end,
|
17
|
+
category: "query",
|
18
|
+
select_keys: [:sql, :name, :connection, :connection_id, :cached],
|
19
|
+
transform: lambda do |data|
|
20
|
+
if data[:sql]
|
21
|
+
connection = data.delete(:connection)
|
22
|
+
adapter = (connection && connection.adapter_name.downcase) || active_record_connection_db_config[:adapter]
|
23
|
+
data[:sql] = Util::SQL.obfuscate(data[:sql], adapter)
|
24
|
+
end
|
25
|
+
data
|
26
|
+
end,
|
27
|
+
exclude_when: lambda do |data|
|
28
|
+
# Ignore schema, begin, and commit transaction queries
|
29
|
+
data[:name] == "SCHEMA" ||
|
30
|
+
(data[:sql] && (Util::SQL.force_utf_8(data[:sql].dup) =~ /^(begin|commit)( transaction)?$/i))
|
31
|
+
end
|
32
|
+
},
|
33
|
+
|
34
|
+
# ActionCable Actions
|
35
|
+
#
|
36
|
+
"perform_action.action_cable" => {
|
37
|
+
message: "Action Cable Perform Action",
|
38
|
+
select_keys: [:channel_class, :action],
|
39
|
+
category: "render"
|
40
|
+
},
|
41
|
+
|
42
|
+
# ActiveJob Actions
|
43
|
+
#
|
44
|
+
"enqueue.active_job" => {
|
45
|
+
message: "Active Job Enqueue",
|
46
|
+
select_keys: [],
|
47
|
+
category: "job"
|
48
|
+
},
|
49
|
+
"perform_start.active_job" => {
|
50
|
+
message: "Active Job Perform Start",
|
51
|
+
select_keys: [],
|
52
|
+
category: "job",
|
53
|
+
},
|
54
|
+
|
55
|
+
# ActiveSupport Actions
|
56
|
+
#
|
57
|
+
"cache_read.active_support" => {
|
58
|
+
message: "Active Support Cache Read",
|
59
|
+
category: "query"
|
60
|
+
},
|
61
|
+
"cache_fetch_hit.active_support" => {
|
62
|
+
message: "Active Support Cache Fetch Hit",
|
63
|
+
category: "query"
|
64
|
+
},
|
65
|
+
|
66
|
+
# Controller Actions
|
67
|
+
#
|
68
|
+
"halted_callback.action_controller" => {
|
69
|
+
message: "Action Controller Callback Halted",
|
70
|
+
category: "request",
|
71
|
+
},
|
72
|
+
"process_action.action_controller" => {
|
73
|
+
message: "Action Controller Action Process",
|
74
|
+
select_keys: [:controller, :action, :format, :method, :path, :status, :view_runtime, :db_runtime],
|
75
|
+
category: "request",
|
76
|
+
},
|
77
|
+
"start_processing.action_controller" => {
|
78
|
+
message: "Action Controller Start Process",
|
79
|
+
select_keys: [:controller, :action, :format, :method, :path],
|
80
|
+
category: "request",
|
81
|
+
},
|
82
|
+
"redirect_to.action_controller" => {
|
83
|
+
message: "Action Controller Redirect",
|
84
|
+
category: "request",
|
85
|
+
},
|
86
|
+
|
87
|
+
# View Actions
|
88
|
+
#
|
89
|
+
"render_template.action_view" => {
|
90
|
+
message: "Action View Template Render",
|
91
|
+
category: "render",
|
92
|
+
},
|
93
|
+
"render_partial.action_view" => {
|
94
|
+
message: "Action View Partial Render",
|
95
|
+
category: "render",
|
96
|
+
},
|
97
|
+
|
98
|
+
# Mailer actions
|
99
|
+
#
|
100
|
+
"deliver.action_mailer" => {
|
101
|
+
message: "Action Mailer Deliver",
|
102
|
+
select_keys: [:mailer, :message_id, :from, :date],
|
103
|
+
category: "render"
|
104
|
+
}
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
private_class_method def self.active_record_connection_db_config
|
109
|
+
if ::ActiveRecord::Base.respond_to?(:connection_db_config)
|
110
|
+
# >= Rails 6.1
|
111
|
+
::ActiveRecord::Base.connection_db_config.configuration_hash
|
112
|
+
else
|
113
|
+
# < Rails 6.1
|
114
|
+
::ActiveRecord::Base.connection_config
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|