diff --git a/lib/new_relic/agent/instrumentation/grape.rb b/lib/new_relic/agent/instrumentation/grape.rb index dd00951f80..7b04878ac2 100644 --- a/lib/new_relic/agent/instrumentation/grape.rb +++ b/lib/new_relic/agent/instrumentation/grape.rb @@ -20,12 +20,17 @@ depends_on do begin if defined?(Bundler) && - if Bundler::VERSION >= '2' && Bundler.rubygems.installed_specs.map(&:name).include?('newrelic-grape') - NewRelic::Agent.logger.info('Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present') - false - elsif Bundler.rubygems.all_specs.map(&:name).include?('newrelic-grape') + grape_present = if (Bundler::VERSION >= '2' && Bundler.rubygems.installed_specs.map(&:name).include?('newrelic-grape')) || + Bundler.rubygems.all_specs.map(&:name).include?('newrelic-grape') + true + else + false + end + if grape_present NewRelic::Agent.logger.info('Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present') false + else + true end else true diff --git a/lib/new_relic/environment_report.rb b/lib/new_relic/environment_report.rb index c15012da34..d189abee2d 100644 --- a/lib/new_relic/environment_report.rb +++ b/lib/new_relic/environment_report.rb @@ -44,11 +44,8 @@ def self.registered_reporters=(logic) #################################### report_on('Gems') do begin - if Bundler::VERSION >= '2' - Bundler.rubygems.installed_specs.map { |gem| "#{gem.name}(#{gem.version})" } - else - Bundler.rubygems.all_specs.map { |gem| "#{gem.name}(#{gem.version})" } - end + specs_method = Bundler::VERSION >= '2' ? :installed_specs : :all_specs + Bundler.rubygems.send(specs_method).map { |gem| "#{gem.name} (#{gem.version})" } rescue # There are certain rubygem, bundler, rails combinations (e.g. gem # 1.6.2, rails 2.3, bundler 1.2.3) where the code above throws an error