Skip to content

Commit 2fbc548

Browse files
authored
Merge pull request #564 from bugsnag/next
6.12.0 release
2 parents 73ab896 + e938bce commit 2fbc548

24 files changed

Lines changed: 248 additions & 66 deletions

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
Changelog
22
=========
33

4+
## 6.12.0 (28 Aug 2019)
5+
6+
### Enhancements
7+
8+
* Add Ruby (and other framework) version strings to report and session payloads (device.runtimeVersions).
9+
| [560](https://github.com/bugsnag/bugsnag-ruby/pull/560)
10+
11+
* Allow symbols in breadcrumb meta data.
12+
| [#563](https://github.com/bugsnag/bugsnag-ruby/pull/563)
13+
| [directionless](https://github.com/directionless)
14+
15+
### Fixes
16+
17+
* Use `Module#prepend` for Rake integration when on a new enough Ruby version
18+
to avoid infinite mutual recursion issues when something else monkey patches
19+
`Rake::Task`.
20+
| [#556](https://github.com/bugsnag/bugsnag-ruby/issues/556)
21+
| [#559](https://github.com/bugsnag/bugsnag-ruby/issues/559)
22+
23+
* Handle `nil` values for the `job` block parameter for the Que error notifier.
24+
This occurs under some conditions such as database connection failures.
25+
| [#545](https://github.com/bugsnag/bugsnag-ruby/issues/545)
26+
| [#548](https://github.com/bugsnag/bugsnag-ruby/pull/548)
27+
428
## 6.11.1 (22 Jan 2019)
529

630
### Fixes

CONTRIBUTING.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ Thank you!
1818
- Run the tests with and make sure they all pass
1919

2020
```
21-
rake spec
21+
bundle exec rake spec
22+
```
23+
- You will need to add the following test dependencies:
24+
25+
```
26+
bundle install --with test --binstubs
2227
```
2328
- For adding a new integration (like support for a web framework or worker
2429
queue), include an example in the `example/` directory showing off what

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.11.1
1+
6.12.0

lib/bugsnag/breadcrumbs/validator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def validate(breadcrumb)
4949
##
5050
# Tests whether the meta_data types are non-complex objects.
5151
#
52-
# Acceptable types are String, Numeric, TrueClass, FalseClass, and nil.
52+
# Acceptable types are String, Symbol, Numeric, TrueClass, FalseClass, and nil.
5353
#
5454
# @param value [Object] the object to be type checked
5555
def valid_meta_data_type?(value)
56-
value.nil? || value.is_a?(String) || value.is_a?(Numeric) || value.is_a?(FalseClass) || value.is_a?(TrueClass)
56+
value.nil? || value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(Numeric) || value.is_a?(FalseClass) || value.is_a?(TrueClass)
5757
end
5858
end
5959
end

lib/bugsnag/configuration.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Configuration
3434
attr_accessor :proxy_password
3535
attr_accessor :timeout
3636
attr_accessor :hostname
37+
attr_accessor :runtime_versions
3738
attr_accessor :ignore_classes
3839
attr_accessor :auto_capture_sessions
3940
attr_accessor :track_sessions
@@ -93,6 +94,9 @@ def initialize
9394
self.send_code = true
9495
self.meta_data_filters = Set.new(DEFAULT_META_DATA_FILTERS)
9596
self.hostname = default_hostname
97+
self.runtime_versions = {}
98+
self.runtime_versions["ruby"] = RUBY_VERSION
99+
self.runtime_versions["jruby"] = JRUBY_VERSION if defined?(JRUBY_VERSION)
96100
self.timeout = 15
97101
self.notify_release_stages = nil
98102
self.auto_capture_sessions = true

lib/bugsnag/integrations/que.rb

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
require 'que'
2-
32
if defined?(::Que)
43
handler = proc do |error, job|
54
begin
6-
job = job.dup # Make sure the original job object is not mutated.
5+
job &&= job.dup # Make sure the original job object is not mutated.
76

87
Bugsnag.notify(error, true) do |report|
9-
job[:error_count] += 1
8+
if job
9+
job[:error_count] += 1
1010

11-
# If the job was scheduled using ActiveJob then unwrap the job details for clarity:
12-
if job[:job_class] == "ActiveJob::QueueAdapters::QueAdapter::JobWrapper"
13-
wrapped_job = job[:args].last
14-
wrapped_job = wrapped_job.each_with_object({}) { |(k, v), result| result[k.to_sym] = v } # Symbolize keys
11+
# If the job was scheduled using ActiveJob then unwrap the job details for clarity:
12+
if job[:job_class] == "ActiveJob::QueueAdapters::QueAdapter::JobWrapper"
13+
wrapped_job = job[:args].last
14+
wrapped_job = wrapped_job.each_with_object({}) { |(k, v), result| result[k.to_sym] = v } # Symbolize keys
1515

16-
# Align key names with keys in `job`
17-
wrapped_job[:queue] = wrapped_job.delete(:queue_name)
18-
wrapped_job[:args] = wrapped_job.delete(:arguments)
16+
# Align key names with keys in `job`
17+
wrapped_job[:queue] = wrapped_job.delete(:queue_name)
18+
wrapped_job[:args] = wrapped_job.delete(:arguments)
1919

20-
job.merge!(wrapper_job_class: job[:job_class], wrapper_job_id: job[:job_id]).merge!(wrapped_job)
20+
job.merge!(wrapper_job_class: job[:job_class], wrapper_job_id: job[:job_id]).merge!(wrapped_job)
21+
end
2122
end
2223

2324
report.add_tab(:job, job)
@@ -38,9 +39,11 @@
3839

3940
if Que.respond_to?(:error_notifier=)
4041
Bugsnag.configuration.app_type ||= "que"
42+
Bugsnag.configuration.runtime_versions["que"] = ::Que::Version
4143
Que.error_notifier = handler
4244
elsif Que.respond_to?(:error_handler=)
4345
Bugsnag.configuration.app_type ||= "que"
46+
Bugsnag.configuration.runtime_versions["que"] = ::Que::Version
4447
Que.error_handler = handler
4548
end
46-
end
49+
end

lib/bugsnag/integrations/rack.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def initialize(app)
2929
config.middleware.insert_before(Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::WardenUser) if defined?(Warden)
3030
config.middleware.insert_before(Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::ClearanceUser) if defined?(Clearance)
3131

32+
# Set environment data for payload
3233
config.app_type ||= "rack"
34+
config.runtime_versions["rack"] = ::Rack.release if defined?(::Rack)
35+
config.runtime_versions["sinatra"] = ::Sinatra::VERSION if defined?(::Sinatra)
3336
end
3437
end
3538

lib/bugsnag/integrations/railtie.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Railtie < ::Rails::Railtie
2828
config.release_stage = ENV["BUGSNAG_RELEASE_STAGE"] || ::Rails.env.to_s
2929
config.project_root = ::Rails.root.to_s
3030
config.middleware.insert_before Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::Rails3Request
31+
config.runtime_versions["rails"] = ::Rails::VERSION::STRING
3132
end
3233

3334
ActiveSupport.on_load(:action_controller) do

lib/bugsnag/integrations/rake.rb

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,68 @@
22

33
Rake::TaskManager.record_task_metadata = true
44

5-
class Rake::Task
6-
7-
FRAMEWORK_ATTRIBUTES = {
8-
:framework => "Rake"
9-
}
10-
11-
##
12-
# Executes the rake task with Bugsnag setup with contextual data.
13-
def execute_with_bugsnag(args=nil)
14-
Bugsnag.configuration.app_type ||= "rake"
15-
old_task = Bugsnag.configuration.request_data[:bugsnag_running_task]
16-
Bugsnag.configuration.set_request_data :bugsnag_running_task, self
17-
18-
execute_without_bugsnag(args)
19-
20-
rescue Exception => ex
21-
Bugsnag.notify(ex, true) do |report|
22-
report.severity = "error"
23-
report.severity_reason = {
24-
:type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
25-
:attributes => FRAMEWORK_ATTRIBUTES
5+
if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.0')
6+
module Bugsnag
7+
module RakeTask
8+
FRAMEWORK_ATTRIBUTES = {
9+
framework: 'Rake'
2610
}
11+
12+
# Executes the rake task with Bugsnag setup with contextual data.
13+
def execute(args = nil)
14+
Bugsnag.configuration.app_type ||= "rake"
15+
old_task = Bugsnag.configuration.request_data[:bugsnag_running_task]
16+
Bugsnag.configuration.set_request_data :bugsnag_running_task, self
17+
Bugsnag.configuration.runtime_versions["rake"] = ::Rake::VERSION
18+
19+
super
20+
rescue Exception => ex
21+
Bugsnag.notify(ex, true) do |report|
22+
report.severity = "error"
23+
report.severity_reason = {
24+
type: Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
25+
attributes: FRAMEWORK_ATTRIBUTES
26+
}
27+
end
28+
raise
29+
ensure
30+
Bugsnag.configuration.set_request_data :bugsnag_running_task, old_task
31+
end
2732
end
28-
raise
29-
ensure
30-
Bugsnag.configuration.set_request_data :bugsnag_running_task, old_task
3133
end
3234

33-
alias_method :execute_without_bugsnag, :execute
34-
alias_method :execute, :execute_with_bugsnag
35+
Rake::Task.send(:prepend, Bugsnag::RakeTask)
36+
else
37+
class Rake::Task
38+
FRAMEWORK_ATTRIBUTES = {
39+
framework: 'Rake'
40+
}
41+
42+
##
43+
# Executes the rake task with Bugsnag setup with contextual data.
44+
def execute_with_bugsnag(args=nil)
45+
Bugsnag.configuration.app_type ||= "rake"
46+
old_task = Bugsnag.configuration.request_data[:bugsnag_running_task]
47+
Bugsnag.configuration.set_request_data :bugsnag_running_task, self
48+
Bugsnag.configuration.runtime_versions["rake"] = ::Rake::VERSION
49+
50+
execute_without_bugsnag(args)
51+
rescue Exception => ex
52+
Bugsnag.notify(ex, true) do |report|
53+
report.severity = "error"
54+
report.severity_reason = {
55+
type: Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
56+
attributes: FRAMEWORK_ATTRIBUTES
57+
}
58+
end
59+
raise
60+
ensure
61+
Bugsnag.configuration.set_request_data :bugsnag_running_task, old_task
62+
end
63+
64+
alias_method :execute_without_bugsnag, :execute
65+
alias_method :execute, :execute_with_bugsnag
66+
end
3567
end
3668

3769
Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::Rake)

lib/bugsnag/integrations/resque.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ def save
6262
Resque.after_fork do
6363
Bugsnag.configuration.app_type = "resque"
6464
Bugsnag.configuration.default_delivery_method = :synchronous
65+
Bugsnag.configuration.runtime_versions["resque"] = ::Resque::VERSION
6566
end
6667
else
6768
Resque.before_first_fork do
6869
Bugsnag.configuration.app_type = "resque"
6970
Bugsnag.configuration.default_delivery_method = :synchronous
71+
Bugsnag.configuration.runtime_versions["resque"] = ::Resque::VERSION
7072
end
7173
end

0 commit comments

Comments
 (0)