bugsnag 6.6.3 → 6.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rdoc_options +27 -0
  3. data/.rubocop.yml +2 -0
  4. data/.rubocop_todo.yml +672 -0
  5. data/.travis.yml +46 -11
  6. data/CHANGELOG.md +12 -0
  7. data/Gemfile +8 -0
  8. data/Rakefile +5 -4
  9. data/VERSION +1 -1
  10. data/lib/bugsnag.rb +19 -4
  11. data/lib/bugsnag/configuration.rb +20 -2
  12. data/lib/bugsnag/delivery.rb +4 -0
  13. data/lib/bugsnag/delivery/synchronous.rb +2 -0
  14. data/lib/bugsnag/delivery/thread_queue.rb +2 -0
  15. data/lib/bugsnag/helpers.rb +10 -0
  16. data/lib/bugsnag/integrations/mailman.rb +4 -0
  17. data/lib/bugsnag/integrations/rack.rb +4 -0
  18. data/lib/bugsnag/integrations/rake.rb +2 -0
  19. data/lib/bugsnag/integrations/resque.rb +6 -0
  20. data/lib/bugsnag/integrations/shoryuken.rb +2 -0
  21. data/lib/bugsnag/integrations/sidekiq.rb +2 -0
  22. data/lib/bugsnag/middleware/callbacks.rb +2 -0
  23. data/lib/bugsnag/middleware/classify_error.rb +2 -0
  24. data/lib/bugsnag/middleware/clearance_user.rb +2 -0
  25. data/lib/bugsnag/middleware/exception_meta_data.rb +14 -14
  26. data/lib/bugsnag/middleware/ignore_error_class.rb +3 -0
  27. data/lib/bugsnag/middleware/mailman.rb +2 -0
  28. data/lib/bugsnag/middleware/rack_request.rb +2 -0
  29. data/lib/bugsnag/middleware/rails3_request.rb +2 -0
  30. data/lib/bugsnag/middleware/rake.rb +2 -0
  31. data/lib/bugsnag/middleware/session_data.rb +2 -0
  32. data/lib/bugsnag/middleware/sidekiq.rb +2 -0
  33. data/lib/bugsnag/middleware/suggestion_data.rb +2 -0
  34. data/lib/bugsnag/middleware/warden_user.rb +2 -0
  35. data/lib/bugsnag/middleware_stack.rb +20 -2
  36. data/lib/bugsnag/report.rb +16 -3
  37. data/lib/bugsnag/session_tracker.rb +13 -1
  38. data/lib/bugsnag/stacktrace.rb +6 -2
  39. data/spec/middleware/exception_meta_data_spec.rb +104 -0
  40. data/spec/report_spec.rb +9 -1
  41. metadata +7 -3
@@ -4,11 +4,11 @@ language: ruby
4
4
  before_install:
5
5
  - gem update --system 2.6.14
6
6
  - gem --version
7
- - gem install bundler -v 1.12
8
- - bundle _1.12.0_ --version
7
+ - gem install bundler -v $BUNDLE_VERSION
8
+ - bundle _${BUNDLE_VERSION}_ --version
9
9
 
10
10
  install:
11
- - bundle _1.12.0_ install --with "$GEMSETS" --binstubs
11
+ - bundle _${BUNDLE_VERSION}_ install --with "$GEMSETS" --binstubs
12
12
 
13
13
  script:
14
14
  - bundle exec ./bin/rake spec
@@ -16,23 +16,58 @@ script:
16
16
  jobs:
17
17
  include:
18
18
  - stage: test
19
- env: GEMSETS=test
19
+ env:
20
+ - BUNDLE_VERSION=1.16.1
21
+ - GEMSETS=test
20
22
  rvm: jruby-19mode
21
23
  - stage: test
22
- env: GEMSETS=test
23
24
  rvm: 1.9.3
25
+ env:
26
+ - BUNDLE_VERSION=1.12.0
27
+ - GEMSETS=test
24
28
  - stage: test
25
- env: GEMSETS=test
26
29
  rvm: 2.0.0
30
+ env:
31
+ - BUNDLE_VERSION=1.12.0
32
+ - GEMSETS=test
27
33
  - stage: test
28
- env: GEMSETS=test
29
- rvm: 2.1.10
34
+ rvm: 2.1.
35
+ env:
36
+ - BUNDLE_VERSION=1.12.0
37
+ - GEMSETS=test
30
38
  - stage: test
31
- env: GEMSETS="test sidekiq"
39
+ env:
40
+ - BUNDLE_VERSION=1.12.0
41
+ - GEMSETS="test sidekiq"
32
42
  rvm: 2.2.4
33
43
  - stage: test
34
- env: GEMSETS="test sidekiq coverage"
44
+ env:
45
+ - BUNDLE_VERSION=1.12.0
46
+ - GEMSETS="test sidekiq coverage"
35
47
  rvm: 2.3.0
36
48
  - stage: test
37
- env: GEMSETS="test sidekiq"
49
+ env:
50
+ - BUNDLE_VERSION=1.12.0
51
+ - GEMSETS="test sidekiq"
38
52
  rvm: 2.4.1
53
+ - stage: test
54
+ env:
55
+ - BUNDLE_VERSION=1.12.0
56
+ - GEMSETS="test rubocop"
57
+ rvm: 2.4.1
58
+ script: bundle exec ./bin/rubocop lib/
59
+ - stage: deploy
60
+ env:
61
+ - BUNDLE_VERSION=1.12.0
62
+ - GEMSETS="test doc"
63
+ rvm: 2.4.1
64
+ script: bundle exec rake rdoc
65
+ if: tag =~ ^v[1-9]
66
+
67
+ deploy:
68
+ provider: pages
69
+ local_dir: rdoc # only include the contents of the generated docs dir
70
+ skip_cleanup: true
71
+ github_token: $GITHUB_TOKEN # set in travis-ci dashboard
72
+ on:
73
+ tags: true # only deploy when tag is applied to commit
@@ -1,6 +1,18 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 6.6.4 (14 Feb 2018)
5
+
6
+ ### Fixes
7
+
8
+ * Mark files in `.bundle/` directory as not "in project"
9
+ | [#420](https://github.com/bugsnag/bugsnag-ruby/pull/420)
10
+ | [Alex Moinet](https://github.com/Cawllec)
11
+ * Restore support for attaching `bugsnag_*` metadata to exceptions without
12
+ extending `Bugsnag::Middleware::ExceptionMetaData`
13
+ | [#426](https://github.com/bugsnag/bugsnag-ruby/pull/426)
14
+ | [Jordan Raine](https://github.com/jnraine)
15
+
4
16
  ## 6.6.3 (23 Jan 2018)
5
17
 
6
18
  ### Fixes
data/Gemfile CHANGED
@@ -16,8 +16,16 @@ group :coverage, optional: true do
16
16
  gem 'coveralls'
17
17
  end
18
18
 
19
+ group :rubocop, optional: true do
20
+ gem 'rubocop', '~> 0.52.1'
21
+ end
22
+
19
23
  group :sidekiq, optional: true do
20
24
  gem 'sidekiq', '~> 5.0.4'
21
25
  end
22
26
 
27
+ group :doc, optional: true do
28
+ gem 'hanna-nouveau'
29
+ end
30
+
23
31
  gemspec
data/Rakefile CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  require 'rdoc/task'
4
4
  RDoc::Task.new do |rdoc|
5
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
6
-
7
5
  rdoc.rdoc_dir = 'rdoc'
8
- rdoc.title = "bugsnag #{version}"
9
- rdoc.rdoc_files.include('README*')
6
+ rdoc.rdoc_files.include('README.md')
7
+ rdoc.rdoc_files.include('CONTRIBUTING.md')
8
+ rdoc.rdoc_files.include('CHANGELOG.md')
10
9
  rdoc.rdoc_files.include('lib/**/*.rb')
10
+ rdoc.options.push '-f', 'hanna'
11
+ rdoc.markup = 'markdown'
11
12
  end
12
13
 
13
14
  # RSpec tasks
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.6.3
1
+ 6.6.4
@@ -30,7 +30,10 @@ module Bugsnag
30
30
  LOCK = Mutex.new
31
31
 
32
32
  class << self
33
+ ##
33
34
  # Configure the Bugsnag notifier application-wide settings.
35
+ #
36
+ # Yields a configuration object to use to set application settings.
34
37
  def configure
35
38
  yield(configuration) if block_given?
36
39
 
@@ -41,7 +44,10 @@ module Bugsnag
41
44
  end
42
45
  end
43
46
 
44
- # Explicitly notify of an exception
47
+ ##
48
+ # Explicitly notify of an exception.
49
+ #
50
+ # Optionally accepts a block to append metadata to the yielded report.
45
51
  def notify(exception, auto_notify=false, &block)
46
52
  unless auto_notify.is_a? TrueClass or auto_notify.is_a? FalseClass
47
53
  configuration.warn("Adding metadata/severity using a hash is no longer supported, please use block syntax instead")
@@ -120,23 +126,32 @@ module Bugsnag
120
126
  end
121
127
  end
122
128
 
123
- # Configuration getters
129
+ ##
130
+ # Returns the client's Configuration object, or creates one if not yet created.
124
131
  def configuration
125
132
  @configuration = nil unless defined?(@configuration)
126
133
  @configuration || LOCK.synchronize { @configuration ||= Bugsnag::Configuration.new }
127
134
  end
128
135
 
129
- # Session tracking
136
+ ##
137
+ # Returns the client's SessionTracker object, or creates one if not yet created.
130
138
  def session_tracker
131
139
  @session_tracker = nil unless defined?(@session_tracker)
132
140
  @session_tracker || LOCK.synchronize { @session_tracker ||= Bugsnag::SessionTracker.new}
133
141
  end
134
142
 
143
+ ##
144
+ # Starts a session.
145
+ #
146
+ # Allows Bugsnag to track error rates across releases.
135
147
  def start_session
136
148
  session_tracker.start_session
137
149
  end
138
150
 
139
- # Allow access to "before notify" callbacks
151
+ ##
152
+ # Allow access to "before notify" callbacks as an array.
153
+ #
154
+ # These callbacks will be called whenever an error notification is being made.
140
155
  def before_notify_callbacks
141
156
  Bugsnag.configuration.request_data[:before_callbacks] ||= []
142
157
  end
@@ -121,40 +121,58 @@ module Bugsnag
121
121
  @default_delivery_method = delivery_method
122
122
  end
123
123
 
124
+ ##
125
+ # Indicates whether the notifier should send a notification based on the
126
+ # configured release stage.
124
127
  def should_notify_release_stage?
125
128
  @release_stage.nil? || @notify_release_stages.nil? || @notify_release_stages.include?(@release_stage)
126
129
  end
127
130
 
131
+ ##
132
+ # Tests whether the configured API key is valid.
128
133
  def valid_api_key?
129
134
  !api_key.nil? && api_key =~ API_KEY_REGEX
130
135
  end
131
136
 
137
+ ##
138
+ # Returns the array of data that will be automatically attached to every
139
+ # error notification.
132
140
  def request_data
133
141
  Thread.current[THREAD_LOCAL_NAME] ||= {}
134
142
  end
135
143
 
144
+ ##
145
+ # Sets an entry in the array of data attached to every error notification.
136
146
  def set_request_data(key, value)
137
147
  self.request_data[key] = value
138
148
  end
139
149
 
150
+ ##
151
+ # Unsets an entry in the array of data attached to every error notification.
140
152
  def unset_request_data(key, value)
141
153
  self.request_data.delete(key)
142
154
  end
143
155
 
156
+ ##
157
+ # Clears the array of data attached to every error notification.
144
158
  def clear_request_data
145
159
  Thread.current[THREAD_LOCAL_NAME] = nil
146
160
  end
147
161
 
162
+ ##
163
+ # Logs an info level message
148
164
  def info(message)
149
165
  logger.info(message)
150
166
  end
151
167
 
152
- # Warning logger
168
+ ##
169
+ # Logs a warning level message
153
170
  def warn(message)
154
171
  logger.warn(message)
155
172
  end
156
173
 
157
- # Debug logger
174
+ ##
175
+ # Logs a debug level message
158
176
  def debug(message)
159
177
  logger.debug(message)
160
178
  end
@@ -1,18 +1,22 @@
1
1
  module Bugsnag
2
2
  module Delivery
3
3
  class << self
4
+ ##
4
5
  # Add a delivery method to the list of supported methods. Any registered
5
6
  # method can then be used by name in Configuration.
6
7
  #
8
+ # ```
7
9
  # require 'bugsnag'
8
10
  # Bugsnag::Delivery.register(:my_delivery_queue, MyDeliveryQueue)
9
11
  # Bugsnag.configure do |config|
10
12
  # config.delivery_method = :my_delivery_queue
11
13
  # end
14
+ # ```
12
15
  def register(name, delivery_method)
13
16
  delivery_methods[name.to_sym] = delivery_method
14
17
  end
15
18
 
19
+ ##
16
20
  # Reference a delivery method by name
17
21
  def [](name)
18
22
  delivery_methods[name.to_sym]
@@ -5,6 +5,8 @@ module Bugsnag
5
5
  module Delivery
6
6
  class Synchronous
7
7
  class << self
8
+ ##
9
+ # Attempts to deliver a payload to the given endpoint synchronously.
8
10
  def deliver(url, body, configuration, options={})
9
11
  begin
10
12
  response = request(url, body, configuration, options)
@@ -8,6 +8,8 @@ module Bugsnag
8
8
  MUTEX = Mutex.new
9
9
 
10
10
  class << self
11
+ ##
12
+ # Queues a given payload to be delivered asynchronously.
11
13
  def deliver(url, body, configuration, options={})
12
14
  @configuration = configuration
13
15
 
@@ -10,6 +10,7 @@ module Bugsnag
10
10
  MAX_ARRAY_LENGTH = 40
11
11
  RAW_DATA_TYPES = [Numeric, TrueClass, FalseClass]
12
12
 
13
+ ##
13
14
  # Trim the size of value if the serialized JSON value is longer than is
14
15
  # accepted by Bugsnag
15
16
  def self.trim_if_needed(value)
@@ -23,6 +24,10 @@ module Bugsnag
23
24
  remove_metadata_from_events(reduced_value)
24
25
  end
25
26
 
27
+ ##
28
+ # Merges r_hash into l_hash recursively, favouring the values in r_hash.
29
+ #
30
+ # Returns a new array consisting of the merged values
26
31
  def self.deep_merge(l_hash, r_hash)
27
32
  l_hash.merge(r_hash) do |key, l_val, r_val|
28
33
  if l_val.is_a?(Hash) && r_val.is_a?(Hash)
@@ -35,6 +40,10 @@ module Bugsnag
35
40
  end
36
41
  end
37
42
 
43
+ ##
44
+ # Merges r_hash into l_hash recursively, favouring the values in r_hash.
45
+ #
46
+ # Overwrites the values in the existing l_hash
38
47
  def self.deep_merge!(l_hash, r_hash)
39
48
  l_hash.merge!(r_hash) do |key, l_val, r_val|
40
49
  if l_val.is_a?(Hash) && r_val.is_a?(Hash)
@@ -51,6 +60,7 @@ module Bugsnag
51
60
 
52
61
  TRUNCATION_INFO = '[TRUNCATED]'
53
62
 
63
+ ##
54
64
  # Check if a value is a raw type which should not be trimmed, truncated
55
65
  # or converted to a string
56
66
  def self.is_json_raw_type?(value)
@@ -1,6 +1,8 @@
1
1
  require 'mailman'
2
2
 
3
3
  module Bugsnag
4
+ ##
5
+ # Extracts and appends mailman message information to error reports
4
6
  class Mailman
5
7
 
6
8
  FRAMEWORK_ATTRIBUTES = {
@@ -12,6 +14,8 @@ module Bugsnag
12
14
  Bugsnag.configuration.app_type = "mailman"
13
15
  end
14
16
 
17
+ ##
18
+ # Calls the mailman middleware.
15
19
  def call(mail)
16
20
  begin
17
21
  Bugsnag.configuration.set_request_data :mailman_msg, mail.to_s
@@ -1,4 +1,6 @@
1
1
  module Bugsnag
2
+ ##
3
+ # Automatically captures and adds Rack request information to error reports
2
4
  class Rack
3
5
 
4
6
  FRAMEWORK_ATTRIBUTES = {
@@ -31,6 +33,8 @@ module Bugsnag
31
33
  end
32
34
  end
33
35
 
36
+ ##
37
+ # Wraps a call to the application with error capturing
34
38
  def call(env)
35
39
  # Set the request data for bugsnag middleware to use
36
40
  Bugsnag.configuration.set_request_data(:rack_env, env)
@@ -8,6 +8,8 @@ class Rake::Task
8
8
  :framework => "Rake"
9
9
  }
10
10
 
11
+ ##
12
+ # Executes the rake task with Bugsnag setup with contextual data.
11
13
  def execute_with_bugsnag(args=nil)
12
14
  Bugsnag.configuration.app_type ||= "rake"
13
15
  old_task = Bugsnag.configuration.request_data[:bugsnag_running_task]
@@ -8,11 +8,15 @@ module Bugsnag
8
8
  :framework => "Resque"
9
9
  }
10
10
 
11
+ ##
12
+ # Callthrough to Bugsnag configuration.
11
13
  def self.configure(&block)
12
14
  add_failure_backend
13
15
  Bugsnag.configure(&block)
14
16
  end
15
17
 
18
+ ##
19
+ # Sets up the Resque failure backend.
16
20
  def self.add_failure_backend
17
21
  return if ::Resque::Failure.backend == self
18
22
 
@@ -30,6 +34,8 @@ module Bugsnag
30
34
  end
31
35
  end
32
36
 
37
+ ##
38
+ # Notifies Bugsnag of a raised exception.
33
39
  def save
34
40
  Bugsnag.notify(exception, true) do |report|
35
41
  report.severity = "error"
@@ -1,6 +1,8 @@
1
1
  require 'shoryuken'
2
2
 
3
3
  module Bugsnag
4
+ ##
5
+ # Extracts and attaches Shoryuken queue information to an error report
4
6
  class Shoryuken
5
7
 
6
8
  FRAMEWORK_ATTRIBUTES = {
@@ -1,6 +1,8 @@
1
1
  require 'sidekiq'
2
2
 
3
3
  module Bugsnag
4
+ ##
5
+ # Extracts and attaches Sidekiq job and queue information to an error report
4
6
  class Sidekiq
5
7
 
6
8
  FRAMEWORK_ATTRIBUTES = {
@@ -1,4 +1,6 @@
1
1
  module Bugsnag::Middleware
2
+ ##
3
+ # Calls all configured callbacks passing an error report
2
4
  class Callbacks
3
5
  def initialize(bugsnag)
4
6
  @bugsnag = bugsnag
@@ -1,4 +1,6 @@
1
1
  module Bugsnag::Middleware
2
+ ##
3
+ # Sets the severity to info for low-importance errors
2
4
  class ClassifyError
3
5
  INFO_CLASSES = [
4
6
  "AbstractController::ActionNotFound",