From a885001e7f7bef3a7f1824c822b88ae16053c4b7 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Wed, 21 Aug 2024 11:13:05 -0700 Subject: [PATCH 1/4] Add Bundler version conditions (#2823) * Add Bundler version conditions Co-authored-by: James Bunch --- lib/new_relic/agent/instrumentation/grape.rb | 4 +++- lib/new_relic/control/frameworks/rails4.rb | 6 ++++-- lib/new_relic/environment_report.rb | 6 +++++- lib/new_relic/language_support.rb | 8 +++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/new_relic/agent/instrumentation/grape.rb b/lib/new_relic/agent/instrumentation/grape.rb index 26198326d0..0167794b3c 100644 --- a/lib/new_relic/agent/instrumentation/grape.rb +++ b/lib/new_relic/agent/instrumentation/grape.rb @@ -19,7 +19,9 @@ depends_on do begin - if defined?(Bundler) && Bundler.rubygems.all_specs.map(&:name).include?('newrelic-grape') + if defined?(Bundler) && + ((Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.0.0') && Bundler.rubygems.installed_specs.map(&:name).include?('newrelic-grape')) || + 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 else diff --git a/lib/new_relic/control/frameworks/rails4.rb b/lib/new_relic/control/frameworks/rails4.rb index 955749d5d3..3b13d588c1 100644 --- a/lib/new_relic/control/frameworks/rails4.rb +++ b/lib/new_relic/control/frameworks/rails4.rb @@ -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 Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.0.0') + Bundler.rubygems.installed_specs.map { |gem| "#{gem.name} (#{gem.version})" } + else + Bundler.rubygems.all_specs.map { |gem| "#{gem.name} (#{gem.version})" } end end diff --git a/lib/new_relic/environment_report.rb b/lib/new_relic/environment_report.rb index 0b6f76290f..7d2b487fc0 100644 --- a/lib/new_relic/environment_report.rb +++ b/lib/new_relic/environment_report.rb @@ -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 Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.0.0') + Bundler.rubygems.installed_specs.map { |gem| "#{gem.name}(#{gem.version})" } + else + Bundler.rubygems.all_specs.map { |gem| "#{gem.name}(#{gem.version})" } + end 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 diff --git a/lib/new_relic/language_support.rb b/lib/new_relic/language_support.rb index 612bc38d68..438d899aa4 100644 --- a/lib/new_relic/language_support.rb +++ b/lib/new_relic/language_support.rb @@ -88,7 +88,13 @@ def snakeize(string) end def bundled_gem?(gem_name) - defined?(Bundler) && Bundler.rubygems.all_specs.map(&:name).include?(gem_name) + return false unless defined?(Bundler) + + if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.0.0') + 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 From 7adc0dccf81adb97c7b0431522b3dbb1d3a848fe Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Wed, 21 Aug 2024 11:35:23 -0700 Subject: [PATCH 2/4] Add CHANGELOG for Bundler version update --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 946d229641..6c68a01075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## dev -Version enhances support for AWS Lambda functions, adds experimental OpenSearch instrumentation, updates framework detection, fixes Falcon dispatcher detection, fixes a bug with Redis instrumentation installation, and addresses a JRuby specific concurrency issue. +Version enhances support for AWS Lambda functions, adds experimental OpenSearch instrumentation, updates framework detection, silences a Bundler deprecation warning, fixes Falcon dispatcher detection, fixes a bug with Redis instrumentation installation, and addresses a JRuby-specific concurrency issue. - **Feature: Enhance AWS Lambda function instrumentation** @@ -22,6 +22,10 @@ When utilized via the latest [New Relic Ruby layer for AWS Lambda](https://layer Previously, applications using the Grape framework would set `ruby` as their framework within the Environment Report. Now, Grape applications will be set to `grape`. Similarly, applications using the Padrino framework would be set to `sinatra`. Now, they will be set to `padrino`. This will help the New Relic security agent compatibility checks. Thank you, [@prateeksen](https://github.com/prateeksen) for making this change. [Issue#2777](https://github.com/newrelic/newrelic-ruby-agent/issues/2777) [PR#2789](https://github.com/newrelic/newrelic-ruby-agent/pull/2789) +- **Feature: Silence Bundler `all_specs` deprecation warning** + + `Bundler.rubygems.all_specs` was removed in favor of `Bundler.rubygems.installed_specs` in Bundler versions 2+, causing the agent to emit deprecation warnings. The method has been updated when Bundler 2+ is detected and warnings are now silenced. Thanks to [@jcoyne](https://github.com/jcoyne) for reporting this issue. [Issue#2733](https://github.com/newrelic/newrelic-ruby-agent/issues/2733) [PR#2823](https://github.com/newrelic/newrelic-ruby-agent/pull/2823) + - **Bugfix: Fix Falcon dispatcher detection** Previously, we tried to use the object space to determine whether the [Falcon web server](https://github.com/socketry/falcon) was in use. However, Falcon is not added to the object space until after the environment report is generated, resulting in a `nil` dispatcher. Now, we revert to an earlier strategy that discovered the dispatcher using `File.basename`. Thank you, [@prateeksen](https://github.com/prateeksen) for reporting this issue and researching the problem. [Issue#2778](https://github.com/newrelic/newrelic-ruby-agent/issues/2778) [PR#2795](https://github.com/newrelic/newrelic-ruby-agent/pull/2795) From a50b3283dff22071e86686e5299990107b45480a Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Wed, 21 Aug 2024 11:58:43 -0700 Subject: [PATCH 3/4] Update CHANGELOG.md Co-authored-by: James Bunch --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c68a01075..770a209c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ When utilized via the latest [New Relic Ruby layer for AWS Lambda](https://layer - **Feature: Silence Bundler `all_specs` deprecation warning** - `Bundler.rubygems.all_specs` was removed in favor of `Bundler.rubygems.installed_specs` in Bundler versions 2+, causing the agent to emit deprecation warnings. The method has been updated when Bundler 2+ is detected and warnings are now silenced. Thanks to [@jcoyne](https://github.com/jcoyne) for reporting this issue. [Issue#2733](https://github.com/newrelic/newrelic-ruby-agent/issues/2733) [PR#2823](https://github.com/newrelic/newrelic-ruby-agent/pull/2823) + `Bundler.rubygems.all_specs` was deprecated in favor of `Bundler.rubygems.installed_specs` in Bundler versions 2+, causing the agent to emit deprecation warnings. The method has been updated when Bundler 2+ is detected and warnings are now silenced. Thanks to [@jcoyne](https://github.com/jcoyne) for reporting this issue. [Issue#2733](https://github.com/newrelic/newrelic-ruby-agent/issues/2733) [PR#2823](https://github.com/newrelic/newrelic-ruby-agent/pull/2823) - **Bugfix: Fix Falcon dispatcher detection** From dcc8ac029a3ebd615dc521a3737a5e91c7e3782f Mon Sep 17 00:00:00 2001 From: newrelic-ruby-agent-bot Date: Wed, 21 Aug 2024 19:11:04 +0000 Subject: [PATCH 4/4] bump version --- CHANGELOG.md | 4 ++-- lib/new_relic/version.rb | 2 +- newrelic.yml | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 770a209c3b..3b5946f5fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # New Relic Ruby Agent Release Notes -## dev +## v9.13.0 -Version enhances support for AWS Lambda functions, adds experimental OpenSearch instrumentation, updates framework detection, silences a Bundler deprecation warning, fixes Falcon dispatcher detection, fixes a bug with Redis instrumentation installation, and addresses a JRuby-specific concurrency issue. +Version 9.13.0 enhances support for AWS Lambda functions, adds experimental OpenSearch instrumentation, updates framework detection, silences a Bundler deprecation warning, fixes Falcon dispatcher detection, fixes a bug with Redis instrumentation installation, and addresses a JRuby-specific concurrency issue. - **Feature: Enhance AWS Lambda function instrumentation** diff --git a/lib/new_relic/version.rb b/lib/new_relic/version.rb index eb65139f10..e4889456a2 100644 --- a/lib/new_relic/version.rb +++ b/lib/new_relic/version.rb @@ -6,7 +6,7 @@ module NewRelic module VERSION # :nodoc: MAJOR = 9 - MINOR = 12 + MINOR = 13 TINY = 0 STRING = "#{MAJOR}.#{MINOR}.#{TINY}" diff --git a/newrelic.yml b/newrelic.yml index 737cba3760..cb2c78a591 100644 --- a/newrelic.yml +++ b/newrelic.yml @@ -509,6 +509,10 @@ common: &default_settings # prepend, chain, disabled. # instrumentation.net_http: auto + # Controls auto-instrumentation of the opensearch-ruby library at start-up. May + # be one of auto, prepend, chain, disabled. + # instrumentation.opensearch: auto + # Controls auto-instrumentation of Puma::Rack. When enabled, the agent hooks # into the to_app method in Puma::Rack::Builder to find gems to instrument # during application startup. May be one of: auto, prepend, chain, disabled. @@ -607,6 +611,12 @@ common: &default_settings # When true, the agent transmits data about your app to the New Relic collector. # monitor_mode: true + # If true, the agent captures OpenSearch queries in transaction traces. + # opensearch.capture_queries: true + + # If true, the agent obfuscates OpenSearch queries in transaction traces. + # opensearch.obfuscate_queries: true + # If true, uses Module#prepend rather than alias_method for ActiveRecord # instrumentation. # prepend_active_record_instrumentation: false