diff --git a/airbrake.gemspec b/airbrake.gemspec index af664e7b3..954916581 100644 --- a/airbrake.gemspec +++ b/airbrake.gemspec @@ -31,7 +31,7 @@ DESC s.required_ruby_version = '>= 2.0' - s.add_dependency 'airbrake-ruby', '~> 2.5' + s.add_dependency 'airbrake-ruby', '~> 2.10' s.add_development_dependency 'rspec', '~> 3' s.add_development_dependency 'rspec-wait', '~> 0' diff --git a/lib/airbrake/rack/context_filter.rb b/lib/airbrake/rack/context_filter.rb index 45935aa73..f74f0907c 100644 --- a/lib/airbrake/rack/context_filter.rb +++ b/lib/airbrake/rack/context_filter.rb @@ -10,11 +10,14 @@ class ContextFilter def initialize @framework_version = if defined?(::Rails) && ::Rails.respond_to?(:version) - "Rails/#{::Rails.version}" + { 'rails' => ::Rails.version } elsif defined?(::Sinatra) - "Sinatra/#{Sinatra::VERSION}" + { 'sinatra' => Sinatra::VERSION } else - "Rack.version/#{::Rack.version} Rack.release/#{::Rack.release}" + { + 'rack_version' => ::Rack.version, + 'rack_release' => ::Rack.release + } end.freeze @weight = 99 end @@ -44,10 +47,10 @@ def call(notice) private def add_framework_version(context) - if context.key?(:version) - context[:version] += " #{@framework_version}" + if context.key?(:versions) + context[:versions].merge!(@framework_version) else - context[:version] = @framework_version + context[:versions] = @framework_version end end end diff --git a/spec/integration/rack/rack_spec.rb b/spec/integration/rack/rack_spec.rb index 01829b0ef..cdd2dd5a5 100644 --- a/spec/integration/rack/rack_spec.rb +++ b/spec/integration/rack/rack_spec.rb @@ -10,7 +10,7 @@ it "includes version" do get '/crash' wait_for_a_request_with_body( - /"context":{.*"version":"1.2.3 Rack\.version.+Rack\.release/ + /"context":{.*"versions":{"rack_version":"\d\..+","rack_release":"\d\..+"}/ ) end end diff --git a/spec/integration/rails/rails_spec.rb b/spec/integration/rails/rails_spec.rb index 802fd10cc..42cf18bd5 100644 --- a/spec/integration/rails/rails_spec.rb +++ b/spec/integration/rails/rails_spec.rb @@ -53,7 +53,7 @@ end it "includes version" do - wait_for_a_request_with_body(/"context":{.*"version":"1.2.3 Rails/) + wait_for_a_request_with_body(/"context":{.*"versions":{"rails":"\d\./) end it "includes session" do diff --git a/spec/integration/sinatra/sinatra_spec.rb b/spec/integration/sinatra/sinatra_spec.rb index 3487c0691..d5bc06437 100644 --- a/spec/integration/sinatra/sinatra_spec.rb +++ b/spec/integration/sinatra/sinatra_spec.rb @@ -15,7 +15,7 @@ describe "context payload" do it "includes version" do get '/crash' - wait_for_a_request_with_body(/"context":{.*"version":"1.2.3 Sinatra/) + wait_for_a_request_with_body(/"context":{.*"versions":{"sinatra":"\d\./) end end diff --git a/spec/unit/rack/context_filter_spec.rb b/spec/unit/rack/context_filter_spec.rb index 5a021dc3a..4caac1aa5 100644 --- a/spec/unit/rack/context_filter_spec.rb +++ b/spec/unit/rack/context_filter_spec.rb @@ -18,8 +18,10 @@ def env_for(url, opts = {}) it "adds framework version to the context" do subject.call(notice) - expect(notice[:context][:version]). - to match(/\d.\d.\d Rack\.version.+Rack\.release/) + expect(notice[:context][:versions]).to include( + 'rack_version' => a_string_matching(/\d.\d/), + 'rack_release' => a_string_matching(/\d.\d\.\d/) + ) end context "when URL is present" do diff --git a/spec/unit/rack/middleware_spec.rb b/spec/unit/rack/middleware_spec.rb index 83d7a7acb..e947f64c9 100644 --- a/spec/unit/rack/middleware_spec.rb +++ b/spec/unit/rack/middleware_spec.rb @@ -76,7 +76,7 @@ def wait_for_a_request_with_body(body) to raise_error(AirbrakeTestError) wait_for_a_request_with_body( - %r("context":{.*"version":"1.2.3 (Rails|Sinatra|Rack\.version)/.+".+}) + /"context":{.*"versions":{"(rails|sinatra|rack_version)"/ ) end end