Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bundler version conditions #2823

Merged
merged 8 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/new_relic/agent/instrumentation/grape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@

depends_on do
begin
if defined?(Bundler) && Bundler.rubygems.all_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
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')
NewRelic::Agent.logger.info('Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present')
false
end
hannahramadan marked this conversation as resolved.
Show resolved Hide resolved
else
true
end
Expand Down
6 changes: 4 additions & 2 deletions lib/new_relic/control/frameworks/rails4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class Control
module Frameworks
class Rails4 < NewRelic::Control::Frameworks::Rails3
def rails_gem_list
Bundler.rubygems.all_specs.map do |gem|
"#{gem.name} (#{gem.version})"
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
end

Expand Down
6 changes: 5 additions & 1 deletion lib/new_relic/environment_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def self.registered_reporters=(logic)
####################################
report_on('Gems') do
begin
Bundler.rubygems.all_specs.map { |gem| "#{gem.name}(#{gem.version})" }
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
hannahramadan marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
7 changes: 6 additions & 1 deletion lib/new_relic/language_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ def snakeize(string)
end

def bundled_gem?(gem_name)
defined?(Bundler) && Bundler.rubygems.all_specs.map(&:name).include?(gem_name)
defined?(Bundler) &&
kaylareopelle marked this conversation as resolved.
Show resolved Hide resolved
if Bundler::VERSION >= '2'
Bundler.rubygems.installed_specs.map(&:name).include?(gem_name)
else
Bundler.rubygems.all_specs.map(&:name).include?(gem_name)
end
rescue => e
::NewRelic::Agent.logger.info("Could not determine if third party #{gem_name} gem is installed", e)
false
Expand Down
Loading