honeybadger 3.1.2 → 3.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,137 +1,3 @@
1
1
  # Troubleshooting
2
2
 
3
- Common issues/workarounds are documented here. If you don't find a solution to
4
- your problem here or in our [support
5
- documentation](http://docs.honeybadger.io/), email support@honeybadger.io and
6
- one or all of our helpful founders will assist you!
7
-
8
- ## Upgrade the gem
9
-
10
- Before digging deeper into this guide, **make sure you are on the latest minor
11
- release of the honeybadger gem** (i.e. 3.x.x). There's a chance you've found a bug
12
- which has already been fixed!
13
-
14
- ## Send a Test Exception
15
-
16
- You can send a test exception using the `honeybadger` command line utility:
17
-
18
- ```bash
19
- $ honeybadger test
20
- ```
21
-
22
- ## How to enable verbose logging
23
-
24
- Troubleshooting any of these issues will be much easier if you can see what's
25
- going on with Honeybadger when your app starts. To enable verbose debug logging,
26
- run your app with the `HONEYBADGER_DEBUG=true` environment variable or add the
27
- following to your *honeybadger.yml* file:
28
-
29
- ```yml
30
- debug: true
31
- ```
32
-
33
- By default Honeybadger will log to the default Rails logger or STDOUT outside of
34
- Rails. When debugging it can be helpful to have a dedicated log file for
35
- Honeybadger. To enable one, set the
36
- `HONEYBADGER_LOGGING_PATH=log/honeybadger.log` environment variable or add the
37
- following to your *honeybadger.yml* file:
38
-
39
- ```yml
40
- logging:
41
- path: 'log/honeybadger.log'
42
- ```
43
-
44
- ## Common Issues
45
-
46
- ### My errors aren't being reported
47
-
48
- Error reporting may be disabled for several reasons:
49
-
50
- #### Honeybadger is not configured
51
-
52
- Honeybadger requires at minimum the `api_key` option to be set. If Honeybadger
53
- is unable to start due to invalid configuration, you should see something like
54
- the following in your logs:
55
-
56
- ```
57
- ** [Honeybadger] Unable to start Honeybadger -- api_key is missing or invalid. level=2 pid=18195
58
- ```
59
-
60
- #### Honeybadger is in a development environment
61
-
62
- Errors are ignored by default in the "test", "development", and "cucumber"
63
- environments. To explicitly enable Honeybadger in a development environment, set
64
- the `HONEYBADGER_REPORT_DATA=true` environment variable or add the following
65
- configuration to *honeybadger.yml* file (change "development" to the name of the
66
- environment you want to enable):
67
-
68
- ```yml
69
- development:
70
- report_data: true
71
- ```
72
-
73
- ##### The `better_errors` gem is installed
74
-
75
- The [`better_errors` gem](https://github.com/charliesome/better_errors) conflicts with the Honeybadger gem when in development mode. To be able to report errors from development you must first temporarily disable/remove the `better_errors` gem. Better Errors should not affect production because it should never be enabled in production.
76
-
77
- #### Is the error ignored by default?
78
-
79
- Honeybadger ignores [this list of
80
- exceptions](https://github.com/honeybadger-io/honeybadger-ruby/blob/master/lib/honeybadger/config/defaults.rb#L7)
81
- by default.
82
-
83
- #### Is the error rescued without re-raising?
84
-
85
- Honeybadger will automatically report exceptions in many frameworks including
86
- Rails, Sinatra, Sidekiq, Rake, etc. For exceptions to reported automatically
87
- they must be raised; check for any `rescue` statements in your app where
88
- exceptions may be potentially silenced. In Rails, this includes any use of
89
- `rescue_from` which does not re-raise the exception.
90
-
91
- Errors which are handled in a `rescue` block without re-raising must be reported
92
- to Honeybadger manually:
93
-
94
- ```ruby
95
- begin
96
- fail 'This error will be handled internally.'
97
- rescue => e
98
- Honeybadger.notify(e)
99
- end
100
- ```
101
-
102
- ### I'm not receiving notifications
103
-
104
- #### Was the error reported already and is unresolved?
105
-
106
- By default we only send notifications the first time an exception happens, and
107
- when it re-occurs after being marked resolved. If an exception happens 100
108
- times, but was never resolved you'll only get 1 email about it.
109
-
110
- ## Sidekiq/Resque/ActiveJob/etc.
111
-
112
- - See [Common Issues](#common-issues)
113
-
114
- ### If the error is ignored by default
115
-
116
- Honeybadger ignores [this list of
117
- exceptions](https://github.com/honeybadger-io/honeybadger-ruby/blob/master/lib/honeybadger/config/defaults.rb#L7)
118
- by default. It may be surprising that `ActiveRecord::RecordNotFound` is on that
119
- list; that's because in a Rails controller that error class is treated as a 404
120
- not-found and handled internally (and thus we shouldn't report it). Support for
121
- Sidekiq and friends was added later and inherited the default. We would like to
122
- provide alternate defaults for job processors in the future, but for now you can
123
- provide your own list of ignored class names if you want to change this
124
- behavior:
125
-
126
- ```
127
- HONEYBADGER_EXCEPTIONS_IGNORE_ONLY=Error,ClassNames,Here bundle exec sidekiq
128
- ```
129
-
130
- ## Command line utility
131
-
132
- If you get an error while running the `honeybadger` command line utility:
133
-
134
- 0. Try prefixing the command with `bundle exec`...even if you normally rely on bin-stubs to do this for you
135
- 1. Check `honeybadger help` if you're having trouble with the syntax for a specific command.
136
- 2. Try enabling [verbose logging](#how-to-enable-verbose-logging) to get more info
137
- 3. Ask Us! We're always here to help. Just copy the terminal output and email it to us at support@honeybadger.io
3
+ Troubleshooting instructions have been moved to our [documentation site](http://docs.honeybadger.io/ruby/support/troubleshooting.html)!
@@ -19,7 +19,7 @@ module Honeybadger
19
19
  # This also includes the Rack environment when using the Honeybadger rack
20
20
  # middleware.
21
21
  #
22
- # Examples:
22
+ # Examples
23
23
  #
24
24
  # # Standard usage:
25
25
  # OtherBadger = Honeybadger::Agent.new
@@ -70,13 +70,22 @@ module Honeybadger
70
70
  # to build the notice. All other types of objects will
71
71
  # be converted to a String and used as the `:error_message`.
72
72
  # opts - The options Hash when the first argument is an
73
- # Exception. (default: {}):
73
+ # Exception (default: {}):
74
74
  # :error_message - The String error message.
75
- # :error_class - The String class name of the error. (optional)
76
- # :force - Always report the exception, even when
77
- # ignored. (optional)
78
- #
79
- # Examples:
75
+ # :error_class - The String class name of the error (default: "Notice").
76
+ # :backtrace - The Array backtrace of the error (optional).
77
+ # :fingerprint - The String grouping fingerprint of the exception (optional).
78
+ # :force - Always report the exception when true, even when ignored (default: false).
79
+ # :tags - The String comma-separated list of tags (optional).
80
+ # :context - The Hash context to associate with the exception (optional).
81
+ # :controller - The String controller name (such as a Rails controller) (optional).
82
+ # :action - The String action name (such as a Rails controller action) (optional).
83
+ # :parameters - The Hash HTTP request paramaters (optional).
84
+ # :session - The Hash HTTP request session (optional).
85
+ # :url - The String HTTP request URL (optional).
86
+ # :cause - The Exception cause for this error (optional).
87
+ #
88
+ # Examples
80
89
  #
81
90
  # # With an exception:
82
91
  # begin
@@ -88,9 +97,8 @@ module Honeybadger
88
97
  # end
89
98
  #
90
99
  # # Custom notification:
91
- # Honeybadger.notify({
100
+ # Honeybadger.notify('Something went wrong.', {
92
101
  # error_class: 'MyClass',
93
- # error_message: 'Something went wrong.',
94
102
  # context: {my_data: 'value'}
95
103
  # }) # => '06220c5a-b471-41e5-baeb-de247da45a56'
96
104
  #
@@ -137,10 +145,18 @@ module Honeybadger
137
145
 
138
146
  # Public: Save global context for the current request.
139
147
  #
140
- # hash - A Hash of data which will be sent to Honeybadger when an error
141
- # occurs. (default: nil)
148
+ # context - A Hash of data which will be sent to Honeybadger when an error
149
+ # occurs. If the object responds to #to_honeybadger_context, the return
150
+ # value of that method will be used (explicit conversion). Can
151
+ # include any key/value, but a few keys have a special meaning in
152
+ # Honeybadger (default: nil):
153
+ # :user_id - The String user ID used by Honeybadger to aggregate
154
+ # user data across occurrences on the error page (optional).
155
+ # :user_email - The String user email address (optional).
156
+ # :tags - The String comma-separated list of tags. When present,
157
+ # tags will be applied to errors with this context (optional).
142
158
  #
143
- # Examples:
159
+ # Examples
144
160
  #
145
161
  # Honeybadger.context({my_data: 'my value'})
146
162
  #
@@ -149,12 +165,22 @@ module Honeybadger
149
165
  # Honeybadger.context({user_id: current_user.id})
150
166
  # end
151
167
  #
168
+ # # Explicit conversion
169
+ # class User < ActiveRecord::Base
170
+ # def to_honeybadger_context
171
+ # { user_id: id, user_email: email }
172
+ # end
173
+ # end
174
+ #
175
+ # user = User.first
176
+ # Honeybadger.context(user)
177
+ #
152
178
  # # Clearing global context:
153
179
  # Honeybadger.context.clear!
154
180
  #
155
181
  # Returns self so that method calls can be chained.
156
- def context(hash = nil)
157
- context_manager.set_context(hash) unless hash.nil?
182
+ def context(context = nil)
183
+ context_manager.set_context(context) unless context.nil?
158
184
  self
159
185
  end
160
186
 
@@ -166,7 +192,7 @@ module Honeybadger
166
192
  # Public: Get global context for the current request.
167
193
  #
168
194
  #
169
- # Examples:
195
+ # Examples
170
196
  #
171
197
  # Honeybadger.context({my_data: 'my value'})
172
198
  # Honeybadger.get_context #now returns {my_data: 'my value'}
@@ -183,7 +209,7 @@ module Honeybadger
183
209
  # block - The optional block to execute (exceptions will propagate after data
184
210
  # is flushed).
185
211
  #
186
- # Examples:
212
+ # Examples
187
213
  #
188
214
  # # Without a block:
189
215
  # it "sends a notification to Honeybadger" do
@@ -215,7 +241,7 @@ module Honeybadger
215
241
 
216
242
  # Public: Stops the Honeybadger service.
217
243
  #
218
- # Examples:
244
+ # Examples
219
245
  #
220
246
  # Honeybadger.stop # => nil
221
247
  #
@@ -231,7 +257,7 @@ module Honeybadger
231
257
  #
232
258
  # block - The configuration block.
233
259
  #
234
- # Examples:
260
+ # Examples
235
261
  #
236
262
  # Honeybadger.configure do |config|
237
263
  # config.api_key = 'project api key'
@@ -249,7 +275,7 @@ module Honeybadger
249
275
  # block - A block returning TrueClass true (to ignore) or FalseClass false
250
276
  # (to send).
251
277
  #
252
- # Examples:
278
+ # Examples
253
279
  #
254
280
  # # Ignoring based on error message:
255
281
  # Honeybadger.exception_filter do |notice|
@@ -272,7 +298,7 @@ module Honeybadger
272
298
  #
273
299
  # block - A block returning any Object responding to #to_s.
274
300
  #
275
- # Examples:
301
+ # Examples
276
302
  #
277
303
  # Honeybadger.exception_fingerprint do |notice|
278
304
  # [notice[:error_class], notice[:component], notice[:backtrace].to_s].join(':')
@@ -289,7 +315,7 @@ module Honeybadger
289
315
  # Honeybadger. The block expects one argument (line) which is the String line
290
316
  # from the Backtrace, and must return the String new line.
291
317
  #
292
- # Examples:
318
+ # Examples
293
319
  #
294
320
  # Honeybadger.backtrace_filter do |line|
295
321
  # line.gsub(/^\/my\/unknown\/bundle\/path/, "[GEM_ROOT]")
@@ -305,7 +331,7 @@ module Honeybadger
305
331
  # block - A block to call. Errors reported from within the block will
306
332
  # include request data.
307
333
  #
308
- # Examples:
334
+ # Examples
309
335
  #
310
336
  # Honeybadger.with_rack_env(env) do
311
337
  # begin
@@ -21,7 +21,7 @@ module Honeybadger
21
21
  # Public: Initializes the Response instance.
22
22
  #
23
23
  # response - With 1 argument Net::HTTPResponse, the code, body, and
24
- # message will be determined automatically. (optional)
24
+ # message will be determined automatically (optional).
25
25
  # code - The Integer status code. May also be :error for requests which
26
26
  # failed to reach the server.
27
27
  # body - The String body of the response.
@@ -76,10 +76,10 @@ module Honeybadger
76
76
  # Internal: Process payload for feature.
77
77
  #
78
78
  # feature - A Symbol feature name (corresponds to HTTP endpoint). Current
79
- # options are: :notices, :deploys, :ping
80
- # payload - Any Object responding to #to_json.
79
+ # options are: `:notices`, `:deploys`, `:ping`.
80
+ # payload - Any Object responding to `#to_json`.
81
81
  #
82
- # Examples:
82
+ # Examples
83
83
  #
84
84
  # backend.notify(:notices, Notice.new(...))
85
85
  #
@@ -3,12 +3,22 @@ require 'honeybadger/backend/base'
3
3
  module Honeybadger
4
4
  module Backend
5
5
  class Null < Base
6
+ class StubbedResponse < Response
7
+ def initialize
8
+ super(:stubbed, '{}'.freeze)
9
+ end
10
+
11
+ def success?
12
+ true
13
+ end
14
+ end
15
+
6
16
  def initialize(*args)
7
17
  super
8
18
  end
9
19
 
10
20
  def notify(feature, payload)
11
- Response.new(201, '{}')
21
+ StubbedResponse.new
12
22
  end
13
23
  end
14
24
  end
@@ -5,7 +5,7 @@ module Honeybadger
5
5
  class Test < Null
6
6
  # Public: The notification list.
7
7
  #
8
- # Examples:
8
+ # Examples
9
9
  #
10
10
  # Test.notifications[:notices] # => [Notice, Notice, ...]
11
11
  #
@@ -92,7 +92,7 @@ module Honeybadger
92
92
  #
93
93
  # Returns an array of line(s) from source file.
94
94
  def get_source(file, number, radius = 2)
95
- if file && File.exists?(file)
95
+ if file && File.exist?(file)
96
96
  before = after = radius
97
97
  start = (number.to_i - 1) - before
98
98
  start = 0 and before = 1 if start <= 0
@@ -151,7 +151,7 @@ WELCOME
151
151
  def load_env
152
152
  # Initialize Rails when running from Rails root.
153
153
  environment_rb = File.join(Dir.pwd, 'config', 'environment.rb')
154
- load_rails_env(environment_rb) if File.exists?(environment_rb)
154
+ load_rails_env(environment_rb) if File.exist?(environment_rb)
155
155
 
156
156
  # Ensure config is loaded (will be skipped if initialized by Rails).
157
157
  Honeybadger.config.load!
@@ -94,9 +94,9 @@ module Honeybadger
94
94
  # logging the framework trace (moved to ActionDispatch::DebugExceptions),
95
95
  # which caused cluttered output while running the test task.
96
96
  defined?(::ActionDispatch::DebugExceptions) and
97
- ::ActionDispatch::DebugExceptions.class_eval { def logger(*args) ; @logger ||= Logger.new('/dev/null') ; end }
97
+ ::ActionDispatch::DebugExceptions.class_eval { def logger(*args) ; @logger ||= Logger.new(nil) ; end }
98
98
  defined?(::ActionDispatch::ShowExceptions) and
99
- ::ActionDispatch::ShowExceptions.class_eval { def logger(*args) ; @logger ||= Logger.new('/dev/null') ; end }
99
+ ::ActionDispatch::ShowExceptions.class_eval { def logger(*args) ; @logger ||= Logger.new(nil) ; end }
100
100
 
101
101
  # Detect and disable the better_errors gem
102
102
  if defined?(::BetterErrors::Middleware)
@@ -162,7 +162,7 @@ module Honeybadger
162
162
  if calling = TestBackend.callings[:notices].find {|c| c[0].exception.eql?(TEST_EXCEPTION) }
163
163
  notice, response = *calling
164
164
 
165
- if response.code != 201
165
+ if !response.success?
166
166
  host = Honeybadger.config.get(:'connection.host')
167
167
  say(<<-MSG, :red)
168
168
  !! --- Honeybadger test failed ------------------------------------------------ !!
@@ -212,7 +212,7 @@ MSG
212
212
  notices.each {|n| say("\n - #{n.error_class}: #{n.error_message}", :red) }
213
213
  end
214
214
 
215
- say("\nSee https://git.io/vXCYp for more troubleshooting help.\n\n", :red)
215
+ say("\nSee https://docs.honeybadger.io/gem-troubleshooting for more troubleshooting help.\n\n", :red)
216
216
  say("!! --- End -------------------------------------------------------------------- !!", :red)
217
217
 
218
218
  exit(1)
@@ -237,16 +237,16 @@ Honeybadger. For now, we've generated a test exception for you:
237
237
  Optional steps:
238
238
 
239
239
  - Show a feedback form on your error page:
240
- http://docs.honeybadger.io/gem-feedback
240
+ https://docs.honeybadger.io/gem-feedback
241
241
  - Show a UUID or link to Honeybadger on your error page:
242
- http://docs.honeybadger.io/gem-informer
242
+ https://docs.honeybadger.io/gem-informer
243
243
  - Track deployments (if you're using Capistrano, we already did this):
244
- http://docs.honeybadger.io/gem-deploys
244
+ https://docs.honeybadger.io/gem-deploys
245
245
 
246
246
  If you ever need help:
247
247
 
248
- - Read the gem troubleshooting guide: https://git.io/vXCYp
249
- - Check out our documentation: http://docs.honeybadger.io/
248
+ - Read the gem troubleshooting guide: https://docs.honeybadger.io/gem-troubleshooting
249
+ - Check out our documentation: https://docs.honeybadger.io/
250
250
  - Email the founders: support@honeybadger.io
251
251
 
252
252
  Most people don't realize that Honeybadger is a small, bootstrapped company. We
@@ -56,7 +56,7 @@ module Honeybadger
56
56
  init_backend!
57
57
 
58
58
  logger.info(sprintf('Initializing Honeybadger Error Tracker for Ruby. Ship it! version=%s framework=%s', Honeybadger::VERSION, detected_framework))
59
- logger.warn('Entering development mode: data will not be reported.') if dev? && backend.kind_of?(Backend::Null)
59
+ logger.warn('Development mode is enabled. Data will not be reported until you deploy your app.') if warn_development?
60
60
 
61
61
  self
62
62
  end
@@ -148,6 +148,10 @@ module Honeybadger
148
148
  self[:env] && Array(self[:development_environments]).include?(self[:env])
149
149
  end
150
150
 
151
+ def warn_development?
152
+ dev? && backend.kind_of?(Backend::Null)
153
+ end
154
+
151
155
  def public?
152
156
  return true if self[:report_data]
153
157
  return false if self[:report_data] == false
@@ -359,7 +363,7 @@ module Honeybadger
359
363
 
360
364
  return framework[:logger] if framework[:logger]
361
365
 
362
- Logger.new('/dev/null')
366
+ Logger.new(nil)
363
367
  end
364
368
 
365
369
  def init_logging!