honeybadger 5.29.1 → 6.0.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/CHANGELOG.md +22 -0
- data/lib/honeybadger/agent.rb +36 -35
- data/lib/honeybadger/backend/base.rb +11 -11
- data/lib/honeybadger/backend/debug.rb +4 -4
- data/lib/honeybadger/backend/null.rb +2 -2
- data/lib/honeybadger/backend/server.rb +11 -11
- data/lib/honeybadger/backend/test.rb +2 -2
- data/lib/honeybadger/backend.rb +6 -6
- data/lib/honeybadger/backtrace.rb +27 -22
- data/lib/honeybadger/breadcrumbs/active_support.rb +9 -9
- data/lib/honeybadger/breadcrumbs/breadcrumb.rb +1 -2
- data/lib/honeybadger/breadcrumbs/collector.rb +4 -4
- data/lib/honeybadger/breadcrumbs/logging.rb +11 -14
- data/lib/honeybadger/breadcrumbs.rb +3 -3
- data/lib/honeybadger/cli/deploy.rb +7 -7
- data/lib/honeybadger/cli/exec.rb +41 -41
- data/lib/honeybadger/cli/helpers.rb +18 -18
- data/lib/honeybadger/cli/heroku.rb +36 -36
- data/lib/honeybadger/cli/install.rb +44 -44
- data/lib/honeybadger/cli/main.rb +107 -107
- data/lib/honeybadger/cli/notify.rb +13 -13
- data/lib/honeybadger/cli/test.rb +109 -94
- data/lib/honeybadger/cli.rb +3 -3
- data/lib/honeybadger/config/defaults.rb +218 -218
- data/lib/honeybadger/config/env.rb +5 -5
- data/lib/honeybadger/config/ruby.rb +19 -19
- data/lib/honeybadger/config/yaml.rb +12 -12
- data/lib/honeybadger/config.rb +76 -78
- data/lib/honeybadger/const.rb +4 -4
- data/lib/honeybadger/context_manager.rb +1 -2
- data/lib/honeybadger/conversions.rb +9 -6
- data/lib/honeybadger/counter.rb +4 -4
- data/lib/honeybadger/event.rb +3 -3
- data/lib/honeybadger/events_worker.rb +33 -33
- data/lib/honeybadger/gauge.rb +2 -2
- data/lib/honeybadger/histogram.rb +4 -4
- data/lib/honeybadger/init/hanami.rb +5 -5
- data/lib/honeybadger/init/rails.rb +14 -14
- data/lib/honeybadger/init/rake.rb +19 -21
- data/lib/honeybadger/init/ruby.rb +4 -4
- data/lib/honeybadger/init/sinatra.rb +11 -12
- data/lib/honeybadger/instrumentation.rb +26 -31
- data/lib/honeybadger/instrumentation_helper.rb +11 -12
- data/lib/honeybadger/karafka.rb +55 -56
- data/lib/honeybadger/logging.rb +22 -21
- data/lib/honeybadger/metric.rb +2 -2
- data/lib/honeybadger/metrics_worker.rb +12 -10
- data/lib/honeybadger/notice.rb +55 -58
- data/lib/honeybadger/notification_subscriber.rb +14 -14
- data/lib/honeybadger/plugin.rb +16 -18
- data/lib/honeybadger/plugins/active_job.rb +11 -9
- data/lib/honeybadger/plugins/autotuner.rb +5 -5
- data/lib/honeybadger/plugins/breadcrumbs.rb +7 -7
- data/lib/honeybadger/plugins/delayed_job/plugin.rb +36 -37
- data/lib/honeybadger/plugins/delayed_job.rb +4 -4
- data/lib/honeybadger/plugins/faktory.rb +9 -9
- data/lib/honeybadger/plugins/karafka.rb +3 -3
- data/lib/honeybadger/plugins/lambda.rb +9 -11
- data/lib/honeybadger/plugins/local_variables.rb +4 -4
- data/lib/honeybadger/plugins/net_http.rb +10 -10
- data/lib/honeybadger/plugins/passenger.rb +4 -4
- data/lib/honeybadger/plugins/rails.rb +13 -9
- data/lib/honeybadger/plugins/resque.rb +7 -7
- data/lib/honeybadger/plugins/shoryuken.rb +6 -6
- data/lib/honeybadger/plugins/sidekiq.rb +61 -57
- data/lib/honeybadger/plugins/solid_queue.rb +3 -3
- data/lib/honeybadger/plugins/sucker_punch.rb +5 -5
- data/lib/honeybadger/plugins/system.rb +3 -3
- data/lib/honeybadger/plugins/thor.rb +5 -5
- data/lib/honeybadger/plugins/warden.rb +4 -4
- data/lib/honeybadger/rack/error_notifier.rb +14 -14
- data/lib/honeybadger/rack/user_feedback.rb +11 -12
- data/lib/honeybadger/rack/user_informer.rb +6 -6
- data/lib/honeybadger/registry.rb +2 -2
- data/lib/honeybadger/registry_execution.rb +1 -1
- data/lib/honeybadger/ruby.rb +2 -2
- data/lib/honeybadger/singleton.rb +49 -48
- data/lib/honeybadger/tasks.rb +3 -3
- data/lib/honeybadger/timer.rb +1 -1
- data/lib/honeybadger/util/http.rb +27 -27
- data/lib/honeybadger/util/request_hash.rb +11 -11
- data/lib/honeybadger/util/request_payload.rb +2 -2
- data/lib/honeybadger/util/revision.rb +14 -6
- data/lib/honeybadger/util/sanitizer.rb +22 -22
- data/lib/honeybadger/util/stats.rb +6 -3
- data/lib/honeybadger/version.rb +1 -1
- data/lib/honeybadger/worker.rb +31 -29
- data/lib/honeybadger.rb +5 -5
- data/lib/puma/plugin/honeybadger.rb +12 -8
- metadata +3 -3
data/lib/honeybadger/cli/main.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
1
|
+
require "honeybadger/cli/deploy"
|
2
|
+
require "honeybadger/cli/exec"
|
3
|
+
require "honeybadger/cli/heroku"
|
4
|
+
require "honeybadger/cli/install"
|
5
|
+
require "honeybadger/cli/notify"
|
6
|
+
require "honeybadger/cli/test"
|
7
|
+
require "honeybadger/config"
|
8
|
+
require "honeybadger/config/defaults"
|
9
|
+
require "honeybadger/ruby"
|
10
|
+
require "honeybadger/util/http"
|
11
|
+
require "honeybadger/version"
|
12
|
+
require "logger"
|
13
13
|
|
14
14
|
module Honeybadger
|
15
15
|
module CLI
|
16
16
|
BLANK = /\A\s*\z/
|
17
17
|
|
18
18
|
NOTIFIER = {
|
19
|
-
name:
|
20
|
-
url:
|
19
|
+
name: "honeybadger-ruby (cli)".freeze,
|
20
|
+
url: "https://github.com/honeybadger-io/honeybadger-ruby".freeze,
|
21
21
|
version: VERSION,
|
22
22
|
language: nil
|
23
23
|
}.freeze
|
24
24
|
|
25
25
|
class Main < Thor
|
26
26
|
def self.project_options
|
27
|
-
option :api_key,
|
28
|
-
option :environment,
|
29
|
-
option :skip_rails_load, required: false, type: :boolean, desc:
|
27
|
+
option :api_key, required: false, aliases: :"-k", type: :string, desc: "Api key of your Honeybadger application"
|
28
|
+
option :environment, required: false, aliases: [:"-e", :"-env"], type: :string, desc: 'Environment this command is being executed in (i.e. "production", "staging")'
|
29
|
+
option :skip_rails_load, required: false, type: :boolean, desc: "Flag to skip rails initialization"
|
30
30
|
end
|
31
31
|
|
32
32
|
def help(*args, &block)
|
33
33
|
if args.size == 0
|
34
|
-
say(
|
35
|
-
⚡ Honeybadger v#{VERSION}
|
36
|
-
|
37
|
-
Honeybadger is your favorite error tracker for Ruby. When your app raises an
|
38
|
-
exception we notify you with all the context you need to fix it.
|
39
|
-
|
40
|
-
The Honeybadger CLI provides tools for interacting with Honeybadger via the
|
41
|
-
command line.
|
42
|
-
|
43
|
-
If you need support, please drop us a line: support@honeybadger.io
|
44
|
-
|
45
|
-
WELCOME
|
34
|
+
say(<<~WELCOME)
|
35
|
+
⚡ Honeybadger v#{VERSION}
|
36
|
+
|
37
|
+
Honeybadger is your favorite error tracker for Ruby. When your app raises an
|
38
|
+
exception we notify you with all the context you need to fix it.
|
39
|
+
|
40
|
+
The Honeybadger CLI provides tools for interacting with Honeybadger via the
|
41
|
+
command line.
|
42
|
+
|
43
|
+
If you need support, please drop us a line: support@honeybadger.io
|
44
|
+
|
45
|
+
WELCOME
|
46
46
|
end
|
47
47
|
super
|
48
48
|
end
|
49
49
|
|
50
|
-
desc
|
51
|
-
option :insights, type: :boolean, aliases: :
|
50
|
+
desc "install API_KEY", "Install Honeybadger into a new project"
|
51
|
+
option :insights, type: :boolean, aliases: :"-i", default: true, desc: "Enable Honeybadger Insights"
|
52
52
|
option :host, type: :string
|
53
53
|
option :ui_host, type: :string
|
54
54
|
def install(api_key)
|
@@ -58,9 +58,9 @@ WELCOME
|
|
58
58
|
exit(1)
|
59
59
|
end
|
60
60
|
|
61
|
-
desc
|
62
|
-
option :dry_run, type: :boolean, aliases: :
|
63
|
-
option :file,
|
61
|
+
desc "test", "Send a test notification from Honeybadger"
|
62
|
+
option :dry_run, type: :boolean, aliases: :"-d", default: false, desc: "Skip sending data to Honeybadger"
|
63
|
+
option :file, type: :string, aliases: :"-f", default: nil, desc: "Write the output to FILE"
|
64
64
|
def test
|
65
65
|
Test.new(options).run
|
66
66
|
rescue => e
|
@@ -68,15 +68,15 @@ WELCOME
|
|
68
68
|
exit(1)
|
69
69
|
end
|
70
70
|
|
71
|
-
desc
|
71
|
+
desc "deploy", "Notify Honeybadger of deployment"
|
72
72
|
project_options
|
73
|
-
option :repository, required: true, type: :string, aliases: :
|
74
|
-
option :revision,
|
75
|
-
option :user,
|
73
|
+
option :repository, required: true, type: :string, aliases: :"-r", desc: "The address of your repository"
|
74
|
+
option :revision, required: true, type: :string, aliases: :"-s", desc: "The revision/sha that is being deployed"
|
75
|
+
option :user, required: true, type: :string, aliases: :"-u", default: ENV["USER"] || ENV["USERNAME"], desc: "The local user who is deploying"
|
76
76
|
def deploy
|
77
77
|
config = build_config(options)
|
78
78
|
|
79
|
-
if config.get(:api_key).to_s
|
79
|
+
if BLANK.match?(config.get(:api_key).to_s)
|
80
80
|
say("No value provided for required options '--api-key'")
|
81
81
|
exit(1)
|
82
82
|
end
|
@@ -87,19 +87,19 @@ WELCOME
|
|
87
87
|
exit(1)
|
88
88
|
end
|
89
89
|
|
90
|
-
desc
|
90
|
+
desc "notify", "Notify Honeybadger of an error"
|
91
91
|
project_options
|
92
|
-
option :class,
|
93
|
-
option :message,
|
94
|
-
option :action,
|
95
|
-
option :component,
|
96
|
-
option :fingerprint, required: false, type: :string, aliases: :
|
97
|
-
option :tags,
|
98
|
-
option :url,
|
92
|
+
option :class, required: true, type: :string, aliases: :"-c", default: "CLI Notification", desc: "The class name of the error. (Default: CLI Notification)"
|
93
|
+
option :message, required: true, type: :string, aliases: :"-m", desc: "The error message."
|
94
|
+
option :action, required: false, type: :string, aliases: :"-a", desc: "The action."
|
95
|
+
option :component, required: false, type: :string, aliases: :"-C", desc: "The component."
|
96
|
+
option :fingerprint, required: false, type: :string, aliases: :"-f", desc: "The fingerprint."
|
97
|
+
option :tags, required: false, type: :string, aliases: :"-t", desc: "The tags."
|
98
|
+
option :url, required: false, type: :string, aliases: :"-u", desc: "The URL."
|
99
99
|
def notify
|
100
100
|
config = build_config(options)
|
101
101
|
|
102
|
-
if config.get(:api_key).to_s
|
102
|
+
if BLANK.match?(config.get(:api_key).to_s)
|
103
103
|
say("No value provided for required options '--api-key'")
|
104
104
|
exit(1)
|
105
105
|
end
|
@@ -110,9 +110,9 @@ WELCOME
|
|
110
110
|
exit(1)
|
111
111
|
end
|
112
112
|
|
113
|
-
desc
|
113
|
+
desc "exec", "Execute a command. If the exit status is not 0, report the result to Honeybadger"
|
114
114
|
project_options
|
115
|
-
option :quiet, required: false, type: :boolean, aliases: :
|
115
|
+
option :quiet, required: false, type: :boolean, aliases: :"-q", default: false, desc: "Suppress all output unless notification fails."
|
116
116
|
def exec(*args)
|
117
117
|
if args.size == 0
|
118
118
|
say("honeybadger: exec needs a command to run", :red)
|
@@ -121,7 +121,7 @@ WELCOME
|
|
121
121
|
|
122
122
|
config = build_config(options)
|
123
123
|
|
124
|
-
if config.get(:api_key).to_s
|
124
|
+
if BLANK.match?(config.get(:api_key).to_s)
|
125
125
|
say("No value provided for required options '--api-key'", :red)
|
126
126
|
exit(1)
|
127
127
|
end
|
@@ -132,13 +132,13 @@ WELCOME
|
|
132
132
|
exit(1)
|
133
133
|
end
|
134
134
|
|
135
|
-
desc
|
136
|
-
subcommand
|
135
|
+
desc "heroku SUBCOMMAND ...ARGS", "Manage Honeybadger on Heroku"
|
136
|
+
subcommand "heroku", Heroku
|
137
137
|
|
138
138
|
private
|
139
139
|
|
140
140
|
def fetch_value(options, key)
|
141
|
-
options[key] == key ? nil : options[key]
|
141
|
+
(options[key] == key) ? nil : options[key]
|
142
142
|
end
|
143
143
|
|
144
144
|
def build_config(options)
|
@@ -146,15 +146,15 @@ WELCOME
|
|
146
146
|
|
147
147
|
config = Honeybadger.config
|
148
148
|
config.set(:report_data, true)
|
149
|
-
config.set(:api_key, fetch_value(options,
|
150
|
-
config.set(:env, fetch_value(options,
|
149
|
+
config.set(:api_key, fetch_value(options, "api_key")) if options.has_key?("api_key")
|
150
|
+
config.set(:env, fetch_value(options, "environment")) if options.has_key?("environment")
|
151
151
|
|
152
152
|
config
|
153
153
|
end
|
154
154
|
|
155
155
|
def load_env(options)
|
156
156
|
# Initialize Rails when running from Rails root.
|
157
|
-
environment_rb = File.join(Dir.pwd,
|
157
|
+
environment_rb = File.join(Dir.pwd, "config", "environment.rb")
|
158
158
|
if File.exist?(environment_rb)
|
159
159
|
load_rails_env_if_allowed(environment_rb, options)
|
160
160
|
end
|
@@ -164,7 +164,7 @@ WELCOME
|
|
164
164
|
|
165
165
|
def load_rails_env_if_allowed(environment_rb, options)
|
166
166
|
# Skip Rails initialization according to option flag
|
167
|
-
if options.has_key?(
|
167
|
+
if options.has_key?("skip_rails_load") && fetch_value(options, "skip_rails_load")
|
168
168
|
say("Skipping Rails initialization.")
|
169
169
|
else
|
170
170
|
load_rails_env(environment_rb)
|
@@ -173,7 +173,7 @@ WELCOME
|
|
173
173
|
|
174
174
|
def load_rails_env(environment_rb)
|
175
175
|
begin
|
176
|
-
require
|
176
|
+
require "rails"
|
177
177
|
rescue LoadError
|
178
178
|
# No Rails, so skip loading Rails environment.
|
179
179
|
return
|
@@ -184,55 +184,55 @@ WELCOME
|
|
184
184
|
def log_error(e)
|
185
185
|
case e
|
186
186
|
when *Util::HTTP::ERRORS
|
187
|
-
say(
|
188
|
-
!! --- Failed to notify Honeybadger ------------------------------------------- !!
|
189
|
-
|
190
|
-
# What happened?
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
# Error details
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
# What can I do?
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
!! --- End -------------------------------------------------------------------- !!
|
207
|
-
MSG
|
187
|
+
say(<<~MSG, :red)
|
188
|
+
!! --- Failed to notify Honeybadger ------------------------------------------- !!
|
189
|
+
|
190
|
+
# What happened?
|
191
|
+
|
192
|
+
We encountered an HTTP error while contacting our service. Issues like this are
|
193
|
+
usually temporary.
|
194
|
+
|
195
|
+
# Error details
|
196
|
+
|
197
|
+
#{e.class}: #{e.message}\n at #{e.backtrace && e.backtrace.first}
|
198
|
+
|
199
|
+
# What can I do?
|
200
|
+
|
201
|
+
- Retry the command.
|
202
|
+
- Make sure you can connect to api.honeybadger.io (`curl https://api.honeybadger.io/v1/notices`).
|
203
|
+
- If you continue to see this message, email us at support@honeybadger.io
|
204
|
+
(don't forget to attach this output!)
|
205
|
+
|
206
|
+
!! --- End -------------------------------------------------------------------- !!
|
207
|
+
MSG
|
208
208
|
else
|
209
|
-
say(
|
210
|
-
!! --- Honeybadger command failed --------------------------------------------- !!
|
211
|
-
|
212
|
-
# What did you try to do?
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
# What actually happend?
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
# Error details
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
# What can I do?
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
!! --- End -------------------------------------------------------------------- !!
|
235
|
-
MSG
|
209
|
+
say(<<~MSG, :red)
|
210
|
+
!! --- Honeybadger command failed --------------------------------------------- !!
|
211
|
+
|
212
|
+
# What did you try to do?
|
213
|
+
|
214
|
+
You tried to execute the following command:
|
215
|
+
`honeybadger #{ARGV.join(" ")}`
|
216
|
+
|
217
|
+
# What actually happend?
|
218
|
+
|
219
|
+
We encountered a Ruby exception and were forced to cancel your request.
|
220
|
+
|
221
|
+
# Error details
|
222
|
+
|
223
|
+
#{e.class}: #{e.message}
|
224
|
+
#{e.backtrace && e.backtrace.join("\n ")}
|
225
|
+
|
226
|
+
# What can I do?
|
227
|
+
|
228
|
+
- If you're calling the `install` or `test` command in a Rails app, make sure
|
229
|
+
you can boot the Rails console: `bundle exec rails console`.
|
230
|
+
- Retry the command.
|
231
|
+
- If you continue to see this message, email us at support@honeybadger.io
|
232
|
+
(don't forget to attach this output!)
|
233
|
+
|
234
|
+
!! --- End -------------------------------------------------------------------- !!
|
235
|
+
MSG
|
236
236
|
end
|
237
237
|
end
|
238
238
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require "digest"
|
2
|
+
require "forwardable"
|
3
|
+
require "honeybadger/cli/main"
|
4
|
+
require "honeybadger/cli/helpers"
|
5
|
+
require "honeybadger/util/http"
|
6
|
+
require "honeybadger/util/stats"
|
7
7
|
|
8
8
|
module Honeybadger
|
9
9
|
module CLI
|
@@ -23,8 +23,8 @@ module Honeybadger
|
|
23
23
|
api_key: config.get(:api_key),
|
24
24
|
notifier: NOTIFIER,
|
25
25
|
error: {
|
26
|
-
class: options[
|
27
|
-
message: options[
|
26
|
+
class: options["class"],
|
27
|
+
message: options["message"]
|
28
28
|
},
|
29
29
|
request: {},
|
30
30
|
server: {
|
@@ -35,12 +35,12 @@ module Honeybadger
|
|
35
35
|
}
|
36
36
|
}
|
37
37
|
|
38
|
-
payload[:error][:fingerprint] = Digest::SHA1.hexdigest(options[
|
39
|
-
payload[:error][:tags] = options[
|
38
|
+
payload[:error][:fingerprint] = Digest::SHA1.hexdigest(options["fingerprint"]) if option?("fingerprint")
|
39
|
+
payload[:error][:tags] = options["tags"].to_s.strip.split(",").map(&:strip) if option?("tags")
|
40
40
|
|
41
|
-
payload[:request][:component] = options[
|
42
|
-
payload[:request][:action] = options[
|
43
|
-
payload[:request][:url] = options[
|
41
|
+
payload[:request][:component] = options["component"] if option?("component")
|
42
|
+
payload[:request][:action] = options["action"] if option?("action")
|
43
|
+
payload[:request][:url] = options["url"] if option?("url")
|
44
44
|
|
45
45
|
payload.delete(:request) if payload[:request].empty?
|
46
46
|
|