newrelic_rpm 8.13.1 → 8.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.rubocop.yml +130 -1
- data/.rubocop_todo.yml +3 -0
- data/CHANGELOG.md +3284 -3148
- data/CONTRIBUTING.md +1 -2
- data/README.md +2 -1
- data/init.rb +1 -1
- data/lib/new_relic/agent/agent.rb +14 -466
- data/lib/new_relic/agent/agent_helpers/connect.rb +227 -0
- data/lib/new_relic/agent/agent_helpers/harvest.rb +153 -0
- data/lib/new_relic/agent/agent_helpers/shutdown.rb +72 -0
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +75 -0
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +167 -0
- data/lib/new_relic/agent/agent_helpers/startup.rb +202 -0
- data/lib/new_relic/agent/agent_helpers/transmit.rb +76 -0
- data/lib/new_relic/agent/configuration/default_source.rb +47 -9
- data/lib/new_relic/agent/datastores.rb +2 -2
- data/lib/new_relic/agent/event_loop.rb +1 -1
- data/lib/new_relic/agent/guid_generator.rb +11 -2
- data/lib/new_relic/agent/heap.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_job.rb +7 -7
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +9 -9
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +24 -24
- data/lib/new_relic/agent/instrumentation/active_storage.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_support.rb +12 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -3
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +2 -2
- data/lib/new_relic/agent/instrumentation/authlogic.rb +2 -2
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/bunny.rb +4 -4
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +36 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +21 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +27 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +31 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb.rb +6 -6
- data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +37 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +50 -50
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +5 -5
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +1 -1
- data/lib/new_relic/agent/instrumentation/excon.rb +9 -9
- data/lib/new_relic/agent/instrumentation/grape.rb +8 -8
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +3 -3
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +4 -4
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httprb.rb +3 -3
- data/lib/new_relic/agent/instrumentation/logger.rb +3 -3
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/memcache.rb +16 -16
- data/lib/new_relic/agent/instrumentation/mongo.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net_http.rb +6 -6
- data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rack.rb +14 -14
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb +5 -3
- data/lib/new_relic/agent/instrumentation/rails_notifications/custom_events.rb +30 -0
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rake.rb +7 -7
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +29 -8
- data/lib/new_relic/agent/instrumentation/redis.rb +4 -4
- data/lib/new_relic/agent/instrumentation/resque.rb +9 -9
- data/lib/new_relic/agent/instrumentation/sequel.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sinatra.rb +7 -7
- data/lib/new_relic/agent/instrumentation/sunspot.rb +4 -4
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/thread.rb +3 -3
- data/lib/new_relic/agent/instrumentation/tilt.rb +3 -3
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +2 -2
- data/lib/new_relic/agent/method_tracer_helpers.rb +6 -11
- data/lib/new_relic/agent/range_extensions.rb +2 -2
- data/lib/new_relic/agent/tracer.rb +8 -4
- data/lib/new_relic/agent/transaction/abstract_segment.rb +2 -2
- data/lib/new_relic/agent/transaction/segment.rb +6 -0
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +3 -3
- data/lib/new_relic/agent.rb +7 -0
- data/lib/new_relic/control/instance_methods.rb +6 -2
- data/lib/new_relic/helper.rb +1 -1
- data/lib/new_relic/recipes/helpers/send_deployment.rb +2 -1
- data/lib/new_relic/traced_thread.rb +5 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +13 -2
- data/lib/sequel/extensions/newrelic_instrumentation.rb +1 -1
- data/lib/sequel/plugins/newrelic_instrumentation.rb +1 -1
- data/newrelic.yml +23 -5
- data/test/agent_helper.rb +7 -7
- metadata +16 -6
- data/lib/new_relic/agent/agent/shutdown.rb +0 -35
- data/lib/new_relic/agent/agent/special_startup.rb +0 -72
- data/lib/new_relic/agent/agent/start_worker_thread.rb +0 -163
- data/lib/new_relic/agent/agent/startup.rb +0 -197
@@ -8,12 +8,12 @@ DependencyDetection.defer do
|
|
8
8
|
named :active_storage
|
9
9
|
|
10
10
|
depends_on do
|
11
|
-
defined?(
|
11
|
+
defined?(ActiveStorage) &&
|
12
12
|
!NewRelic::Agent::Instrumentation::ActiveStorageSubscriber.subscribed?
|
13
13
|
end
|
14
14
|
|
15
15
|
executes do
|
16
|
-
|
16
|
+
NewRelic::Agent.logger.info('Installing ActiveStorage instrumentation')
|
17
17
|
end
|
18
18
|
|
19
19
|
executes do
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
# This is a helper file that will allow apps using ActiveSupport without Rails
|
6
|
+
# to still leverage all ActiveSupport based instrumentation functionality
|
7
|
+
# offered by the agent that would otherwise be gated by the detection of Rails.
|
8
|
+
|
9
|
+
# ActiveSupport notifications custom events
|
10
|
+
if !defined?(Rails) && defined?(ActiveSupport::Notifications) && defined?(ActiveSupport::IsolatedExecutionState)
|
11
|
+
require_relative 'rails_notifications/custom_events'
|
12
|
+
end
|
@@ -9,14 +9,14 @@ require_relative 'active_support_logger/prepend'
|
|
9
9
|
DependencyDetection.defer do
|
10
10
|
named :active_support_logger
|
11
11
|
|
12
|
-
depends_on { defined?(
|
12
|
+
depends_on { defined?(ActiveSupport::Logger) }
|
13
13
|
|
14
14
|
executes do
|
15
|
-
|
15
|
+
NewRelic::Agent.logger.info('Installing ActiveSupport::Logger instrumentation')
|
16
16
|
|
17
17
|
if use_prepend?
|
18
18
|
# the only method currently instrumented is a class method
|
19
|
-
prepend_instrument
|
19
|
+
prepend_instrument ActiveSupport::Logger.singleton_class, NewRelic::Agent::Instrumentation::ActiveSupportLogger::Prepend
|
20
20
|
else
|
21
21
|
chain_instrument NewRelic::Agent::Instrumentation::ActiveSupportLogger::Chain
|
22
22
|
end
|
@@ -44,11 +44,11 @@ DependencyDetection.defer do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
executes do
|
47
|
-
|
47
|
+
NewRelic::Agent.logger.info('Installing ActsAsSolr instrumentation')
|
48
48
|
deprecation_msg = 'The instrumentation for ActsAsSolr is deprecated. ' \
|
49
49
|
'It will be removed in version 9.0.0.' \
|
50
50
|
|
51
|
-
|
51
|
+
NewRelic::Agent.logger.log_once(
|
52
52
|
:warn,
|
53
53
|
:deprecated_acts_as_solr,
|
54
54
|
deprecation_msg
|
@@ -12,11 +12,11 @@ DependencyDetection.defer do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
executes do
|
15
|
-
|
15
|
+
NewRelic::Agent.logger.info('Installing Authlogic instrumentation')
|
16
16
|
deprecation_msg = 'The instrumentation for Authlogic is deprecated. ' \
|
17
17
|
'It will be removed in version 9.0.0.' \
|
18
18
|
|
19
|
-
|
19
|
+
NewRelic::Agent.logger.log_once(
|
20
20
|
:warn,
|
21
21
|
:deprecated_authlogic,
|
22
22
|
deprecation_msg
|
@@ -53,7 +53,7 @@ module NewRelic
|
|
53
53
|
yield
|
54
54
|
end
|
55
55
|
ensure
|
56
|
-
|
56
|
+
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -97,7 +97,7 @@ module NewRelic
|
|
97
97
|
raise bunny_error
|
98
98
|
end
|
99
99
|
ensure
|
100
|
-
|
100
|
+
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
101
101
|
end
|
102
102
|
|
103
103
|
msg
|
@@ -120,7 +120,7 @@ module NewRelic
|
|
120
120
|
yield
|
121
121
|
end
|
122
122
|
ensure
|
123
|
-
|
123
|
+
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -14,7 +14,7 @@ DependencyDetection.defer do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
executes do
|
17
|
-
|
17
|
+
NewRelic::Agent.logger.info('Installing Bunny instrumentation')
|
18
18
|
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
19
19
|
require 'new_relic/agent/messaging'
|
20
20
|
require 'new_relic/agent/transaction/message_broker_segment'
|
@@ -22,9 +22,9 @@ DependencyDetection.defer do
|
|
22
22
|
|
23
23
|
executes do
|
24
24
|
if use_prepend?
|
25
|
-
prepend_instrument
|
26
|
-
prepend_instrument
|
27
|
-
prepend_instrument
|
25
|
+
prepend_instrument Bunny::Exchange, NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange
|
26
|
+
prepend_instrument Bunny::Queue, NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue
|
27
|
+
prepend_instrument Bunny::Consumer, NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer
|
28
28
|
else
|
29
29
|
chain_instrument NewRelic::Agent::Instrumentation::Bunny
|
30
30
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module ConcurrentRuby::Chain
|
7
|
+
def self.instrument!
|
8
|
+
::Concurrent::ThreadPoolExecutor.class_eval do
|
9
|
+
include NewRelic::Agent::Instrumentation::ConcurrentRuby
|
10
|
+
|
11
|
+
alias_method(:post_without_new_relic, :post)
|
12
|
+
|
13
|
+
def post(*args, &task)
|
14
|
+
return post_without_new_relic(*args, &task) unless NewRelic::Agent::Tracer.tracing_enabled?
|
15
|
+
|
16
|
+
traced_task = add_task_tracing(*args, &task)
|
17
|
+
post_without_new_relic(*args, &traced_task)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
[::Concurrent::Promises.const_get(:'InternalStates')::Rejected,
|
22
|
+
::Concurrent::Promises.const_get(:'InternalStates')::PartiallyRejected].each do |klass|
|
23
|
+
klass.class_eval do
|
24
|
+
alias_method(:initialize_without_new_relic, :initialize)
|
25
|
+
|
26
|
+
# Uses args.last to record the error becuase the methods that this will monkey patch
|
27
|
+
# look like: initialize(reason) & initialize(value, reason)
|
28
|
+
def initialize(*args)
|
29
|
+
NewRelic::Agent.notice_error(args.last) if args.last.is_a?(Exception)
|
30
|
+
initialize_without_new_relic(*args)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module ConcurrentRuby
|
7
|
+
SEGMENT_NAME = 'Concurrent/Task'
|
8
|
+
SUPPORTABILITY_METRIC = 'Supportability/ConcurrentRuby/Invoked'
|
9
|
+
|
10
|
+
def add_task_tracing(*args, &task)
|
11
|
+
NewRelic::Agent.record_metric_once(SUPPORTABILITY_METRIC)
|
12
|
+
|
13
|
+
NewRelic::Agent::Tracer.thread_block_with_current_transaction(
|
14
|
+
*args,
|
15
|
+
segment_name: SEGMENT_NAME,
|
16
|
+
parent: NewRelic::Agent::Tracer.current_segment,
|
17
|
+
&task
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module ConcurrentRuby
|
7
|
+
module Prepend
|
8
|
+
include NewRelic::Agent::Instrumentation::ConcurrentRuby
|
9
|
+
|
10
|
+
def post(*args, &task)
|
11
|
+
return super(*args, &task) unless NewRelic::Agent::Tracer.tracing_enabled?
|
12
|
+
|
13
|
+
traced_task = add_task_tracing(*args, &task)
|
14
|
+
super(*args, &traced_task)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module ErrorPrepend
|
19
|
+
# Uses args.last to record the error because the methods that this will be prepended to
|
20
|
+
# look like: initialize(reason) & initialize(value, reason)
|
21
|
+
def initialize(*args)
|
22
|
+
NewRelic::Agent.notice_error(args.last) if args.last.is_a?(Exception)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative 'concurrent_ruby/instrumentation'
|
6
|
+
require_relative 'concurrent_ruby/chain'
|
7
|
+
require_relative 'concurrent_ruby/prepend'
|
8
|
+
|
9
|
+
DependencyDetection.defer do
|
10
|
+
named :'concurrent_ruby'
|
11
|
+
|
12
|
+
depends_on do
|
13
|
+
defined?(Concurrent) &&
|
14
|
+
Gem::Version.new(Concurrent::VERSION) >= Gem::Version.new('1.1.5')
|
15
|
+
end
|
16
|
+
|
17
|
+
executes do
|
18
|
+
NewRelic::Agent.logger.info('Installing concurrent-ruby instrumentation')
|
19
|
+
|
20
|
+
if use_prepend?
|
21
|
+
prepend_instrument(Concurrent::ThreadPoolExecutor, NewRelic::Agent::Instrumentation::ConcurrentRuby::Prepend)
|
22
|
+
|
23
|
+
[Concurrent::Promises.const_get(:'InternalStates')::Rejected,
|
24
|
+
Concurrent::Promises.const_get(:'InternalStates')::PartiallyRejected].each do |klass|
|
25
|
+
klass.prepend(NewRelic::Agent::Instrumentation::ConcurrentRuby::ErrorPrepend)
|
26
|
+
end
|
27
|
+
else
|
28
|
+
chain_instrument NewRelic::Agent::Instrumentation::ConcurrentRuby::Chain
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -340,7 +340,7 @@ module NewRelic
|
|
340
340
|
#
|
341
341
|
# Seldomly used options:
|
342
342
|
#
|
343
|
-
# * <tt>:class_name =>
|
343
|
+
# * <tt>:class_name => Class.name</tt> is used to override the name
|
344
344
|
# of the class when used inside the metric name. Default is the
|
345
345
|
# current class.
|
346
346
|
# * <tt>:path => metric_path</tt> is *deprecated* in the public API. It
|
@@ -143,7 +143,7 @@ module NewRelic
|
|
143
143
|
begin
|
144
144
|
segment.process_response_headers(wrapped_response) if segment
|
145
145
|
ensure
|
146
|
-
|
146
|
+
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
147
147
|
# Make sure the existing completion callback is run, and restore the
|
148
148
|
# on_complete callback to how it was before.
|
149
149
|
original_callback.call(finished_request) if original_callback
|
@@ -11,22 +11,22 @@ DependencyDetection.defer do
|
|
11
11
|
CURB_MIN_VERSION = Gem::Version.new("0.8.1")
|
12
12
|
|
13
13
|
depends_on do
|
14
|
-
defined?(
|
15
|
-
Gem::Version.new(
|
14
|
+
defined?(Curl) && defined?(Curl::CURB_VERSION) &&
|
15
|
+
Gem::Version.new(Curl::CURB_VERSION) >= CURB_MIN_VERSION
|
16
16
|
end
|
17
17
|
|
18
18
|
executes do
|
19
|
-
|
19
|
+
NewRelic::Agent.logger.info('Installing Curb instrumentation')
|
20
20
|
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
21
21
|
require 'new_relic/agent/http_clients/curb_wrappers'
|
22
22
|
end
|
23
23
|
|
24
24
|
executes do
|
25
25
|
if use_prepend?
|
26
|
-
prepend_instrument
|
27
|
-
prepend_instrument
|
26
|
+
prepend_instrument Curl::Easy, NewRelic::Agent::Instrumentation::Curb::Easy::Prepend
|
27
|
+
prepend_instrument Curl::Multi, NewRelic::Agent::Instrumentation::Curb::Multi::Prepend
|
28
28
|
else
|
29
|
-
chain_instrument
|
29
|
+
chain_instrument NewRelic::Agent::Instrumentation::Curb::Chain
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'new_relic/agent/instrumentation/notifications_subscriber'
|
6
|
+
|
7
|
+
# Listen for ActiveSupport::Notifications events for custom events
|
8
|
+
module NewRelic::Agent::Instrumentation
|
9
|
+
class CustomEventsSubscriber < NotificationsSubscriber
|
10
|
+
def start(name, id, _payload) # THREAD_LOCAL_ACCESS
|
11
|
+
return unless state.is_execution_traced?
|
12
|
+
|
13
|
+
finishable = NewRelic::Agent::Tracer.start_transaction_or_segment(name: transaction_name(name),
|
14
|
+
category: :custom_events)
|
15
|
+
push_segment(id, finishable)
|
16
|
+
rescue => e
|
17
|
+
log_notification_error(e, name, 'start')
|
18
|
+
end
|
19
|
+
|
20
|
+
def finish(name, id, payload) # THREAD_LOCAL_ACCESS
|
21
|
+
return unless state.is_execution_traced?
|
22
|
+
|
23
|
+
NewRelic::Agent.notice_error(payload[:exception_object]) if payload.key?(:exception_object)
|
24
|
+
|
25
|
+
finishable = pop_segment(id)
|
26
|
+
finishable.finish if finishable
|
27
|
+
rescue => e
|
28
|
+
log_notification_error(e, name, 'finish')
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def transaction_name(name)
|
34
|
+
"ActiveSupport/CustomEvents/#{name}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -6,14 +6,14 @@ DependencyDetection.defer do
|
|
6
6
|
named :data_mapper
|
7
7
|
|
8
8
|
depends_on do
|
9
|
-
defined?(
|
10
|
-
defined?(
|
11
|
-
defined?(
|
12
|
-
defined?(
|
9
|
+
defined?(DataMapper) &&
|
10
|
+
defined?(DataMapper::Model) &&
|
11
|
+
defined?(DataMapper::Resource) &&
|
12
|
+
defined?(DataMapper::Collection)
|
13
13
|
end
|
14
14
|
|
15
15
|
executes do
|
16
|
-
|
16
|
+
NewRelic::Agent.logger.info('Installing DataMapper instrumentation')
|
17
17
|
require 'new_relic/agent/datastores/metric_helper'
|
18
18
|
|
19
19
|
deprecation_msg = 'The instrumentation for DataMapper is deprecated. ' \
|
@@ -21,7 +21,7 @@ DependencyDetection.defer do
|
|
21
21
|
'Visit https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks ' \
|
22
22
|
'to learn about supported gems.'
|
23
23
|
|
24
|
-
|
24
|
+
NewRelic::Agent.logger.log_once(
|
25
25
|
:warn,
|
26
26
|
:deprecated_datamapper,
|
27
27
|
deprecation_msg
|
@@ -29,76 +29,76 @@ DependencyDetection.defer do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
executes do
|
32
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
33
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
34
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
35
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
36
|
-
|
37
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
38
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
39
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
40
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
41
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
42
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
43
|
-
|
44
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
45
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
46
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
32
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :get)
|
33
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :first)
|
34
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :last)
|
35
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :all)
|
36
|
+
|
37
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :create)
|
38
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :create!)
|
39
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :update)
|
40
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :update!)
|
41
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :destroy)
|
42
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :destroy!)
|
43
|
+
|
44
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :aggregate)
|
45
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :find)
|
46
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :find_by_sql)
|
47
47
|
end
|
48
48
|
|
49
49
|
executes do
|
50
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
51
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
52
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
53
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
54
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
55
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
50
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :update)
|
51
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :update!)
|
52
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :save)
|
53
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :save!)
|
54
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :destroy)
|
55
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :destroy!)
|
56
56
|
end
|
57
57
|
|
58
58
|
executes do
|
59
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
60
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
61
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
62
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
59
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :get)
|
60
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :first)
|
61
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :last)
|
62
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :all)
|
63
63
|
|
64
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
64
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :lazy_load)
|
65
65
|
|
66
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
67
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
68
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
69
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
70
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
71
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
66
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :create)
|
67
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :create!)
|
68
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :update)
|
69
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :update!)
|
70
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :destroy)
|
71
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :destroy!)
|
72
72
|
|
73
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
73
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :aggregate)
|
74
74
|
end
|
75
75
|
|
76
76
|
executes do
|
77
77
|
# Catch direct SQL calls that bypass CRUD
|
78
|
-
if defined?(
|
79
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
80
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
78
|
+
if defined?(DataMapper::Adapters::DataObjectsAdapter)
|
79
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Adapters::DataObjectsAdapter, :select, true)
|
80
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Adapters::DataObjectsAdapter, :execute, true)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
executes do
|
85
85
|
# DM::Validations overrides Model#create, so we patch it here as well
|
86
|
-
if defined?(
|
87
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
86
|
+
if defined?(DataMapper::Validations::ClassMethods)
|
87
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Validations::ClassMethods, :create)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
executes do
|
92
92
|
# DM::Transaction calls commit() twice, so potentially shows up twice.
|
93
|
-
if defined?(
|
94
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(
|
93
|
+
if defined?(DataMapper::Transaction)
|
94
|
+
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Transaction, :commit, true)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
executes do
|
99
|
-
if defined?(
|
100
|
-
|
101
|
-
include
|
99
|
+
if defined?(DataObjects::Connection)
|
100
|
+
DataObjects::Connection.class_eval do
|
101
|
+
include NewRelic::Agent::Instrumentation::DataMapperInstrumentation
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
@@ -181,7 +181,7 @@ module NewRelic
|
|
181
181
|
|
182
182
|
raise
|
183
183
|
ensure
|
184
|
-
|
184
|
+
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
@@ -79,18 +79,18 @@ DependencyDetection.defer do
|
|
79
79
|
@name = :delayed_job
|
80
80
|
|
81
81
|
depends_on do
|
82
|
-
defined?(
|
82
|
+
defined?(Delayed) && defined?(Delayed::Worker)
|
83
83
|
end
|
84
84
|
|
85
85
|
executes do
|
86
|
-
|
86
|
+
NewRelic::Agent.logger.info('Installing DelayedJob instrumentation [part 1/2]')
|
87
87
|
end
|
88
88
|
|
89
89
|
executes do
|
90
90
|
if use_prepend?
|
91
|
-
prepend_instrument
|
91
|
+
prepend_instrument Delayed::Worker, NewRelic::Agent::Instrumentation::DelayedJob::Prepend
|
92
92
|
else
|
93
|
-
chain_instrument
|
93
|
+
chain_instrument NewRelic::Agent::Instrumentation::DelayedJob::Chain
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -101,7 +101,7 @@ DependencyDetection.defer do
|
|
101
101
|
'It will stop being monitored in version 9.0.0. ' \
|
102
102
|
'Please upgrade your DelayedJob version to continue receiving full support. ' \
|
103
103
|
|
104
|
-
|
104
|
+
NewRelic::Agent.logger.log_once(
|
105
105
|
:warn,
|
106
106
|
:deprecated_delayed_job_version,
|
107
107
|
deprecation_msg
|
@@ -10,16 +10,16 @@ DependencyDetection.defer do
|
|
10
10
|
named :elasticsearch
|
11
11
|
|
12
12
|
depends_on do
|
13
|
-
defined?(
|
13
|
+
defined?(Elasticsearch)
|
14
14
|
end
|
15
15
|
|
16
16
|
executes do
|
17
|
-
|
17
|
+
NewRelic::Agent.logger.info('Installing Elasticsearch instrumentation')
|
18
18
|
|
19
|
-
to_instrument = if
|
20
|
-
|
19
|
+
to_instrument = if Gem::Version.create(Elasticsearch::VERSION) < Gem::Version.create("8.0.0")
|
20
|
+
Elasticsearch::Transport::Client
|
21
21
|
else
|
22
|
-
|
22
|
+
Elastic::Transport::Client
|
23
23
|
end
|
24
24
|
|
25
25
|
if use_prepend?
|
@@ -21,32 +21,32 @@ DependencyDetection.defer do
|
|
21
21
|
EXCON_MIN_VERSION = Gem::Version.new("0.19.0")
|
22
22
|
|
23
23
|
depends_on do
|
24
|
-
defined?(
|
24
|
+
defined?(Excon) && defined?(Excon::VERSION)
|
25
25
|
end
|
26
26
|
|
27
27
|
executes do
|
28
|
-
excon_version = Gem::Version.new(
|
28
|
+
excon_version = Gem::Version.new(Excon::VERSION)
|
29
29
|
if excon_version >= EXCON_MIN_VERSION
|
30
30
|
install_excon_instrumentation(excon_version)
|
31
31
|
else
|
32
|
-
|
32
|
+
NewRelic::Agent.logger.warn("Excon instrumentation requires at least version #{EXCON_MIN_VERSION}")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
executes do
|
37
|
-
next unless Gem::Version.new(
|
37
|
+
next unless Gem::Version.new(Excon::VERSION) < Gem::Version.new('0.56.0')
|
38
38
|
|
39
39
|
deprecation_msg = 'Instrumentation for Excon versions below 0.56.0 is deprecated.' \
|
40
40
|
'They will stop being monitored in version 9.0.0. ' \
|
41
41
|
'Please upgrade your Excon version to continue receiving full support. '
|
42
42
|
|
43
|
-
|
43
|
+
NewRelic::Agent.logger.log_once(
|
44
44
|
:warn,
|
45
45
|
:deprecated_excon_version,
|
46
46
|
deprecation_msg
|
47
47
|
)
|
48
48
|
|
49
|
-
|
49
|
+
NewRelic::Agent.record_metric("Supportability/Deprecated/Excon", 1)
|
50
50
|
end
|
51
51
|
|
52
52
|
def install_excon_instrumentation(excon_version)
|
@@ -57,14 +57,14 @@ DependencyDetection.defer do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def install_middleware_excon_instrumentation
|
60
|
-
|
60
|
+
NewRelic::Agent.logger.info('Installing middleware-based Excon instrumentation')
|
61
61
|
require 'new_relic/agent/instrumentation/excon/middleware'
|
62
62
|
defaults = Excon.defaults
|
63
63
|
|
64
64
|
if defaults[:middlewares]
|
65
|
-
defaults[:middlewares] <<
|
65
|
+
defaults[:middlewares] << Excon::Middleware::NewRelicCrossAppTracing
|
66
66
|
else
|
67
|
-
|
67
|
+
NewRelic::Agent.logger.warn("Did not find :middlewares key in Excon.defaults, skipping Excon instrumentation")
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|