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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +130 -1
  4. data/.rubocop_todo.yml +3 -0
  5. data/CHANGELOG.md +3284 -3148
  6. data/CONTRIBUTING.md +1 -2
  7. data/README.md +2 -1
  8. data/init.rb +1 -1
  9. data/lib/new_relic/agent/agent.rb +14 -466
  10. data/lib/new_relic/agent/agent_helpers/connect.rb +227 -0
  11. data/lib/new_relic/agent/agent_helpers/harvest.rb +153 -0
  12. data/lib/new_relic/agent/agent_helpers/shutdown.rb +72 -0
  13. data/lib/new_relic/agent/agent_helpers/special_startup.rb +75 -0
  14. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +167 -0
  15. data/lib/new_relic/agent/agent_helpers/startup.rb +202 -0
  16. data/lib/new_relic/agent/agent_helpers/transmit.rb +76 -0
  17. data/lib/new_relic/agent/configuration/default_source.rb +47 -9
  18. data/lib/new_relic/agent/datastores.rb +2 -2
  19. data/lib/new_relic/agent/event_loop.rb +1 -1
  20. data/lib/new_relic/agent/guid_generator.rb +11 -2
  21. data/lib/new_relic/agent/heap.rb +1 -1
  22. data/lib/new_relic/agent/instrumentation/active_job.rb +7 -7
  23. data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
  24. data/lib/new_relic/agent/instrumentation/active_record.rb +9 -9
  25. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +24 -24
  26. data/lib/new_relic/agent/instrumentation/active_storage.rb +2 -2
  27. data/lib/new_relic/agent/instrumentation/active_support.rb +12 -0
  28. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -3
  29. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +2 -2
  30. data/lib/new_relic/agent/instrumentation/authlogic.rb +2 -2
  31. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +3 -3
  32. data/lib/new_relic/agent/instrumentation/bunny.rb +4 -4
  33. data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +36 -0
  34. data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +21 -0
  35. data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +27 -0
  36. data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +31 -0
  37. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
  38. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +1 -1
  39. data/lib/new_relic/agent/instrumentation/curb.rb +6 -6
  40. data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +37 -0
  41. data/lib/new_relic/agent/instrumentation/data_mapper.rb +50 -50
  42. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +5 -5
  43. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +5 -5
  44. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +1 -1
  45. data/lib/new_relic/agent/instrumentation/excon.rb +9 -9
  46. data/lib/new_relic/agent/instrumentation/grape.rb +8 -8
  47. data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +1 -1
  48. data/lib/new_relic/agent/instrumentation/grpc_client.rb +3 -3
  49. data/lib/new_relic/agent/instrumentation/grpc_server.rb +4 -4
  50. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +1 -1
  51. data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
  52. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +1 -1
  53. data/lib/new_relic/agent/instrumentation/httprb.rb +3 -3
  54. data/lib/new_relic/agent/instrumentation/logger.rb +3 -3
  55. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +3 -3
  56. data/lib/new_relic/agent/instrumentation/memcache.rb +16 -16
  57. data/lib/new_relic/agent/instrumentation/mongo.rb +1 -1
  58. data/lib/new_relic/agent/instrumentation/net_http.rb +6 -6
  59. data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
  60. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +5 -5
  61. data/lib/new_relic/agent/instrumentation/rack.rb +14 -14
  62. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -5
  63. data/lib/new_relic/agent/instrumentation/rails_middleware.rb +3 -3
  64. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +6 -6
  65. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +2 -2
  66. data/lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb +5 -3
  67. data/lib/new_relic/agent/instrumentation/rails_notifications/custom_events.rb +30 -0
  68. data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +4 -4
  69. data/lib/new_relic/agent/instrumentation/rake.rb +7 -7
  70. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +29 -8
  71. data/lib/new_relic/agent/instrumentation/redis.rb +4 -4
  72. data/lib/new_relic/agent/instrumentation/resque.rb +9 -9
  73. data/lib/new_relic/agent/instrumentation/sequel.rb +2 -2
  74. data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -3
  75. data/lib/new_relic/agent/instrumentation/sinatra.rb +7 -7
  76. data/lib/new_relic/agent/instrumentation/sunspot.rb +4 -4
  77. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +5 -1
  78. data/lib/new_relic/agent/instrumentation/thread.rb +3 -3
  79. data/lib/new_relic/agent/instrumentation/tilt.rb +3 -3
  80. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +2 -2
  81. data/lib/new_relic/agent/instrumentation/typhoeus.rb +1 -1
  82. data/lib/new_relic/agent/javascript_instrumentor.rb +2 -2
  83. data/lib/new_relic/agent/method_tracer_helpers.rb +6 -11
  84. data/lib/new_relic/agent/range_extensions.rb +2 -2
  85. data/lib/new_relic/agent/tracer.rb +8 -4
  86. data/lib/new_relic/agent/transaction/abstract_segment.rb +2 -2
  87. data/lib/new_relic/agent/transaction/segment.rb +6 -0
  88. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
  89. data/lib/new_relic/agent/transaction.rb +3 -3
  90. data/lib/new_relic/agent.rb +7 -0
  91. data/lib/new_relic/control/instance_methods.rb +6 -2
  92. data/lib/new_relic/helper.rb +1 -1
  93. data/lib/new_relic/recipes/helpers/send_deployment.rb +2 -1
  94. data/lib/new_relic/traced_thread.rb +5 -1
  95. data/lib/new_relic/version.rb +2 -2
  96. data/lib/newrelic_rpm.rb +13 -2
  97. data/lib/sequel/extensions/newrelic_instrumentation.rb +1 -1
  98. data/lib/sequel/plugins/newrelic_instrumentation.rb +1 -1
  99. data/newrelic.yml +23 -5
  100. data/test/agent_helper.rb +7 -7
  101. metadata +16 -6
  102. data/lib/new_relic/agent/agent/shutdown.rb +0 -35
  103. data/lib/new_relic/agent/agent/special_startup.rb +0 -72
  104. data/lib/new_relic/agent/agent/start_worker_thread.rb +0 -163
  105. 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?(::ActiveStorage) &&
11
+ defined?(ActiveStorage) &&
12
12
  !NewRelic::Agent::Instrumentation::ActiveStorageSubscriber.subscribed?
13
13
  end
14
14
 
15
15
  executes do
16
- ::NewRelic::Agent.logger.info('Installing ActiveStorage instrumentation')
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?(::ActiveSupport::Logger) }
12
+ depends_on { defined?(ActiveSupport::Logger) }
13
13
 
14
14
  executes do
15
- ::NewRelic::Agent.logger.info('Installing ActiveSupport::Logger instrumentation')
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 ::ActiveSupport::Logger.singleton_class, NewRelic::Agent::Instrumentation::ActiveSupportLogger::Prepend
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
- ::NewRelic::Agent.logger.info('Installing ActsAsSolr instrumentation')
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
- ::NewRelic::Agent.logger.log_once(
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
- ::NewRelic::Agent.logger.info('Installing Authlogic instrumentation')
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
- ::NewRelic::Agent.logger.log_once(
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
- segment.finish if segment
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
- segment.finish if segment
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
- segment.finish if segment
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
- ::NewRelic::Agent.logger.info('Installing Bunny instrumentation')
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 ::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
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 => aClass.name</tt> is used to override the 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
- segment.finish if segment
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?(::Curl) && defined?(::Curl::CURB_VERSION) &&
15
- Gem::Version.new(::Curl::CURB_VERSION) >= CURB_MIN_VERSION
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
- ::NewRelic::Agent.logger.info('Installing Curb instrumentation')
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 ::Curl::Easy, NewRelic::Agent::Instrumentation::Curb::Easy::Prepend
27
- prepend_instrument ::Curl::Multi, NewRelic::Agent::Instrumentation::Curb::Multi::Prepend
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 ::NewRelic::Agent::Instrumentation::Curb::Chain
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?(::DataMapper) &&
10
- defined?(::DataMapper::Model) &&
11
- defined?(::DataMapper::Resource) &&
12
- defined?(::DataMapper::Collection)
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
- ::NewRelic::Agent.logger.info('Installing DataMapper instrumentation')
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
- ::NewRelic::Agent.logger.log_once(
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(::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)
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(::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!)
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(::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)
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(::DataMapper::Collection, :lazy_load)
64
+ NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :lazy_load)
65
65
 
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!)
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(::DataMapper::Collection, :aggregate)
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?(::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)
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?(::DataMapper::Validations::ClassMethods)
87
- NewRelic::Agent::DataMapperTracing.add_tracer(::DataMapper::Validations::ClassMethods, :create)
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?(::DataMapper::Transaction)
94
- NewRelic::Agent::DataMapperTracing.add_tracer(::DataMapper::Transaction, :commit, true)
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?(::DataObjects::Connection)
100
- ::DataObjects::Connection.class_eval do
101
- include ::NewRelic::Agent::Instrumentation::DataMapperInstrumentation
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
- segment.finish if segment
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?(::Delayed) && defined?(::Delayed::Worker)
82
+ defined?(Delayed) && defined?(Delayed::Worker)
83
83
  end
84
84
 
85
85
  executes do
86
- ::NewRelic::Agent.logger.info('Installing DelayedJob instrumentation [part 1/2]')
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 ::Delayed::Worker, ::NewRelic::Agent::Instrumentation::DelayedJob::Prepend
91
+ prepend_instrument Delayed::Worker, NewRelic::Agent::Instrumentation::DelayedJob::Prepend
92
92
  else
93
- chain_instrument ::NewRelic::Agent::Instrumentation::DelayedJob::Chain
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
- ::NewRelic::Agent.logger.log_once(
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?(::Elasticsearch)
13
+ defined?(Elasticsearch)
14
14
  end
15
15
 
16
16
  executes do
17
- ::NewRelic::Agent.logger.info('Installing Elasticsearch instrumentation')
17
+ NewRelic::Agent.logger.info('Installing Elasticsearch instrumentation')
18
18
 
19
- to_instrument = if ::Gem::Version.create(::Elasticsearch::VERSION) < ::Gem::Version.create("8.0.0")
20
- ::Elasticsearch::Transport::Client
19
+ to_instrument = if Gem::Version.create(Elasticsearch::VERSION) < Gem::Version.create("8.0.0")
20
+ Elasticsearch::Transport::Client
21
21
  else
22
- ::Elastic::Transport::Client
22
+ Elastic::Transport::Client
23
23
  end
24
24
 
25
25
  if use_prepend?
@@ -57,7 +57,7 @@ module ::Excon
57
57
  segment.process_response_headers(wrapped_response)
58
58
  end
59
59
  ensure
60
- segment.finish if segment
60
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
61
61
  end
62
62
  end
63
63
  end
@@ -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?(::Excon) && defined?(::Excon::VERSION)
24
+ defined?(Excon) && defined?(Excon::VERSION)
25
25
  end
26
26
 
27
27
  executes do
28
- excon_version = Gem::Version.new(::Excon::VERSION)
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
- ::NewRelic::Agent.logger.warn("Excon instrumentation requires at least version #{EXCON_MIN_VERSION}")
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(::Excon::VERSION) < Gem::Version.new('0.56.0')
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
- ::NewRelic::Agent.logger.log_once(
43
+ NewRelic::Agent.logger.log_once(
44
44
  :warn,
45
45
  :deprecated_excon_version,
46
46
  deprecation_msg
47
47
  )
48
48
 
49
- ::NewRelic::Agent.record_metric("Supportability/Deprecated/Excon", 1)
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
- ::NewRelic::Agent.logger.info('Installing middleware-based Excon instrumentation')
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] << ::Excon::Middleware::NewRelicCrossAppTracing
65
+ defaults[:middlewares] << Excon::Middleware::NewRelicCrossAppTracing
66
66
  else
67
- ::NewRelic::Agent.logger.warn("Did not find :middlewares key in Excon.defaults, skipping Excon instrumentation")
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