bugsnag 6.10.0 → 6.11.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +4 -0
  3. data/CHANGELOG.md +20 -0
  4. data/Gemfile +1 -0
  5. data/README.md +1 -0
  6. data/VERSION +1 -1
  7. data/features/fixtures/docker-compose.yml +13 -0
  8. data/features/fixtures/rails3/app/app/controllers/breadcrumbs_controller.rb +19 -0
  9. data/features/fixtures/rails3/app/app/controllers/session_tracking_controller.rb +10 -6
  10. data/features/fixtures/rails3/app/config/initializers/bugsnag.rb +8 -2
  11. data/features/fixtures/rails3/app/config/routes.rb +1 -0
  12. data/features/fixtures/rails4/app/Gemfile +5 -1
  13. data/features/fixtures/rails4/app/app/controllers/breadcrumbs_controller.rb +26 -0
  14. data/features/fixtures/rails4/app/app/controllers/mongo_controller.rb +23 -0
  15. data/features/fixtures/rails4/app/app/controllers/session_tracking_controller.rb +9 -5
  16. data/features/fixtures/rails4/app/app/jobs/application_job.rb +2 -0
  17. data/features/fixtures/rails4/app/app/jobs/notify_job.rb +5 -0
  18. data/features/fixtures/rails4/app/app/models/mongo_model.rb +6 -0
  19. data/features/fixtures/rails4/app/config/initializers/bugsnag.rb +7 -1
  20. data/features/fixtures/rails4/app/config/mongoid.yml +22 -0
  21. data/features/fixtures/rails4/app/config/routes.rb +2 -0
  22. data/features/fixtures/rails5/app/Gemfile +4 -0
  23. data/features/fixtures/rails5/app/app/controllers/breadcrumbs_controller.rb +24 -0
  24. data/features/fixtures/rails5/app/app/controllers/mongo_controller.rb +22 -0
  25. data/features/fixtures/rails5/app/app/controllers/session_tracking_controller.rb +9 -5
  26. data/features/fixtures/rails5/app/app/jobs/notify_job.rb +5 -0
  27. data/features/fixtures/rails5/app/app/models/mongo_model.rb +6 -0
  28. data/features/fixtures/rails5/app/config/initializers/bugsnag.rb +7 -1
  29. data/features/fixtures/rails5/app/config/mongoid.yml +23 -0
  30. data/features/fixtures/rails5/app/config/routes.rb +11 -1
  31. data/features/rails_features/auto_capture_sessions.feature +55 -5
  32. data/features/rails_features/breadcrumbs.feature +135 -0
  33. data/features/rails_features/mongo_breadcrumbs.feature +100 -0
  34. data/features/steps/ruby_notifier_steps.rb +6 -0
  35. data/lib/bugsnag.rb +59 -3
  36. data/lib/bugsnag/breadcrumbs/breadcrumb.rb +76 -0
  37. data/lib/bugsnag/breadcrumbs/breadcrumbs.rb +14 -0
  38. data/lib/bugsnag/breadcrumbs/validator.rb +59 -0
  39. data/lib/bugsnag/configuration.rb +103 -6
  40. data/lib/bugsnag/integrations/mongo.rb +132 -0
  41. data/lib/bugsnag/integrations/rails/rails_breadcrumbs.rb +118 -0
  42. data/lib/bugsnag/integrations/railtie.rb +28 -1
  43. data/lib/bugsnag/middleware/breadcrumbs.rb +21 -0
  44. data/lib/bugsnag/report.rb +30 -1
  45. data/lib/bugsnag/session_tracker.rb +1 -0
  46. data/lib/bugsnag/utility/circular_buffer.rb +62 -0
  47. data/spec/breadcrumbs/breadcrumb_spec.rb +93 -0
  48. data/spec/breadcrumbs/validator_spec.rb +200 -0
  49. data/spec/bugsnag_spec.rb +230 -0
  50. data/spec/configuration_spec.rb +176 -2
  51. data/spec/integrations/mongo_spec.rb +262 -0
  52. data/spec/report_spec.rb +149 -0
  53. data/spec/session_tracker_spec.rb +24 -2
  54. data/spec/utility/circular_buffer_spec.rb +98 -0
  55. metadata +27 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce226017ad134f5f882d4c5cd347871e04daac3270d032db298de2b23a5abc97
4
- data.tar.gz: a5b2a379fafe7bd51b8d2d8ca762ccda6f19ac5beb1b9d6ac607fd85e8768a2f
3
+ metadata.gz: fc8a84dd1c666154aabc8e2a259f195e002b536d65c26c7e2a4399f988da37c0
4
+ data.tar.gz: c57acd7af26a27dcdc8649d8822f707f146f77d02fa01356941cf4cd4f9d8293
5
5
  SHA512:
6
- metadata.gz: f94232a1d4f0c98df012d75ff19b02bfaf0133b3cc93b4e0b0285e9455ce52e40bb94b5f7cd1742841777f24ccfb0a7a01cc7756e618a4693675bad8e5dc378d
7
- data.tar.gz: d9840980489c43a139d92e9573be4eb5ba36c34d1a4b79874fc96176d1d1ab20ba4d1fd2c179d92ae08645276543a899b41e9ce3e62520d9ca7a0292c140ab17
6
+ metadata.gz: f1af419ae0b0fdc8b6284463a2945369564b5af5255aaeda4141f197787972d3483514a4db99e2a5dc9b6cba50ebd237bcdfe5509b738772954c25acdaa7582e
7
+ data.tar.gz: 845838f4f41b3893b95067437825c9af1ab4e634194d0cd81276784fde73e6227d1665da89c68d15e40181c257ec23eab7c857ff77225a9cfd52a7d1bbffb75d
@@ -289,6 +289,9 @@ Metrics/BlockNesting:
289
289
  # Configuration parameters: CountComments.
290
290
  Metrics/ClassLength:
291
291
  Max: 149
292
+ Exclude:
293
+ - 'lib/bugsnag/report.rb'
294
+ - 'lib/bugsnag/configuration.rb'
292
295
 
293
296
  # Offense count: 12
294
297
  Metrics/CyclomaticComplexity:
@@ -305,6 +308,7 @@ Metrics/ModuleLength:
305
308
  Max: 125
306
309
  Exclude:
307
310
  - 'lib/bugsnag/helpers.rb'
311
+ - 'lib/bugsnag.rb'
308
312
 
309
313
  # Offense count: 11
310
314
  Metrics/PerceivedComplexity:
@@ -1,6 +1,26 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 6.11.0 (17 Jan 2019)
5
+
6
+ **Note**: this release alters the behaviour of the notifier to track sessions automatically.
7
+
8
+ ### Enhancements
9
+
10
+ * Added Breadcrumbs. Breadcrumbs allow you to track events that may have led
11
+ up to an error, such as handled errors, page redirects, or SQL queries. For info on what
12
+ is tracked and how you can customize the data that breadcrumbs collect, see the
13
+ [Logging breadcrumbs](https://docs.bugsnag.com/platforms/ruby/other#logging-breadcrumbs)
14
+ section of our documentation.
15
+ | [#525](https://github.com/bugsnag/bugsnag-ruby/pull/525)
16
+
17
+ * Bugsnag will now capture automatically created sessions by default.
18
+ | [#523](https://github.com/bugsnag/bugsnag-ruby/pull/523)
19
+
20
+ ### Deprecated
21
+
22
+ * The `endpoint` and `session_endpoint` configuration options are now deprecated but still supported. The [`set_endpoints`](https://docs.bugsnag.com/platforms/ruby/other/configuration-options#endpoints) method should be used instead. Note that session tracking will be disabled if the notify endpoint is configured but the sessions endpoint is not - this is to avoid inadvertently sending session payloads to the wrong server.
23
+
4
24
  ## 6.10.0 (05 Dec 2018)
5
25
 
6
26
  ### Enhancements
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ group :test, optional: true do
8
8
  gem 'pry'
9
9
  gem 'addressable', '~> 2.3.8'
10
10
  gem 'delayed_job' if RUBY_VERSION >= '2.2.2'
11
+ gem 'i18n', RUBY_VERSION <= '2.3.0' ? '1.4.0': '>1.4.0' if RUBY_VERSION >= '2.2.2'
11
12
  gem 'webmock', RUBY_VERSION <= '1.9.3' ? '2.3.2': '>2.3.2'
12
13
  end
13
14
 
data/README.md CHANGED
@@ -10,6 +10,7 @@ The Bugsnag exception reporter for Ruby gives you instant notification of except
10
10
  * Report handled exceptions
11
11
  * Attach user information to determine how many people are affected by a crash
12
12
  * Send customized diagnostic data
13
+ * Track events that occur leading up to a crash
13
14
 
14
15
  ## Getting started
15
16
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.10.0
1
+ 6.11.0
@@ -4,6 +4,9 @@ services:
4
4
  redis:
5
5
  image: redis
6
6
 
7
+ mongo:
8
+ image: mongo
9
+
7
10
  plain-ruby:
8
11
  build:
9
12
  context: plain
@@ -117,6 +120,8 @@ services:
117
120
  - BUGSNAG_SESSION_ENDPOINT
118
121
  - BUGSNAG_TIMEOUT
119
122
  - CALLBACK_INITIATOR
123
+ - SQL_ONLY_BREADCRUMBS
124
+ - USE_DEFAULT_AUTO_CAPTURE_SESSIONS
120
125
  ports:
121
126
  - target: 3000
122
127
  published: 61283
@@ -128,6 +133,8 @@ services:
128
133
  args:
129
134
  - RUBY_VERSION
130
135
  - APP_PATH
136
+ depends_on:
137
+ - mongo
131
138
  environment:
132
139
  - BUGSNAG_API_KEY
133
140
  - http_proxy
@@ -152,6 +159,8 @@ services:
152
159
  - BUGSNAG_SESSION_ENDPOINT
153
160
  - BUGSNAG_TIMEOUT
154
161
  - CALLBACK_INITIATOR
162
+ - SQL_ONLY_BREADCRUMBS
163
+ - USE_DEFAULT_AUTO_CAPTURE_SESSIONS
155
164
  ports:
156
165
  - target: 3000
157
166
  published: 61284
@@ -163,6 +172,8 @@ services:
163
172
  args:
164
173
  - RUBY_VERSION
165
174
  - APP_PATH
175
+ depends_on:
176
+ - mongo
166
177
  environment:
167
178
  - BUGSNAG_API_KEY
168
179
  - http_proxy
@@ -187,6 +198,8 @@ services:
187
198
  - BUGSNAG_SESSION_ENDPOINT
188
199
  - BUGSNAG_TIMEOUT
189
200
  - CALLBACK_INITIATOR
201
+ - SQL_ONLY_BREADCRUMBS
202
+ - USE_DEFAULT_AUTO_CAPTURE_SESSIONS
190
203
  ports:
191
204
  - target: 3000
192
205
  published: 61285
@@ -0,0 +1,19 @@
1
+ class BreadcrumbsController < ApplicationController
2
+ def handled
3
+ Bugsnag.notify("Request breadcrumb")
4
+ render json: {}
5
+ end
6
+
7
+ def sql_breadcrumb
8
+ User.where(:email => "foo").as_json
9
+ Bugsnag.notify("SQL breadcrumb")
10
+ render json: {}
11
+ end
12
+
13
+ def cache_read
14
+ Rails.cache.write('test', true)
15
+ Rails.cache.read('test')
16
+ Bugsnag.notify("Cache breadcrumb")
17
+ render json: {}
18
+ end
19
+ end
@@ -6,15 +6,19 @@ class SessionTrackingController < ActionController::Base
6
6
  end
7
7
 
8
8
  def initializer
9
- Bugsnag.session_tracker.send_sessions()
9
+ Bugsnag.session_tracker.send_sessions
10
10
  render json: {}
11
11
  end
12
12
 
13
- def after
14
- Bugsnag.configure do |conf|
15
- conf.auto_capture_sessions = true
16
- end
17
- Bugsnag.session_tracker.send_sessions()
13
+ def manual
14
+ Bugsnag.start_session
15
+ Bugsnag.session_tracker.send_sessions
16
+ render json: {}
17
+ end
18
+
19
+ def multi_sessions
20
+ (0...100).each { Bugsnag.start_session }
21
+ Bugsnag.session_tracker.send_sessions
18
22
  render json: {}
19
23
  end
20
24
  end
@@ -7,8 +7,14 @@ Bugsnag.configure do |config|
7
7
  config.auto_notify = ENV["BUGSNAG_AUTO_NOTIFY"] != "false"
8
8
  config.project_root = ENV["BUGSNAG_PROJECT_ROOT"] if ENV.include? "BUGSNAG_PROJECT_ROOT"
9
9
  config.ignore_classes << lambda { |ex| ex.class.to_s == ENV["BUGSNAG_IGNORE_CLASS"] } if ENV.include? "BUGSNAG_IGNORE_CLASS"
10
- config.auto_capture_sessions = ENV["BUGSNAG_AUTO_CAPTURE_SESSIONS"] == "true"
10
+ config.auto_capture_sessions = ENV["BUGSNAG_AUTO_CAPTURE_SESSIONS"] == "true" unless ENV["USE_DEFAULT_AUTO_CAPTURE_SESSIONS"]
11
11
  config.release_stage = ENV["BUGSNAG_RELEASE_STAGE"] if ENV.include? "BUGSNAG_RELEASE_STAGE"
12
12
  config.send_code = ENV["BUGSNAG_SEND_CODE"] != "false"
13
13
  config.send_environment = ENV["BUGSNAG_SEND_ENVIRONMENT"] == "true"
14
- end
14
+
15
+ if ENV["SQL_ONLY_BREADCRUMBS"] == "true"
16
+ config.before_breadcrumb_callbacks << Proc.new do |breadcrumb|
17
+ breadcrumb.ignore! unless breadcrumb.meta_data[:event_name] == "sql.active_record" && breadcrumb.meta_data[:name] == "User Load"
18
+ end
19
+ end
20
+ end
@@ -14,5 +14,6 @@ App::Application.routes.draw do
14
14
  get "/send_code/(:action)", controller: 'send_code'
15
15
  get "/send_environment/(:action)", controller: 'send_environment'
16
16
  get "/warden/(:action)", controller: 'warden'
17
+ get "/breadcrumbs/(:action)", controller: 'breadcrumbs'
17
18
  get "/(:action)", controller: 'application'
18
19
  end
@@ -39,4 +39,8 @@ end
39
39
  # Added at 2018-03-26 15:02:53 +0100 by amoinet:
40
40
  gem 'bugsnag', path: '/bugsnag'
41
41
 
42
- gem 'devise'
42
+ gem 'devise'
43
+
44
+ gem "mongoid", '~> 5.4.0'
45
+
46
+ gem "nokogiri", "1.6.8"
@@ -0,0 +1,26 @@
1
+ class BreadcrumbsController < ApplicationController
2
+ def handled
3
+ Bugsnag.notify("Request breadcrumb")
4
+ render json: {}
5
+ end
6
+
7
+ def sql_breadcrumb
8
+ User.find_by(email: "foo")
9
+ Bugsnag.notify("SQL breadcrumb")
10
+ render json: {}
11
+ end
12
+
13
+ def active_job
14
+ Thread.new { NotifyJob.perform_later }.join
15
+ render json: {}
16
+ end
17
+
18
+ def cache_read
19
+ Thread.new {
20
+ Rails.cache.write('test', true)
21
+ Rails.cache.read('test')
22
+ Bugsnag.notify("Cache breadcrumb")
23
+ }.join
24
+ render json: {}
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ class MongoController < ApplicationController
2
+
3
+ def success_crash
4
+ doc = MongoModel.create(string_field: "String")
5
+ doc.save
6
+ "Statement".prepnd("Failing")
7
+ end
8
+
9
+ def get_crash
10
+ MongoModel.where(string_field: true).as_json
11
+ MongoModel.any_of({string_field: true}, {numeric_field: 123}).as_json
12
+ "Statement".prepnd("Failing")
13
+ end
14
+
15
+ def failure_crash
16
+ begin
17
+ Mongoid::Clients.default.database.command(:bogus => 1)
18
+ rescue
19
+ end
20
+
21
+ "Statement".prepnd("Failing")
22
+ end
23
+ end
@@ -10,11 +10,15 @@ class SessionTrackingController < ActionController::Base
10
10
  render json: {}
11
11
  end
12
12
 
13
- def after
14
- Bugsnag.configure do |conf|
15
- conf.auto_capture_sessions = true
16
- end
17
- Bugsnag.session_tracker.send_sessions()
13
+ def manual
14
+ Bugsnag.start_session
15
+ Bugsnag.session_tracker.send_sessions
16
+ render json: {}
17
+ end
18
+
19
+ def multi_sessions
20
+ (0...100).each { Bugsnag.start_session }
21
+ Bugsnag.session_tracker.send_sessions
18
22
  render json: {}
19
23
  end
20
24
  end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,5 @@
1
+ class NotifyJob < ApplicationJob
2
+ def perform
3
+ Bugsnag.notify("Failed")
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class MongoModel
2
+ include Mongoid::Document
3
+
4
+ field :string_field, type: String
5
+ field :numeric_field, type: Integer
6
+ end
@@ -7,8 +7,14 @@ Bugsnag.configure do |config|
7
7
  config.auto_notify = ENV["BUGSNAG_AUTO_NOTIFY"] != "false"
8
8
  config.project_root = ENV["BUGSNAG_PROJECT_ROOT"] if ENV.include? "BUGSNAG_PROJECT_ROOT"
9
9
  config.ignore_classes << lambda { |ex| ex.class.to_s == ENV["BUGSNAG_IGNORE_CLASS"] } if ENV.include? "BUGSNAG_IGNORE_CLASS"
10
- config.auto_capture_sessions = ENV["BUGSNAG_AUTO_CAPTURE_SESSIONS"] == "true"
10
+ config.auto_capture_sessions = ENV["BUGSNAG_AUTO_CAPTURE_SESSIONS"] == "true" unless ENV["USE_DEFAULT_AUTO_CAPTURE_SESSIONS"]
11
11
  config.release_stage = ENV["BUGSNAG_RELEASE_STAGE"] if ENV.include? "BUGSNAG_RELEASE_STAGE"
12
12
  config.send_code = ENV["BUGSNAG_SEND_CODE"] != "false"
13
13
  config.send_environment = ENV["BUGSNAG_SEND_ENVIRONMENT"] == "true"
14
+
15
+ if ENV["SQL_ONLY_BREADCRUMBS"] == "true"
16
+ config.before_breadcrumb_callbacks << Proc.new do |breadcrumb|
17
+ breadcrumb.ignore! unless breadcrumb.meta_data[:event_name] == "sql.active_record" && breadcrumb.meta_data[:name] == "User Load"
18
+ end
19
+ end
14
20
  end
@@ -0,0 +1,22 @@
1
+ development:
2
+ # Configure available database clients. (required)
3
+ clients:
4
+ # Defines the default client. (required)
5
+ default:
6
+ # Defines the name of the default database that Mongoid can connect to.
7
+ # (required).
8
+ database: rails4_development
9
+ # Provides the hosts the default client can connect to. Must be an array
10
+ # of host:port pairs. (required)
11
+ hosts:
12
+ - mongo:27017
13
+ test:
14
+ clients:
15
+ default:
16
+ database: rails4_test
17
+ hosts:
18
+ - mongo:27017
19
+ options:
20
+ read:
21
+ mode: :primary
22
+ max_pool_size: 1
@@ -16,4 +16,6 @@ App::Application.routes.draw do
16
16
  get "/send_code/(:action)", controller: 'send_code'
17
17
  get "/send_environment/(:action)", controller: 'send_environment'
18
18
  get "/devise/(:action)", controller: 'devise'
19
+ get "/breadcrumbs/(:action)", controller: 'breadcrumbs'
20
+ get "/mongo/(:action)", controller: 'mongo'
19
21
  end
@@ -45,3 +45,7 @@ gem 'bugsnag', path: '/bugsnag'
45
45
 
46
46
  # Added at 2018-04-26 10:20:10 +0100 by amoinet:
47
47
  gem "clearance", "~> 1.16"
48
+
49
+ gem "mongoid"
50
+
51
+ gem "nokogiri", "1.6.8"
@@ -0,0 +1,24 @@
1
+ class BreadcrumbsController < ApplicationController
2
+ def handled
3
+ Bugsnag.notify("Request breadcrumb")
4
+ render json: {}
5
+ end
6
+
7
+ def sql_breadcrumb
8
+ User.find_by(email: "foo")
9
+ Bugsnag.notify("SQL breadcrumb")
10
+ render json: {}
11
+ end
12
+
13
+ def active_job
14
+ NotifyJob.perform_later
15
+ render json: {}
16
+ end
17
+
18
+ def cache_read
19
+ Rails.cache.write('test', true)
20
+ Rails.cache.read('test')
21
+ Bugsnag.notify("Cache breadcrumb")
22
+ render json: {}
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ class MongoController < ApplicationController
2
+ def success_crash
3
+ doc = MongoModel.create(string_field: "String")
4
+ doc.save
5
+ "Statement".prepnd("Failing")
6
+ end
7
+
8
+ def get_crash
9
+ MongoModel.where(string_field: true).as_json
10
+ MongoModel.any_of({string_field: true}, {numeric_field: 123}).as_json
11
+ "Statement".prepnd("Failing")
12
+ end
13
+
14
+ def failure_crash
15
+ begin
16
+ Mongoid::Clients.default.database.command(:bogus => 1)
17
+ rescue
18
+ end
19
+
20
+ "Statement".prepnd("Failing")
21
+ end
22
+ end
@@ -6,11 +6,15 @@ class SessionTrackingController < ActionController::Base
6
6
  render json: {}
7
7
  end
8
8
 
9
- def after
10
- Bugsnag.configure do |conf|
11
- conf.auto_capture_sessions = true
12
- end
13
- Bugsnag.session_tracker.send_sessions()
9
+ def manual
10
+ Bugsnag.start_session
11
+ Bugsnag.session_tracker.send_sessions
12
+ render json: {}
13
+ end
14
+
15
+ def multi_sessions
16
+ (0...100).each { Bugsnag.start_session }
17
+ Bugsnag.session_tracker.send_sessions
14
18
  render json: {}
15
19
  end
16
20
  end
@@ -0,0 +1,5 @@
1
+ class NotifyJob < ApplicationJob
2
+ def perform
3
+ Bugsnag.notify("Failed")
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class MongoModel
2
+ include Mongoid::Document
3
+
4
+ field :string_field, type: String
5
+ field :numeric_field, type: Integer
6
+ end