Skip to content

Commit

Permalink
Merge branch 'dev' into bugfix/rails-frameworks-forced-to-load-during…
Browse files Browse the repository at this point in the history
…-agent-initialization
  • Loading branch information
kaylareopelle committed Dec 8, 2022
2 parents 832fc4f + c8fbcac commit 00e04a0
Show file tree
Hide file tree
Showing 62 changed files with 310 additions and 310 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Version 8.13.1 of the agent provides a bugfix for Redis v5.0 instrumentation.

- **Fix NoMethodError when using Sidekiq v7.0 with RedisClient v0.11**

In some cases, the `RedisClient` object cannot directly access methods like db, port, or path. These methods are always available on the `client.config` object. This raised a `NoMethodError` in environments that used Sidekiq v7.0 and [RedisClient](https://rubygems.org/gems/redis-client) v0.11. Thank you to [fcheung](https://github.com/fcheung) and [@stevenou](https://github.com/stevenou) for bringing this to our attention! [Issue#1639](https://github.com/newrelic/newrelic-ruby-agent/issues/1639)
In some cases, the `RedisClient` object cannot directly access methods like db, port, or path. These methods are always available on the `client.config` object. This raised a `NoMethodError` in environments that used Sidekiq v7.0 and [RedisClient](https://rubygems.org/gems/redis-client) v0.11. Thank you to [@fcheung](https://github.com/fcheung) and [@stevenou](https://github.com/stevenou) for bringing this to our attention! [Issue#1639](https://github.com/newrelic/newrelic-ruby-agent/issues/1639)

## v8.13.0

Expand Down
2 changes: 1 addition & 1 deletion infinite_tracing/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def deferred_span(segment)
end

def reset_infinite_tracer
::NewRelic::Agent.instance.instance_variable_set(:@infinite_tracer, nil)
NewRelic::Agent.instance.instance_variable_set(:@infinite_tracer, nil)
end

CLIENT_MUTEX = Mutex.new
Expand Down
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@

NewRelic::Control.instance.init_plugin(:config => current_config)
rescue => e
::NewRelic::Agent.logger.error("Error initializing New Relic plugin. Agent is disabled.", e)
NewRelic::Agent.logger.error("Error initializing New Relic plugin. Agent is disabled.", e)
end
14 changes: 7 additions & 7 deletions lib/new_relic/agent/instrumentation/active_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
named :activejob

depends_on do
defined?(::ActiveJob::Base)
defined?(ActiveJob::Base)
end

executes do
::NewRelic::Agent.logger.info('Installing ActiveJob instrumentation')
NewRelic::Agent.logger.info('Installing ActiveJob instrumentation')

ActiveSupport.on_load(:active_job) do
::ActiveJob::Base.around_enqueue do |job, block|
::NewRelic::Agent::Instrumentation::ActiveJobHelper.enqueue(job, block)
ActiveJob::Base.around_enqueue do |job, block|
NewRelic::Agent::Instrumentation::ActiveJobHelper.enqueue(job, block)
end

::ActiveJob::Base.around_perform do |job, block|
::NewRelic::Agent::Instrumentation::ActiveJobHelper.perform(job, block)
ActiveJob::Base.around_perform do |job, block|
NewRelic::Agent::Instrumentation::ActiveJobHelper.perform(job, block)
end

::NewRelic::Agent::PrependSupportability.record_metrics_for(::ActiveJob::Base)
NewRelic::Agent::PrependSupportability.record_metrics_for(ActiveJob::Base)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/new_relic/agent/instrumentation/active_merchant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
end

executes do
::NewRelic::Agent.logger.info('Installing ActiveMerchant instrumentation')
NewRelic::Agent.logger.info('Installing ActiveMerchant instrumentation')
end

executes do
Expand Down Expand Up @@ -42,7 +42,7 @@ class ActiveMerchant::Billing::Gateway
deprecation_msg = 'The Ruby Agent is dropping support for ActiveMerchant versions below 1.65.0 ' \
'in version 9.0.0. Please upgrade your ActiveMerchant version to continue receiving full support. ' \

::NewRelic::Agent.logger.log_once(
NewRelic::Agent.logger.log_once(
:warn,
:deprecated_active_merchant_version,
deprecation_msg
Expand Down
14 changes: 7 additions & 7 deletions lib/new_relic/agent/instrumentation/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,28 @@ def log_with_newrelic_instrumentation(*args, **kwargs, &block)
@name = :active_record

depends_on do
defined?(::ActiveRecord) && defined?(::ActiveRecord::Base) &&
(!defined?(::ActiveRecord::VERSION) ||
::ActiveRecord::VERSION::MAJOR.to_i <= 3)
defined?(ActiveRecord) && defined?(ActiveRecord::Base) &&
(!defined?(ActiveRecord::VERSION) ||
ActiveRecord::VERSION::MAJOR.to_i <= 3)
end

depends_on do
!NewRelic::Agent.config[:disable_activerecord_instrumentation]
end

executes do
::NewRelic::Agent.logger.info('Installing ActiveRecord instrumentation')
NewRelic::Agent.logger.info('Installing ActiveRecord instrumentation')
end

executes do
require 'new_relic/agent/instrumentation/active_record_helper'

if defined?(::Rails::VERSION::MAJOR) && ::Rails::VERSION::MAJOR.to_i == 3
if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR.to_i == 3
ActiveSupport.on_load(:active_record) do
::NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
end
else
::NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
end
end
end
48 changes: 24 additions & 24 deletions lib/new_relic/agent/instrumentation/active_record_notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name =
named :active_record_notifications

depends_on do
defined?(::ActiveRecord) && defined?(::ActiveRecord::Base) &&
defined?(::ActiveRecord::VERSION) &&
::ActiveRecord::VERSION::MAJOR.to_i >= 4
defined?(ActiveRecord) && defined?(ActiveRecord::Base) &&
defined?(ActiveRecord::VERSION) &&
ActiveRecord::VERSION::MAJOR.to_i >= 4
end

depends_on do
Expand All @@ -95,7 +95,7 @@ def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name =
end

executes do
::NewRelic::Agent.logger.info('Installing notifications based Active Record instrumentation')
NewRelic::Agent.logger.info('Installing notifications based Active Record instrumentation')
end

executes do
Expand All @@ -105,51 +105,51 @@ def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name =

executes do
ActiveSupport.on_load(:active_record) do
::NewRelic::Agent::PrependSupportability.record_metrics_for(
::ActiveRecord::Base,
::ActiveRecord::Relation
NewRelic::Agent::PrependSupportability.record_metrics_for(
ActiveRecord::Base,
ActiveRecord::Relation
)

# Default to .prepending, unless the ActiveRecord version is <=4
# **AND** the :prepend_active_record_instrumentation config is false
if ::ActiveRecord::VERSION::MAJOR > 4 \
|| ::NewRelic::Agent.config[:prepend_active_record_instrumentation]
if ActiveRecord::VERSION::MAJOR > 4 \
|| NewRelic::Agent.config[:prepend_active_record_instrumentation]

::ActiveRecord::Base.send(:prepend,
::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions)
::ActiveRecord::Relation.send(:prepend,
::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::RelationExtensions)
ActiveRecord::Base.send(:prepend,
NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions)
ActiveRecord::Relation.send(:prepend,
NewRelic::Agent::Instrumentation::ActiveRecordPrepend::RelationExtensions)
else
::NewRelic::Agent::Instrumentation::ActiveRecordHelper.instrument_additional_methods
NewRelic::Agent::Instrumentation::ActiveRecordHelper.instrument_additional_methods
end
end
end

executes do
if NewRelic::Agent.config[:backport_fast_active_record_connection_lookup]
major_version = ::ActiveRecord::VERSION::MAJOR.to_i
minor_version = ::ActiveRecord::VERSION::MINOR.to_i
major_version = ActiveRecord::VERSION::MAJOR.to_i
minor_version = ActiveRecord::VERSION::MINOR.to_i

activerecord_extension = if major_version == 4
::NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions4x
NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions4x
elsif major_version == 5 && minor_version == 0
::NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions50
NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions50
elsif major_version == 5 && minor_version == 1
::NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions51
NewRelic::Agent::Instrumentation::ActiveRecordNotifications::BaseExtensions51
end

unless activerecord_extension.nil?
::ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:prepend, activerecord_extension)
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:prepend, activerecord_extension)
end
end
end

executes do
if ::ActiveRecord::VERSION::MAJOR == 5 \
&& ::ActiveRecord::VERSION::MINOR.to_i == 1 \
&& ::ActiveRecord::VERSION::TINY.to_i >= 6
if ActiveRecord::VERSION::MAJOR == 5 \
&& ActiveRecord::VERSION::MINOR.to_i == 1 \
&& ActiveRecord::VERSION::TINY.to_i >= 6

::ActiveRecord::Base.prepend(::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions516)
ActiveRecord::Base.prepend(NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions516)
end
end
end
4 changes: 2 additions & 2 deletions lib/new_relic/agent/instrumentation/active_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
named :active_storage

depends_on do
defined?(::ActiveStorage) &&
defined?(ActiveStorage) &&
!NewRelic::Agent::Instrumentation::ActiveStorageSubscriber.subscribed?
end

executes do
::NewRelic::Agent.logger.info('Installing ActiveStorage instrumentation')
NewRelic::Agent.logger.info('Installing ActiveStorage instrumentation')
end

executes do
Expand Down
2 changes: 1 addition & 1 deletion lib/new_relic/agent/instrumentation/active_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
# offered by the agent that would otherwise be gated by the detection of Rails.

# ActiveSupport notifications custom events
if !defined?(::Rails) && defined?(::ActiveSupport::Notifications) && defined?(::ActiveSupport::IsolatedExecutionState)
if !defined?(Rails) && defined?(ActiveSupport::Notifications) && defined?(ActiveSupport::IsolatedExecutionState)
require_relative 'rails_notifications/custom_events'
end
6 changes: 3 additions & 3 deletions lib/new_relic/agent/instrumentation/active_support_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
DependencyDetection.defer do
named :active_support_logger

depends_on { defined?(::ActiveSupport::Logger) }
depends_on { defined?(ActiveSupport::Logger) }

executes do
::NewRelic::Agent.logger.info('Installing ActiveSupport::Logger instrumentation')
NewRelic::Agent.logger.info('Installing ActiveSupport::Logger instrumentation')

if use_prepend?
# the only method currently instrumented is a class method
prepend_instrument ::ActiveSupport::Logger.singleton_class, NewRelic::Agent::Instrumentation::ActiveSupportLogger::Prepend
prepend_instrument ActiveSupport::Logger.singleton_class, NewRelic::Agent::Instrumentation::ActiveSupportLogger::Prepend
else
chain_instrument NewRelic::Agent::Instrumentation::ActiveSupportLogger::Chain
end
Expand Down
4 changes: 2 additions & 2 deletions lib/new_relic/agent/instrumentation/acts_as_solr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def parse_query_with_newrelic(*args)
end

executes do
::NewRelic::Agent.logger.info('Installing ActsAsSolr instrumentation')
NewRelic::Agent.logger.info('Installing ActsAsSolr instrumentation')
deprecation_msg = 'The instrumentation for ActsAsSolr is deprecated. ' \
'It will be removed in version 9.0.0.' \

::NewRelic::Agent.logger.log_once(
NewRelic::Agent.logger.log_once(
:warn,
:deprecated_acts_as_solr,
deprecation_msg
Expand Down
4 changes: 2 additions & 2 deletions lib/new_relic/agent/instrumentation/authlogic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
end

executes do
::NewRelic::Agent.logger.info('Installing Authlogic instrumentation')
NewRelic::Agent.logger.info('Installing Authlogic instrumentation')
deprecation_msg = 'The instrumentation for Authlogic is deprecated. ' \
'It will be removed in version 9.0.0.' \

::NewRelic::Agent.logger.log_once(
NewRelic::Agent.logger.log_once(
:warn,
:deprecated_authlogic,
deprecation_msg
Expand Down
8 changes: 4 additions & 4 deletions lib/new_relic/agent/instrumentation/bunny.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
end

executes do
::NewRelic::Agent.logger.info('Installing Bunny instrumentation')
NewRelic::Agent.logger.info('Installing Bunny instrumentation')
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
require 'new_relic/agent/messaging'
require 'new_relic/agent/transaction/message_broker_segment'
end

executes do
if use_prepend?
prepend_instrument ::Bunny::Exchange, ::NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange
prepend_instrument ::Bunny::Queue, ::NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue
prepend_instrument ::Bunny::Consumer, ::NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer
prepend_instrument Bunny::Exchange, NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange
prepend_instrument Bunny::Queue, NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue
prepend_instrument Bunny::Consumer, NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer
else
chain_instrument NewRelic::Agent::Instrumentation::Bunny
end
Expand Down
12 changes: 6 additions & 6 deletions lib/new_relic/agent/instrumentation/curb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
CURB_MIN_VERSION = Gem::Version.new("0.8.1")

depends_on do
defined?(::Curl) && defined?(::Curl::CURB_VERSION) &&
Gem::Version.new(::Curl::CURB_VERSION) >= CURB_MIN_VERSION
defined?(Curl) && defined?(Curl::CURB_VERSION) &&
Gem::Version.new(Curl::CURB_VERSION) >= CURB_MIN_VERSION
end

executes do
::NewRelic::Agent.logger.info('Installing Curb instrumentation')
NewRelic::Agent.logger.info('Installing Curb instrumentation')
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
require 'new_relic/agent/http_clients/curb_wrappers'
end

executes do
if use_prepend?
prepend_instrument ::Curl::Easy, NewRelic::Agent::Instrumentation::Curb::Easy::Prepend
prepend_instrument ::Curl::Multi, NewRelic::Agent::Instrumentation::Curb::Multi::Prepend
prepend_instrument Curl::Easy, NewRelic::Agent::Instrumentation::Curb::Easy::Prepend
prepend_instrument Curl::Multi, NewRelic::Agent::Instrumentation::Curb::Multi::Prepend
else
chain_instrument ::NewRelic::Agent::Instrumentation::Curb::Chain
chain_instrument NewRelic::Agent::Instrumentation::Curb::Chain
end
end
end
Loading

0 comments on commit 00e04a0

Please sign in to comment.