honeybadger 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +10 -0
  3. data/README.md +1 -1
  4. data/lib/honeybadger.rb +0 -7
  5. data/lib/honeybadger/agent.rb +112 -135
  6. data/lib/honeybadger/backend.rb +1 -0
  7. data/lib/honeybadger/backend/base.rb +22 -20
  8. data/lib/honeybadger/backend/debug.rb +3 -3
  9. data/lib/honeybadger/backend/server.rb +7 -12
  10. data/lib/honeybadger/backend/test.rb +7 -10
  11. data/lib/honeybadger/backtrace.rb +9 -8
  12. data/lib/honeybadger/cli.rb +1 -0
  13. data/lib/honeybadger/cli/heroku.rb +3 -3
  14. data/lib/honeybadger/cli/test.rb +1 -1
  15. data/lib/honeybadger/config.rb +6 -19
  16. data/lib/honeybadger/config/defaults.rb +2 -0
  17. data/lib/honeybadger/const.rb +11 -3
  18. data/lib/honeybadger/context_manager.rb +3 -1
  19. data/lib/honeybadger/conversions.rb +4 -3
  20. data/lib/honeybadger/init/rails.rb +2 -0
  21. data/lib/honeybadger/init/rake.rb +2 -1
  22. data/lib/honeybadger/init/ruby.rb +2 -0
  23. data/lib/honeybadger/init/sinatra.rb +3 -0
  24. data/lib/honeybadger/logging.rb +5 -4
  25. data/lib/honeybadger/notice.rb +63 -49
  26. data/lib/honeybadger/plugin.rb +3 -3
  27. data/lib/honeybadger/plugins/rails.rb +6 -6
  28. data/lib/honeybadger/plugins/resque.rb +3 -3
  29. data/lib/honeybadger/plugins/sidekiq.rb +1 -1
  30. data/lib/honeybadger/rack/error_notifier.rb +2 -3
  31. data/lib/honeybadger/rack/user_feedback.rb +8 -2
  32. data/lib/honeybadger/rack/user_informer.rb +2 -2
  33. data/lib/honeybadger/singleton.rb +46 -11
  34. data/lib/honeybadger/util/request_hash.rb +2 -2
  35. data/lib/honeybadger/util/request_payload.rb +4 -4
  36. data/lib/honeybadger/util/revision.rb +2 -2
  37. data/lib/honeybadger/util/sanitizer.rb +2 -2
  38. data/lib/honeybadger/version.rb +2 -2
  39. data/lib/honeybadger/worker.rb +7 -18
  40. metadata +3 -3
@@ -1,6 +1,7 @@
1
1
  require 'forwardable'
2
2
 
3
3
  module Honeybadger
4
+ # @api private
4
5
  class Plugin
5
6
  CALLER_FILE = Regexp.new('\A(?:\w:)?([^:]+)(?=(:\d+))').freeze
6
7
 
@@ -94,9 +95,8 @@ module Honeybadger
94
95
  false
95
96
  end
96
97
 
97
- # Private: Used for testing only; don't normally call this. :)
98
- #
99
- # Returns nothing
98
+ # @private
99
+ # Used for testing only; don't normally call this. :)
100
100
  def reset!
101
101
  @loaded = false
102
102
  end
@@ -4,15 +4,15 @@ module Honeybadger
4
4
  module Plugins
5
5
  module Rails
6
6
  module ExceptionsCatcher
7
- # Internal: Adds additional Honeybadger info to Request env when an
7
+ # Adds additional Honeybadger info to Request env when an
8
8
  # exception is rendered in Rails' middleware.
9
9
  #
10
- # arg - The Rack env Hash in Rails 3.0-4.2. After Rails 5 arg is
11
- # an ActionDispatch::Request.
12
- # exception - The Exception which was rescued.
10
+ # @param [Hash, ActionDispatch::Request] arg The Rack env +Hash+ in
11
+ # Rails 3.0-4.2. After Rails 5 +arg+ is an +ActionDispatch::Request+.
12
+ # @param [Exception] exception The error which was rescued.
13
13
  #
14
- # Returns the super value of the middleware's #render_exception()
15
- # method.
14
+ # @return The super value of the middleware's +#render_exception()+
15
+ # method.
16
16
  def render_exception(arg, exception)
17
17
  if arg.kind_of?(::ActionDispatch::Request)
18
18
  request = arg
@@ -5,7 +5,7 @@ module Honeybadger
5
5
  module Plugins
6
6
  module Resque
7
7
  module Extension
8
- # Executed before `on_failure` hook; the flush is necessary so that
8
+ # Executed before +on_failure+ hook; the flush is necessary so that
9
9
  # errors reported within jobs get sent before the worker dies.
10
10
  def around_perform_with_honeybadger(*args)
11
11
  Honeybadger.flush { yield }
@@ -13,8 +13,8 @@ module Honeybadger
13
13
  Honeybadger.context.clear!
14
14
  end
15
15
 
16
- # Error notifications must be synchronous as the `on_failure` hook is
17
- # executed after `around_perform`.
16
+ # Error notifications must be synchronous as the +on_failure+ hook is
17
+ # executed after +around_perform+.
18
18
  def on_failure_with_honeybadger(e, *args)
19
19
  Honeybadger.notify(e, parameters: { job_arguments: args }, sync: true) if send_exception_to_honeybadger?(e, args)
20
20
  end
@@ -17,7 +17,7 @@ module Honeybadger
17
17
  execution do
18
18
  ::Sidekiq.configure_server do |sidekiq|
19
19
  sidekiq.server_middleware do |chain|
20
- chain.add Middleware
20
+ chain.prepend Middleware
21
21
  end
22
22
  end
23
23
 
@@ -5,11 +5,10 @@ require 'honeybadger/ruby'
5
5
 
6
6
  module Honeybadger
7
7
  module Rack
8
- # Public: Middleware for Rack applications. Any errors raised by the upstream
8
+ # Middleware for Rack applications. Any errors raised by the upstream
9
9
  # application will be delivered to Honeybadger and re-raised.
10
10
  #
11
- # Examples
12
- #
11
+ # @example
13
12
  # require 'honeybadger/rack/error_notifier'
14
13
  #
15
14
  # app = Rack::Builder.app do
@@ -16,8 +16,8 @@ end
16
16
 
17
17
  module Honeybadger
18
18
  module Rack
19
- # Public: Middleware for Rack applications. Adds a feedback form to the
20
- # Rack response when an error has occurred.
19
+ # Middleware for Rack applications. Adds a feedback form to the Rack
20
+ # response when an error has occurred.
21
21
  class UserFeedback
22
22
  extend Forwardable
23
23
 
@@ -41,25 +41,31 @@ module Honeybadger
41
41
  [status, headers, body]
42
42
  end
43
43
 
44
+ # @private
45
+ # @todo Make this method and others actually private.
44
46
  def action
45
47
  URI.parse("#{config.connection_protocol}://#{config[:'connection.host']}:#{config.connection_port}/v1/feedback/").to_s
46
48
  rescue URI::InvalidURIError
47
49
  nil
48
50
  end
49
51
 
52
+ # @private
50
53
  def render_form(error_id, action = action())
51
54
  return unless action
52
55
  ERB.new(@template ||= File.read(template_file)).result(binding)
53
56
  end
54
57
 
58
+ # @private
55
59
  def custom_template_file
56
60
  @custom_template_file ||= File.join(config[:root], 'lib', 'honeybadger', 'templates', 'feedback_form.erb')
57
61
  end
58
62
 
63
+ # @private
59
64
  def custom_template_file?
60
65
  custom_template_file && File.exist?(custom_template_file)
61
66
  end
62
67
 
68
+ # @private
63
69
  def template_file
64
70
  if custom_template_file?
65
71
  custom_template_file
@@ -2,8 +2,8 @@ require 'forwardable'
2
2
 
3
3
  module Honeybadger
4
4
  module Rack
5
- # Public: Middleware for Rack applications. Adds an error ID to the Rack
6
- # response when an error has occurred.
5
+ # Middleware for Rack applications. Adds an error ID to the Rack response
6
+ # when an error has occurred.
7
7
  class UserInformer
8
8
  extend Forwardable
9
9
 
@@ -1,25 +1,59 @@
1
1
  require 'forwardable'
2
2
  require 'honeybadger/agent'
3
3
 
4
- # The Singleton module includes the public API for Honeybadger which can be
5
- # accessed via the global agent (i.e. `Honeybadger.notify`) or via instances of
6
- # the `Honeybadger::Agent` class.
4
+ # Honeybadger's public API is made up of two parts: the {Honeybadger} singleton
5
+ # module, and the {Agent} class. The singleton module delegates its methods to
6
+ # a global agent instance, {Agent#instance}; this allows methods to be accessed
7
+ # directly, for example when calling +Honeybadger.notify+:
8
+ #
9
+ # begin
10
+ # raise 'testing an error report'
11
+ # rescue => err
12
+ # Honeybadger.notify(err)
13
+ # end
14
+ #
15
+ # Custom agents may also be created by users who want to report to multiple
16
+ # Honeybadger projects in the same app (or have fine-grained control over
17
+ # configuration), however most users will use the global agent.
18
+ #
19
+ # @see Honeybadger::Agent
7
20
  module Honeybadger
8
21
  extend Forwardable
9
22
  extend self
10
23
 
11
- def_delegators :'Honeybadger::Agent.instance', :init!, :config, :configure,
12
- :context, :get_context, :flush, :stop, :with_rack_env, :exception_filter,
13
- :exception_fingerprint, :backtrace_filter
24
+ # @!macro [attach] def_delegator
25
+ # @!method $2(...)
26
+ # Forwards to {$1}.
27
+ # @see Agent#$2
28
+ def_delegator :'Honeybadger::Agent.instance', :check_in
29
+ def_delegator :'Honeybadger::Agent.instance', :context
30
+ def_delegator :'Honeybadger::Agent.instance', :configure
31
+ def_delegator :'Honeybadger::Agent.instance', :get_context
32
+ def_delegator :'Honeybadger::Agent.instance', :flush
33
+ def_delegator :'Honeybadger::Agent.instance', :stop
34
+ def_delegator :'Honeybadger::Agent.instance', :exception_filter
35
+ def_delegator :'Honeybadger::Agent.instance', :exception_fingerprint
36
+ def_delegator :'Honeybadger::Agent.instance', :backtrace_filter
14
37
 
38
+ # @!macro [attach] def_delegator
39
+ # @!method $2(...)
40
+ # @api private
41
+ # Forwards to {$1}.
42
+ # @see Agent#$2
43
+ def_delegator :'Honeybadger::Agent.instance', :config
44
+ def_delegator :'Honeybadger::Agent.instance', :init!
45
+ def_delegator :'Honeybadger::Agent.instance', :with_rack_env
46
+
47
+ # @!method notify(...)
48
+ # Forwards to {Agent.instance}.
49
+ # @see Agent#notify
15
50
  def notify(exception_or_opts, opts = {})
51
+ # Note this is defined directly (instead of via forwardable) so that
52
+ # generated stack traces work as expected.
16
53
  Agent.instance.notify(exception_or_opts, opts)
17
54
  end
18
55
 
19
- def check_in(id)
20
- Agent.instance.check_in(id)
21
- end
22
-
56
+ # @api private
23
57
  def load_plugins!
24
58
  Dir[File.expand_path('../plugins/*.rb', __FILE__)].each do |plugin|
25
59
  require plugin
@@ -27,6 +61,7 @@ module Honeybadger
27
61
  Plugin.load!(self.config)
28
62
  end
29
63
 
64
+ # @api private
30
65
  def install_at_exit_callback
31
66
  at_exit do
32
67
  if $! && !$!.is_a?(SystemExit) && Honeybadger.config[:'exceptions.notify_at_exit']
@@ -37,7 +72,7 @@ module Honeybadger
37
72
  end
38
73
  end
39
74
 
40
- # Deprecated
75
+ # @deprecated
41
76
  def start(config = {})
42
77
  raise NoMethodError, <<-WARNING
43
78
  `Honeybadger.start` is no longer necessary and has been removed.
@@ -2,8 +2,8 @@ require 'set'
2
2
 
3
3
  module Honeybadger
4
4
  module Util
5
- # Internal: Constructs a request hash from a Rack::Request matching the
6
- # /v1/notices API specification.
5
+ # Constructs a request hash from a Rack::Request matching the /v1/notices
6
+ # API specification.
7
7
  module RequestHash
8
8
  HTTP_HEADER_PREFIX = 'HTTP_'.freeze
9
9
 
@@ -2,9 +2,9 @@ require 'honeybadger/util/sanitizer'
2
2
 
3
3
  module Honeybadger
4
4
  module Util
5
- # Internal: Constructs/sanitizes request data for notices
5
+ # Constructs/sanitizes request data for notices
6
6
  module RequestPayload
7
- # Internal: Default values to use for request data.
7
+ # Default values to use for request data.
8
8
  DEFAULTS = {
9
9
  url: nil,
10
10
  component: nil,
@@ -14,10 +14,10 @@ module Honeybadger
14
14
  cgi_data: {}.freeze
15
15
  }.freeze
16
16
 
17
- # Internal: Allowed keys.
17
+ # Allowed keys.
18
18
  KEYS = DEFAULTS.keys.freeze
19
19
 
20
- # Internal: The cgi_data key where the raw Cookie header is stored.
20
+ # The cgi_data key where the raw Cookie header is stored.
21
21
  HTTP_COOKIE_KEY = 'HTTP_COOKIE'.freeze
22
22
 
23
23
  def self.build(opts = {})
@@ -10,8 +10,8 @@ module Honeybadger
10
10
 
11
11
  private
12
12
 
13
- # Requires (currently) alpha platform feature
14
- # `heroku labs:enable runtime-dyno-metadata`
13
+ # Requires (currently) alpha platform feature `heroku labs:enable
14
+ # runtime-dyno-metadata`
15
15
  #
16
16
  # See https://devcenter.heroku.com/articles/dyno-metadata
17
17
  def from_heroku
@@ -5,8 +5,8 @@ require 'honeybadger/conversions'
5
5
 
6
6
  module Honeybadger
7
7
  module Util
8
- # Internal: Sanitizer sanitizes data for sending to Honeybadger's API. The
9
- # filters are based on Rails' HTTP parameter filter.
8
+ # Sanitizer sanitizes data for sending to Honeybadger's API. The filters
9
+ # are based on Rails' HTTP parameter filter.
10
10
  class Sanitizer
11
11
  COOKIE_PAIRS = /[;,]\s?/
12
12
  COOKIE_SEP = '='.freeze
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
- # Public: The current String Honeybadger version.
3
- VERSION = '3.2.0'.freeze
2
+ # The current String Honeybadger version.
3
+ VERSION = '3.3.0'.freeze
4
4
  end
@@ -4,16 +4,17 @@ require 'net/http'
4
4
  require 'honeybadger/logging'
5
5
 
6
6
  module Honeybadger
7
- # Internal: A concurrent queue to notify the backend.
7
+ # A concurrent queue to notify the backend.
8
+ # @api private
8
9
  class Worker
9
10
  extend Forwardable
10
11
 
11
12
  include Honeybadger::Logging::Helper
12
13
 
13
- # Internal: Sub-class thread so we have a named thread (useful for debugging in Thread.list).
14
+ # Sub-class thread so we have a named thread (useful for debugging in Thread.list).
14
15
  class Thread < ::Thread; end
15
16
 
16
- # Internal: A queue which enforces a maximum size.
17
+ # A queue which enforces a maximum size.
17
18
  class Queue < ::Queue
18
19
  attr_reader :max_size
19
20
 
@@ -48,9 +49,6 @@ module Honeybadger
48
49
  handle_response(msg, notify_backend(msg))
49
50
  end
50
51
 
51
- # Internal: Shutdown the worker after sending remaining data.
52
- #
53
- # Returns true.
54
52
  def shutdown
55
53
  d { 'shutting down worker' }
56
54
 
@@ -91,9 +89,7 @@ module Honeybadger
91
89
  true
92
90
  end
93
91
 
94
- # Internal: Blocks until queue is processed up to this point in time.
95
- #
96
- # Returns nothing.
92
+ # Blocks until queue is processed up to this point in time.
97
93
  def flush
98
94
  mutex.synchronize do
99
95
  if thread && thread.alive?
@@ -226,19 +222,12 @@ module Honeybadger
226
222
  end
227
223
  end
228
224
 
229
- # Internal: Release the marker. Important to perform during cleanup when
230
- # shutting down, otherwise it could end up waiting indefinitely.
231
- #
232
- # Returns nothing.
225
+ # Release the marker. Important to perform during cleanup when shutting
226
+ # down, otherwise it could end up waiting indefinitely.
233
227
  def release_marker
234
228
  signal_marker(marker)
235
229
  end
236
230
 
237
- # Internal: Signal a marker.
238
- #
239
- # marker - The ConditionVariable marker to signal.
240
- #
241
- # Returns nothing.
242
231
  def signal_marker(marker)
243
232
  mutex.synchronize do
244
233
  marker.signal
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-28 00:00:00.000000000 Z
11
+ date: 2018-01-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email:
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  requirements: []
145
145
  rubyforge_project:
146
- rubygems_version: 2.6.13
146
+ rubygems_version: 2.7.3
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Error reports you can be happy about.