bugsnag 5.2.0 → 5.3.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: d4b00bead73bfc579980368d65edb60286f0531b
4
- data.tar.gz: fbb45b08f2dc84545752c020110bb5c0bc746706
3
+ metadata.gz: bd7eb03ea37369e9f1168f4bacca512afe60b57e
4
+ data.tar.gz: c547dd53611a661b2965c5e6e75485e7ba8ccf42
5
5
  SHA512:
6
- metadata.gz: 08581bdce123264cbd592ddb6c4074f03b4d7d044bfa8ef8e72ee4af29dce3c34d183bb5db93b2fe770eee9b170ce39220969c6d93f784ab87dc50fb270a355b
7
- data.tar.gz: baa4a8957c00e2ac6608471ff19b3976dbe076b4c63fb3277c3c24ecfb18586fb40a80a896c3d8a1685cc3062d859311730f26e0e03fa0e1eb3586caf5c97b43
6
+ metadata.gz: 72ccb3099959f0e0fbf41f0c8bbbfeedeb5df9f2762b70a2a8d6cd01a399868e014fa2b0ae8a8d014ed49a87c7a9ab6ff893155deb70a6b5871164fe81d0a82c
7
+ data.tar.gz: e80bda1683ad5c7c9452467e2001ec17c9cb0631a87ae4c0ba5bc5ec1d5f2c6745a09bab8663955612d768090aa193fcd04edbfcc65063521b87ce5e38b0b5b9
data/CHANGELOG.md CHANGED
@@ -1,6 +1,42 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 5.3.0 (07 April 2017)
5
+
6
+ ### Enhancements
7
+
8
+ * [Resque] Fix leaking config into parent process
9
+ | [Martin Holman](https://github.com/martin308)
10
+ | [#347](https://github.com/bugsnag/bugsnag-ruby/pull/347)
11
+ * Add new integration for Que
12
+ | [Sjoerd Andringa](https://github.com/s-andringa)
13
+ | [#305](https://github.com/bugsnag/bugsnag-ruby/pull/305)
14
+ * [Sidekiq] Start Bugsnag after the logger in the middleware chain
15
+ | [Stephen Bussey](https://github.com/sb8244)
16
+ | [Akhil Naini](https://github.com/akhiln)
17
+ | [#326](https://github.com/bugsnag/bugsnag-ruby/pull/326)
18
+ | [#350](https://github.com/bugsnag/bugsnag-ruby/pull/350)
19
+ * [Rake] Allow overriding `app_type` apps
20
+ | [#351](https://github.com/bugsnag/bugsnag-ruby/issues/351)
21
+ * Send the dyno name as the hostname when running on Heroku
22
+ | [#333](https://github.com/bugsnag/bugsnag-ruby/issues/333)
23
+ * [Delayed Job] Add additional job information such as arguments and number of
24
+ attempts when available
25
+ | [Tim Diggins](https://github.com/timdiggins)
26
+ | [Abraham Chan](https://github.com/abraham-chan)
27
+ | [Johnny Shields](https://github.com/johnnyshields)
28
+ | [#329](https://github.com/bugsnag/bugsnag-ruby/pull/329)
29
+ | [#332](https://github.com/bugsnag/bugsnag-ruby/pull/332)
30
+ | [#321](https://github.com/bugsnag/bugsnag-ruby/pull/321)
31
+
32
+ ### Bug fixes
33
+
34
+ * Initialize Railtie after Bugsnag class
35
+ | [#343](https://github.com/bugsnag/bugsnag-ruby/issues/343)
36
+ * Alias `notify_or_ignore` to `notify`
37
+ | [Simon Maynard](https://github.com/snmaynard)
38
+ | [#319](https://github.com/bugsnag/bugsnag-ruby/pull/319)
39
+
4
40
  ## 5.2.0 (10 February 2017)
5
41
 
6
42
  ### Enhancements
data/CONTRIBUTING.md CHANGED
@@ -1,16 +1,34 @@
1
1
 
2
2
  ## How to contribute
3
3
 
4
- - [Fork](https://help.github.com/articles/fork-a-repo) the [notifier on github](https://github.com/bugsnag/bugsnag-ruby)
4
+ We are glad you're here! First-time and returning contributors are welcome to
5
+ add bug fixes and new integrations. If you are unsure about the direction of an
6
+ enhancement or if it would be generally useful, feel free to open an issue or a
7
+ work-in-progress pull request and ask for input.
8
+
9
+ Thank you!
10
+
11
+ ### Getting started
12
+
13
+ - [Fork](https://help.github.com/articles/fork-a-repo) the [library on github](https://github.com/bugsnag/bugsnag-ruby)
5
14
  - Commit and push until you are happy with your contribution
15
+
16
+ ### Polish
17
+
6
18
  - Run the tests with and make sure they all pass
7
19
 
8
20
  ```
9
21
  rake spec
10
22
  ```
23
+ - For adding a new integration (like support for a web framework or worker
24
+ queue), include an example in the `example/` directory showing off what
25
+ you've built. Include a `README` with the example app so others know how to
26
+ run it.
27
+
28
+
29
+ ### Ship it!
11
30
 
12
31
  - [Make a pull request](https://help.github.com/articles/using-pull-requests)
13
- - Thanks!
14
32
 
15
33
 
16
34
  ## How to release
data/README.md CHANGED
@@ -15,6 +15,7 @@ The Bugsnag exception reporter for Ruby gives you instant notification of except
15
15
 
16
16
  1. [Create a Bugsnag account](https://bugsnag.com)
17
17
  2. Complete the instructions in the integration guide for your framework:
18
+ * [Que](http://docs.bugsnag.com/platforms/ruby/que)
18
19
  * [Rack](http://docs.bugsnag.com/platforms/ruby/rack)
19
20
  * [Rails](http://docs.bugsnag.com/platforms/ruby/rails)
20
21
  * [Rake](http://docs.bugsnag.com/platforms/ruby/rake)
@@ -26,6 +27,7 @@ The Bugsnag exception reporter for Ruby gives you instant notification of except
26
27
  ## Support
27
28
 
28
29
  * Read the configuration reference:
30
+ * [Que](http://docs.bugsnag.com/platforms/ruby/que/configuration-options)
29
31
  * [Rack](http://docs.bugsnag.com/platforms/ruby/rack/configuration-options)
30
32
  * [Rails](http://docs.bugsnag.com/platforms/ruby/rails/configuration-options)
31
33
  * [Rake](http://docs.bugsnag.com/platforms/ruby/rake/configuration-options)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.2.0
1
+ 5.3.0
data/lib/bugsnag.rb CHANGED
@@ -14,7 +14,6 @@ require "bugsnag/delivery/synchronous"
14
14
  require "bugsnag/delivery/thread_queue"
15
15
 
16
16
  require "bugsnag/rack"
17
- require "bugsnag/railtie" if defined?(Rails::Railtie)
18
17
 
19
18
  require "bugsnag/middleware/rack_request"
20
19
  require "bugsnag/middleware/warden_user"
@@ -59,16 +58,6 @@ module Bugsnag
59
58
 
60
59
  yield(notification) if block_given?
61
60
 
62
- notification.deliver
63
- notification
64
- end
65
-
66
- # Notify of an exception unless it should be ignored
67
- def notify_or_ignore(exception, overrides=nil, request_data=nil, &block)
68
- notification = Notification.new(exception, configuration, overrides, request_data)
69
-
70
- yield(notification) if block_given?
71
-
72
61
  unless notification.ignore?
73
62
  notification.deliver
74
63
  notification
@@ -76,6 +65,7 @@ module Bugsnag
76
65
  false
77
66
  end
78
67
  end
68
+ alias_method :notify_or_ignore, :notify
79
69
 
80
70
  # Auto notify of an exception, called from rails and rack exception
81
71
  # rescuers, unless auto notification is disabled, or we should ignore this
@@ -131,7 +121,8 @@ module Bugsnag
131
121
  end
132
122
  end
133
123
 
134
- [:resque, :sidekiq, :mailman, :delayed_job, :shoryuken].each do |integration|
124
+ require "bugsnag/railtie" if defined?(Rails::Railtie)
125
+ [:resque, :sidekiq, :mailman, :delayed_job, :shoryuken, :que].each do |integration|
135
126
  begin
136
127
  require "bugsnag/#{integration}"
137
128
  rescue LoadError
@@ -146,8 +146,8 @@ module Bugsnag
146
146
  private
147
147
 
148
148
  def default_hostname
149
- # Don't send the hostname on Heroku
150
- Socket.gethostname unless ENV["DYNO"]
149
+ # Send the heroku dyno name instead of hostname if available
150
+ ENV["DYNO"] || Socket.gethostname;
151
151
  end
152
152
  end
153
153
  end
@@ -19,6 +19,13 @@ unless defined? Delayed::Plugins::Bugsnag
19
19
  :id => job.id,
20
20
  }
21
21
  }
22
+ if job.respond_to?(:queue) && (queue = job.queue)
23
+ overrides[:job][:queue] = queue
24
+ end
25
+ if job.respond_to?(:attempts)
26
+ overrides[:job][:attempts] = "#{job.attempts + 1} / #{Delayed::Worker.max_attempts}"
27
+ # +1 as "attempts" is really previous attempts AFAICT, certainly it starts at 0.
28
+ end
22
29
  if payload = job.payload_object
23
30
  p = {
24
31
  :class => payload.class.name,
@@ -33,6 +40,7 @@ unless defined? Delayed::Plugins::Bugsnag
33
40
  }
34
41
  p[:object][:id] = object.id if object.respond_to?(:id)
35
42
  end
43
+ add_active_job_details(p, payload)
36
44
  overrides[:job][:payload] = p
37
45
  end
38
46
 
@@ -40,6 +48,16 @@ unless defined? Delayed::Plugins::Bugsnag
40
48
 
41
49
  super if defined?(super)
42
50
  end
51
+
52
+ def add_active_job_details(p, payload)
53
+ if payload.respond_to?(:job_data) && payload.job_data.respond_to?(:[])
54
+ [:job_class, :arguments, :queue_name, :job_id].each do |key|
55
+ if (value = payload.job_data[key.to_s])
56
+ p[key] = value
57
+ end
58
+ end
59
+ end
60
+ end
43
61
  end
44
62
 
45
63
  callbacks do |lifecycle|
@@ -0,0 +1,37 @@
1
+ if defined?(::Que)
2
+ handler = proc do |error, job|
3
+ begin
4
+ job = job.dup # Make sure the original job object is not mutated.
5
+
6
+ Bugsnag.auto_notify(error) do |notification|
7
+ job[:error_count] += 1
8
+
9
+ # If the job was scheduled using ActiveJob then unwrap the job details for clarity:
10
+ if job[:job_class] == "ActiveJob::QueueAdapters::QueAdapter::JobWrapper"
11
+ wrapped_job = job[:args].last
12
+ wrapped_job = wrapped_job.each_with_object({}) { |(k, v), result| result[k.to_sym] = v } # Symbolize keys
13
+
14
+ # Align key names with keys in `job`
15
+ wrapped_job[:queue] = wrapped_job.delete(:queue_name)
16
+ wrapped_job[:args] = wrapped_job.delete(:arguments)
17
+
18
+ job.merge!(wrapper_job_class: job[:job_class], wrapper_job_id: job[:job_id]).merge!(wrapped_job)
19
+ end
20
+
21
+ notification.add_tab(:job, job)
22
+ end
23
+ rescue => e
24
+ # Que supresses errors raised by its error handler to avoid killing the worker. Log them somewhere:
25
+ Bugsnag.warn("Failed to notify Bugsnag of error in Que job (#{e.class}): #{e.message} \n#{e.backtrace[0..9].join("\n")}")
26
+ raise
27
+ end
28
+ end
29
+
30
+ if Que.respond_to?(:error_notifier=)
31
+ Bugsnag.configuration.app_type ||= "que"
32
+ Que.error_notifier = handler
33
+ elsif Que.respond_to?(:error_handler=)
34
+ Bugsnag.configuration.app_type ||= "que"
35
+ Que.error_handler = handler
36
+ end
37
+ end
data/lib/bugsnag/rake.rb CHANGED
@@ -5,7 +5,7 @@ Rake::TaskManager.record_task_metadata = true
5
5
  class Rake::Task
6
6
 
7
7
  def execute_with_bugsnag(args=nil)
8
- Bugsnag.configuration.app_type = "rake"
8
+ Bugsnag.configuration.app_type ||= "rake"
9
9
  old_task = Bugsnag.configuration.request_data[:bugsnag_running_task]
10
10
  Bugsnag.set_request_data :bugsnag_running_task, self
11
11
 
@@ -37,7 +37,14 @@ Resque::Failure::Bugsnag = Bugsnag::Resque
37
37
  # Auto-load the failure backend
38
38
  Bugsnag::Resque.add_failure_backend
39
39
 
40
- Resque.before_first_fork do
41
- Bugsnag.configuration.app_type = "resque"
42
- Bugsnag.configuration.default_delivery_method = :synchronous
40
+ if Resque::Worker.new.fork_per_job?
41
+ Resque.after_fork do
42
+ Bugsnag.configuration.app_type = "resque"
43
+ Bugsnag.configuration.default_delivery_method = :synchronous
44
+ end
45
+ else
46
+ Resque.before_first_fork do
47
+ Bugsnag.configuration.app_type = "resque"
48
+ Bugsnag.configuration.default_delivery_method = :synchronous
49
+ end
43
50
  end
@@ -27,6 +27,6 @@ end
27
27
 
28
28
  ::Sidekiq.configure_server do |config|
29
29
  config.server_middleware do |chain|
30
- chain.add ::Bugsnag::Sidekiq
30
+ chain.insert_after ::Sidekiq::Middleware::Server::Logging, ::Bugsnag::Sidekiq
31
31
  end
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-10 00:00:00.000000000 Z
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -140,6 +140,7 @@ files:
140
140
  - lib/bugsnag/middleware/warden_user.rb
141
141
  - lib/bugsnag/middleware_stack.rb
142
142
  - lib/bugsnag/notification.rb
143
+ - lib/bugsnag/que.rb
143
144
  - lib/bugsnag/rack.rb
144
145
  - lib/bugsnag/rails.rb
145
146
  - lib/bugsnag/rails/action_controller_rescue.rb
@@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  version: '0'
192
193
  requirements: []
193
194
  rubyforge_project:
194
- rubygems_version: 2.2.2
195
+ rubygems_version: 2.4.5
195
196
  signing_key:
196
197
  specification_version: 4
197
198
  summary: Ruby notifier for bugsnag.com