honeybadger 3.2.0.beta1 → 3.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c3dbe99d414f6c89625a0cad87334f0bc7a7176
4
- data.tar.gz: 40431378fce7369c2e749fd389ab925609d38c18
3
+ metadata.gz: 315f88413aa73eea6868999adbad9707b1a6fb30
4
+ data.tar.gz: '0583a2c4a6e6feaf9e9b02d1c9f7d044864b4c03'
5
5
  SHA512:
6
- metadata.gz: e96e67c779f33c75ad30b2c0cd53081452b355bf499087cee3bf7cf2a2fc8d84e49b1dde0952a477e337476795247c6805578b80704fd7434959c7c67ddc5634
7
- data.tar.gz: 7e9689d593714186c2382fa31265f646cd3ef6e4857651ac215648f7ef75a74312417997d899869cd2fdba6020a8cac4fcbd20439e5471e7619be9333828a910
6
+ metadata.gz: 83eb0c64f6821c92edcc90829b7b7b9e7f43c857937236235cb97b12a54e90ba99619a0e255c3158bf5b67cf6740714d66e33232eb1753d0fc428c72f591bc82
7
+ data.tar.gz: 060b06e30f83babcd3ece659c3e9010aa34696911540a3366dff53d181742c2ee8ba62ad5fb33340a1ff9b447404627f7cde6484878e20fd7913de163fac2c03
data/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ CHANGELOG](http://keepachangelog.com/) for how to update this file. This project
4
4
  adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
+
8
+ ## [3.2.0] - 2017-11-27
9
+ ### Changed
10
+ - Objects which explicitly alias `#to_s` to `#inspect` (such as `OpenStruct`) are
11
+ now sanitized. `'#<OpenStruct attribute="value">'` becomes `'#<OpenStruct>'`.
12
+ If you pass the value of `#inspect` (as a `String`) directly to Honeybadger (or
13
+ return it from `#to_honeybadger`), the value will not be sanitized.
14
+ - We're now using `String(object)` instead of `object.to_s` as the last resort
15
+ during sanitization.
16
+
7
17
  ### Added
8
18
  - The exception cause may now be set using an optional `:cause` option when
9
19
  calling `Honeybadger.notify`. If not present, the exception's cause will be
@@ -16,15 +26,8 @@ adheres to [Semantic Versioning](http://semver.org/).
16
26
  for unknown types) can be changed by defining the `#to_honeybadger` method. If
17
27
  the method is defined, the return value of that method will be sent to Honeybadger
18
28
  instead of the `#to_s` value (for context values, local variables, etc.).
19
- - `BasicObject`, which previously could not be serialized, is now serialized as
20
- `"#<BasicObject>"`.
21
- - Objects which explicitly alias `#to_s` to `#inspect` (such as `OpenStruct`) are
22
- now sanitized. `'#<OpenStruct attribute="value">'` becomes `'#<OpenStruct>'`.
23
- If you pass the value of `#inspect` (as a `String`) directly to Honeybadger (or
24
- return it from `#to_honeybadger`), the value will not be sanitized.
25
- - We're now using `String(object)` instead of `object.to_s` as the last resort
26
- during sanitization.
27
29
  - `'[RAISED]'` is returned when `object.to_honeybadger` or `String(object)` fails.
30
+ - Added `Honeybadger.check_in` method which allows performing check ins from ruby.
28
31
 
29
32
  ### Fixed
30
33
  - We no longer use "/dev/null" as the default log device as it doesn't exist on
@@ -32,6 +35,10 @@ adheres to [Semantic Versioning](http://semver.org/).
32
35
  - Logs when reporting errors in development mode now mention that the error wasn't
33
36
  *actually* reported. :)
34
37
  - Support new Sidekiq job params key.
38
+ - Move at_exit callback to an appropriate place for sinatra apps, so that it does
39
+ not prematurely stop honeybadger workers.
40
+ - `BasicObject`, which previously could not be serialized, is now serialized as
41
+ `"#<BasicObject>"`.
35
42
 
36
43
  ## [3.1.2] - 2017-04-20
37
44
  ### Fixed
data/lib/honeybadger.rb CHANGED
@@ -10,9 +10,9 @@ if defined?(Rake.application)
10
10
  require 'honeybadger/init/rake'
11
11
  end
12
12
 
13
- at_exit do
14
- if $! && !$!.is_a?(SystemExit) && Honeybadger.config[:'exceptions.notify_at_exit']
15
- Honeybadger.notify($!, component: 'at_exit', sync: true)
16
- end
17
- Honeybadger.stop if Honeybadger.config[:'send_data_at_exit']
13
+ # Sinatra is a special case. Sinatra starts the web application in an at_exit
14
+ # handler. And, since we require sinatra before requiring HB, the only way to
15
+ # setup our at_exit callback is in the sinatra build callback honeybadger/init/sinatra.rb
16
+ if !defined?(Sinatra::Base)
17
+ Honeybadger.install_at_exit_callback
18
18
  end
@@ -143,6 +143,23 @@ module Honeybadger
143
143
  notice.id
144
144
  end
145
145
 
146
+ # Public: Perform a synchronous check_in.
147
+ #
148
+ # id - The unique check in id (e.g. '1MqIo1') or the check in url.
149
+ #
150
+ # Examples
151
+ #
152
+ # Honeybadger.check_in('1MqIo1')
153
+ #
154
+ # Returns a boolean which is true if the check in was successful and false
155
+ # otherwise.
156
+ def check_in(id)
157
+ # this is to allow check ins even if a url is passed
158
+ check_in_id = id.to_s.strip.gsub(/\/$/, '').split('/').last
159
+ response = backend.check_in(check_in_id)
160
+ response.success?
161
+ end
162
+
146
163
  # Public: Save global context for the current request.
147
164
  #
148
165
  # context - A Hash of data which will be sent to Honeybadger when an error
@@ -355,6 +372,9 @@ module Honeybadger
355
372
  # Internal
356
373
  def_delegators :config, :init!
357
374
 
375
+ # Internal
376
+ def_delegators :config, :backend
377
+
358
378
  private
359
379
 
360
380
  def validate_notify_opts!(opts)
@@ -88,6 +88,15 @@ module Honeybadger
88
88
  raise NotImplementedError, 'must define #notify on subclass.'
89
89
  end
90
90
 
91
+ # Internal: Does a check in using the input id.
92
+ #
93
+ # id - The unique check_in id.
94
+ #
95
+ # Raises NotImplementedError.
96
+ def check_in(id)
97
+ raise NotImplementedError, 'must define #check_in on subclass.'
98
+ end
99
+
91
100
  private
92
101
 
93
102
  attr_reader :config
@@ -11,6 +11,12 @@ module Honeybadger
11
11
  return Response.new(ENV['DEBUG_BACKEND_STATUS'].to_i, nil) if ENV['DEBUG_BACKEND_STATUS']
12
12
  super
13
13
  end
14
+
15
+ def check_in(id)
16
+ logger.unknown("checking in debug backend with id=#{id}")
17
+ return Response.new(ENV['DEBUG_BACKEND_STATUS'].to_i, nil) if ENV['DEBUG_BACKEND_STATUS']
18
+ super
19
+ end
14
20
  end
15
21
  end
16
22
  end
@@ -20,6 +20,10 @@ module Honeybadger
20
20
  def notify(feature, payload)
21
21
  StubbedResponse.new
22
22
  end
23
+
24
+ def check_in(id)
25
+ StubbedResponse.new
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -14,6 +14,9 @@ module Honeybadger
14
14
  deploys: '/v1/deploys'.freeze
15
15
  }.freeze
16
16
 
17
+ CHECK_IN_ENDPOINT = '/v1/check_in'.freeze
18
+
19
+
17
20
  HTTP_ERRORS = Util::HTTP::ERRORS
18
21
 
19
22
  def initialize(config)
@@ -34,6 +37,17 @@ module Honeybadger
34
37
  Response.new(:error, nil, "HTTP Error: #{e.class}")
35
38
  end
36
39
 
40
+ # Internal: Does a check in using the input id.
41
+ #
42
+ # id - The unique check_in id.
43
+ #
44
+ # Returns Response.
45
+ def check_in(id)
46
+ Response.new(@http.get("#{CHECK_IN_ENDPOINT}/#{id}"))
47
+ rescue *HTTP_ERRORS => e
48
+ Response.new(:error, nil, "HTTP Error: #{e.class}")
49
+ end
50
+
37
51
  private
38
52
 
39
53
  # Internal: Construct headers for supported payloads.
@@ -14,15 +14,35 @@ module Honeybadger
14
14
  @notifications ||= Hash.new {|h,k| h[k] = [] }
15
15
  end
16
16
 
17
+ # Public: The check in list.
18
+ #
19
+ # Examples
20
+ #
21
+ # Test.check_ins # => ["foobar", "danny", ...]
22
+ #
23
+ # Returns the Array of check ins.
24
+ def self.check_ins
25
+ @check_ins ||= []
26
+ end
27
+
17
28
  # Internal: Local helper.
18
29
  def notifications
19
30
  self.class.notifications
20
31
  end
21
32
 
33
+ # Internal: Local helper.
34
+ def check_ins
35
+ self.class.check_ins
36
+ end
37
+
22
38
  def notify(feature, payload)
23
39
  notifications[feature] << payload
24
40
  super
25
41
  end
42
+
43
+ def check_in(id)
44
+ check_ins << id
45
+ end
26
46
  end
27
47
  end
28
48
  end
@@ -9,6 +9,7 @@ module Honeybadger
9
9
  def build_with_honeybadger(*args, &block)
10
10
  configure_honeybadger
11
11
  install_honeybadger
12
+ Honeybadger.install_at_exit_callback
12
13
  build_without_honeybadger(*args, &block)
13
14
  end
14
15
  alias :build_without_honeybadger :build
@@ -31,6 +32,7 @@ module Honeybadger
31
32
  return if middleware.any? {|m| m[0] == klass }
32
33
  use(klass)
33
34
  end
35
+
34
36
  end
35
37
  end
36
38
  end
@@ -324,15 +324,22 @@ module Honeybadger
324
324
  Util::RequestPayload.build(request)
325
325
  end
326
326
 
327
+ # Internal: Get optional context from exception.
328
+ #
329
+ # Returns the Hash context.
327
330
  def exception_context(exception)
328
- return {}.freeze unless exception.respond_to?(:to_honeybadger_context)
329
- exception.to_honeybadger_context
331
+ # This extra check exists because the exception itself is not expected to
332
+ # convert to a hash.
333
+ object = exception if exception.respond_to?(:to_honeybadger_context)
334
+ object ||= {}.freeze
335
+
336
+ Context(object)
330
337
  end
331
338
 
332
339
  def construct_context_hash(opts, exception)
333
340
  context = {}
334
341
  context.merge!(Context(opts[:global_context]))
335
- context.merge!(Context(exception_context(exception)))
342
+ context.merge!(exception_context(exception))
336
343
  context.merge!(Context(opts[:context]))
337
344
  context.empty? ? nil : context
338
345
  end
@@ -16,6 +16,10 @@ module Honeybadger
16
16
  Agent.instance.notify(exception_or_opts, opts)
17
17
  end
18
18
 
19
+ def check_in(id)
20
+ Agent.instance.check_in(id)
21
+ end
22
+
19
23
  def load_plugins!
20
24
  Dir[File.expand_path('../plugins/*.rb', __FILE__)].each do |plugin|
21
25
  require plugin
@@ -23,6 +27,16 @@ module Honeybadger
23
27
  Plugin.load!(self.config)
24
28
  end
25
29
 
30
+ def install_at_exit_callback
31
+ at_exit do
32
+ if $! && !$!.is_a?(SystemExit) && Honeybadger.config[:'exceptions.notify_at_exit']
33
+ Honeybadger.notify($!, component: 'at_exit', sync: true)
34
+ end
35
+
36
+ Honeybadger.stop if Honeybadger.config[:'send_data_at_exit']
37
+ end
38
+ end
39
+
26
40
  # Deprecated
27
41
  def start(config = {})
28
42
  raise NoMethodError, <<-WARNING
@@ -37,6 +37,12 @@ module Honeybadger
37
37
  @config = config
38
38
  end
39
39
 
40
+ def get(endpoint)
41
+ response = http_connection.get(endpoint)
42
+ debug { sprintf("http method=GET path=%s code=%d", endpoint.dump, response.code) }
43
+ response
44
+ end
45
+
40
46
  def post(endpoint, payload, headers = nil)
41
47
  response = http_connection.post(endpoint, compress(payload.to_json), http_headers(headers))
42
48
  debug { sprintf("http method=POST path=%s code=%d", endpoint.dump, response.code) }
@@ -106,6 +106,8 @@ module Honeybadger
106
106
  when String
107
107
  sanitize_string(data)
108
108
  when -> (d) { d.respond_to?(:to_honeybadger) }
109
+ return DEPTH if depth >= max_depth
110
+
109
111
  begin
110
112
  data = data.to_honeybadger
111
113
  rescue
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # Public: The current String Honeybadger version.
3
- VERSION = '3.2.0.beta1'.freeze
3
+ VERSION = '3.2.0'.freeze
4
4
  end
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.beta1
4
+ version: 3.2.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-10-12 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email:
@@ -138,12 +138,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  version: 2.1.0
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - ">"
141
+ - - ">="
142
142
  - !ruby/object:Gem::Version
143
- version: 1.3.1
143
+ version: '0'
144
144
  requirements: []
145
145
  rubyforge_project:
146
- rubygems_version: 2.6.8
146
+ rubygems_version: 2.6.13
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Error reports you can be happy about.