newrelic_rpm 8.13.0 → 8.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +3 -0
  4. data/CHANGELOG.md +3258 -3144
  5. data/CONTRIBUTING.md +1 -2
  6. data/README.md +1 -2
  7. data/init.rb +1 -1
  8. data/lib/new_relic/agent/agent.rb +14 -466
  9. data/lib/new_relic/agent/agent_helpers/connect.rb +227 -0
  10. data/lib/new_relic/agent/agent_helpers/harvest.rb +153 -0
  11. data/lib/new_relic/agent/agent_helpers/shutdown.rb +72 -0
  12. data/lib/new_relic/agent/agent_helpers/special_startup.rb +75 -0
  13. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +167 -0
  14. data/lib/new_relic/agent/agent_helpers/startup.rb +202 -0
  15. data/lib/new_relic/agent/agent_helpers/transmit.rb +76 -0
  16. data/lib/new_relic/agent/configuration/default_source.rb +22 -0
  17. data/lib/new_relic/agent/datastores.rb +2 -2
  18. data/lib/new_relic/agent/guid_generator.rb +11 -2
  19. data/lib/new_relic/agent/instrumentation/active_job.rb +7 -7
  20. data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
  21. data/lib/new_relic/agent/instrumentation/active_record.rb +9 -9
  22. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +24 -24
  23. data/lib/new_relic/agent/instrumentation/active_storage.rb +2 -2
  24. data/lib/new_relic/agent/instrumentation/active_support.rb +12 -0
  25. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -3
  26. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +2 -2
  27. data/lib/new_relic/agent/instrumentation/authlogic.rb +2 -2
  28. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +3 -3
  29. data/lib/new_relic/agent/instrumentation/bunny.rb +4 -4
  30. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/curb.rb +6 -6
  32. data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +37 -0
  33. data/lib/new_relic/agent/instrumentation/data_mapper.rb +50 -50
  34. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +5 -5
  35. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +5 -5
  36. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +1 -1
  37. data/lib/new_relic/agent/instrumentation/excon.rb +9 -9
  38. data/lib/new_relic/agent/instrumentation/grape.rb +8 -8
  39. data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +1 -1
  40. data/lib/new_relic/agent/instrumentation/grpc_client.rb +3 -3
  41. data/lib/new_relic/agent/instrumentation/grpc_server.rb +4 -4
  42. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +1 -1
  43. data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
  44. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +1 -1
  45. data/lib/new_relic/agent/instrumentation/httprb.rb +3 -3
  46. data/lib/new_relic/agent/instrumentation/logger.rb +3 -3
  47. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +3 -3
  48. data/lib/new_relic/agent/instrumentation/memcache.rb +16 -16
  49. data/lib/new_relic/agent/instrumentation/mongo.rb +1 -1
  50. data/lib/new_relic/agent/instrumentation/net_http.rb +6 -6
  51. data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
  52. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +5 -5
  53. data/lib/new_relic/agent/instrumentation/rack.rb +14 -14
  54. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -5
  55. data/lib/new_relic/agent/instrumentation/rails_middleware.rb +3 -3
  56. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +6 -6
  57. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +2 -2
  58. data/lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb +5 -3
  59. data/lib/new_relic/agent/instrumentation/rails_notifications/custom_events.rb +30 -0
  60. data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +4 -4
  61. data/lib/new_relic/agent/instrumentation/rake.rb +7 -7
  62. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +29 -10
  63. data/lib/new_relic/agent/instrumentation/redis.rb +4 -4
  64. data/lib/new_relic/agent/instrumentation/resque.rb +9 -9
  65. data/lib/new_relic/agent/instrumentation/sequel.rb +2 -2
  66. data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -3
  67. data/lib/new_relic/agent/instrumentation/sinatra.rb +7 -7
  68. data/lib/new_relic/agent/instrumentation/sunspot.rb +4 -4
  69. data/lib/new_relic/agent/instrumentation/thread.rb +3 -3
  70. data/lib/new_relic/agent/instrumentation/tilt.rb +3 -3
  71. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +2 -2
  72. data/lib/new_relic/agent/instrumentation/typhoeus.rb +1 -1
  73. data/lib/new_relic/agent/method_tracer_helpers.rb +6 -11
  74. data/lib/new_relic/agent/tracer.rb +1 -1
  75. data/lib/new_relic/agent/transaction/segment.rb +6 -0
  76. data/lib/new_relic/control/instance_methods.rb +6 -2
  77. data/lib/new_relic/recipes/helpers/send_deployment.rb +2 -1
  78. data/lib/new_relic/version.rb +1 -1
  79. data/lib/newrelic_rpm.rb +13 -2
  80. data/lib/sequel/extensions/newrelic_instrumentation.rb +1 -1
  81. data/lib/sequel/plugins/newrelic_instrumentation.rb +1 -1
  82. data/newrelic.yml +10 -0
  83. data/test/agent_helper.rb +5 -5
  84. metadata +12 -6
  85. data/lib/new_relic/agent/agent/shutdown.rb +0 -35
  86. data/lib/new_relic/agent/agent/special_startup.rb +0 -72
  87. data/lib/new_relic/agent/agent/start_worker_thread.rb +0 -163
  88. data/lib/new_relic/agent/agent/startup.rb +0 -197
@@ -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
@@ -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
@@ -13,32 +13,32 @@ DependencyDetection.defer do
13
13
  configure_with :grape
14
14
 
15
15
  depends_on do
16
- defined?(::Grape::VERSION) &&
17
- Gem::Version.new(::Grape::VERSION) >= ::NewRelic::Agent::Instrumentation::Grape::Instrumentation::MIN_VERSION
16
+ defined?(Grape::VERSION) &&
17
+ Gem::Version.new(Grape::VERSION) >= NewRelic::Agent::Instrumentation::Grape::Instrumentation::MIN_VERSION
18
18
  end
19
19
 
20
20
  depends_on do
21
21
  begin
22
22
  if defined?(Bundler) && Bundler.rubygems.all_specs.map(&:name).include?("newrelic-grape")
23
- ::NewRelic::Agent.logger.info("Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present")
23
+ NewRelic::Agent.logger.info("Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present")
24
24
  false
25
25
  else
26
26
  true
27
27
  end
28
28
  rescue => e
29
- ::NewRelic::Agent.logger.info("Could not determine if third party newrelic-grape gem is installed", e)
29
+ NewRelic::Agent.logger.info("Could not determine if third party newrelic-grape gem is installed", e)
30
30
  true
31
31
  end
32
32
  end
33
33
 
34
34
  executes do
35
- ::NewRelic::Agent::Instrumentation::Grape::Instrumentation.prepare!
35
+ NewRelic::Agent::Instrumentation::Grape::Instrumentation.prepare!
36
36
 
37
37
  if use_prepend?
38
- instrumented_class = ::NewRelic::Agent::Instrumentation::Grape::Instrumentation.instrumented_class
39
- prepend_instrument instrumented_class, ::NewRelic::Agent::Instrumentation::Grape::Prepend
38
+ instrumented_class = NewRelic::Agent::Instrumentation::Grape::Instrumentation.instrumented_class
39
+ prepend_instrument instrumented_class, NewRelic::Agent::Instrumentation::Grape::Prepend
40
40
  else
41
- chain_instrument ::NewRelic::Agent::Instrumentation::Grape::Chain
41
+ chain_instrument NewRelic::Agent::Instrumentation::Grape::Chain
42
42
  end
43
43
  end
44
44
  end
@@ -34,7 +34,7 @@ module NewRelic
34
34
  end
35
35
  ensure
36
36
  add_attributes(segment, grpc_message: grpc_message, grpc_status: grpc_status, grpc_type: grpc_type)
37
- segment.finish if segment
37
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
38
38
  end
39
39
 
40
40
  private
@@ -9,15 +9,15 @@ DependencyDetection.defer do
9
9
  named :grpc_client
10
10
 
11
11
  depends_on do
12
- defined?(::GRPC) && defined?(::GRPC::ClientStub)
12
+ defined?(GRPC) && defined?(GRPC::ClientStub)
13
13
  end
14
14
 
15
15
  executes do
16
16
  supportability_name = 'gRPC_Client'
17
17
  if use_prepend?
18
- prepend_instrument ::GRPC::ClientStub, ::NewRelic::Agent::Instrumentation::GRPC::Client::Prepend, supportability_name
18
+ prepend_instrument GRPC::ClientStub, NewRelic::Agent::Instrumentation::GRPC::Client::Prepend, supportability_name
19
19
  else
20
- chain_instrument ::NewRelic::Agent::Instrumentation::GRPC::Client::Chain, supportability_name
20
+ chain_instrument NewRelic::Agent::Instrumentation::GRPC::Client::Chain, supportability_name
21
21
  end
22
22
  end
23
23
  end
@@ -10,16 +10,16 @@ DependencyDetection.defer do
10
10
  named :grpc_server
11
11
 
12
12
  depends_on do
13
- defined?(::GRPC) && defined?(::GRPC::RpcServer) && defined?(::GRPC::RpcDesc)
13
+ defined?(GRPC) && defined?(GRPC::RpcServer) && defined?(GRPC::RpcDesc)
14
14
  end
15
15
 
16
16
  executes do
17
17
  supportability_name = 'gRPC_Server'
18
18
  if use_prepend?
19
- prepend_instrument ::GRPC::RpcServer, ::NewRelic::Agent::Instrumentation::GRPC::Server::RpcServerPrepend, supportability_name
20
- prepend_instrument ::GRPC::RpcDesc, ::NewRelic::Agent::Instrumentation::GRPC::Server::RpcDescPrepend, supportability_name
19
+ prepend_instrument GRPC::RpcServer, NewRelic::Agent::Instrumentation::GRPC::Server::RpcServerPrepend, supportability_name
20
+ prepend_instrument GRPC::RpcDesc, NewRelic::Agent::Instrumentation::GRPC::Server::RpcDescPrepend, supportability_name
21
21
  else
22
- chain_instrument ::NewRelic::Agent::Instrumentation::GRPC::Server::Chain, supportability_name
22
+ chain_instrument NewRelic::Agent::Instrumentation::GRPC::Server::Chain, supportability_name
23
23
  end
24
24
  end
25
25
  end
@@ -29,7 +29,7 @@ module NewRelic::Agent::Instrumentation
29
29
 
30
30
  response
31
31
  ensure
32
- segment.finish if segment
32
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
33
33
  end
34
34
  end
35
35
  end
@@ -23,14 +23,14 @@ DependencyDetection.defer do
23
23
  end
24
24
 
25
25
  executes do
26
- ::NewRelic::Agent.logger.info('Installing HTTPClient instrumentation')
26
+ NewRelic::Agent.logger.info('Installing HTTPClient instrumentation')
27
27
  require 'new_relic/agent/distributed_tracing/cross_app_tracing'
28
28
  require 'new_relic/agent/http_clients/httpclient_wrappers'
29
29
  end
30
30
 
31
31
  executes do
32
32
  if use_prepend?
33
- prepend_instrument ::HTTPClient, NewRelic::Agent::Instrumentation::HTTPClient::Prepend
33
+ prepend_instrument HTTPClient, NewRelic::Agent::Instrumentation::HTTPClient::Prepend
34
34
  else
35
35
  chain_instrument NewRelic::Agent::Instrumentation::HTTPClient::Chain
36
36
  end
@@ -23,7 +23,7 @@ module NewRelic::Agent::Instrumentation
23
23
 
24
24
  response
25
25
  ensure
26
- segment.finish if segment
26
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
27
27
  end
28
28
  end
29
29
  end
@@ -14,16 +14,16 @@ DependencyDetection.defer do
14
14
  end
15
15
 
16
16
  executes do
17
- ::NewRelic::Agent.logger.info("Installing http.rb Wrappers")
17
+ NewRelic::Agent.logger.info("Installing http.rb Wrappers")
18
18
  require 'new_relic/agent/distributed_tracing/cross_app_tracing'
19
19
  require 'new_relic/agent/http_clients/http_rb_wrappers'
20
20
  end
21
21
 
22
22
  executes do
23
23
  if use_prepend?
24
- prepend_instrument HTTP::Client, ::NewRelic::Agent::Instrumentation::HTTPrb::Prepend
24
+ prepend_instrument HTTP::Client, NewRelic::Agent::Instrumentation::HTTPrb::Prepend
25
25
  else
26
- chain_instrument ::NewRelic::Agent::Instrumentation::HTTPrb::Chain
26
+ chain_instrument NewRelic::Agent::Instrumentation::HTTPrb::Chain
27
27
  end
28
28
  end
29
29
  end
@@ -10,15 +10,15 @@ DependencyDetection.defer do
10
10
  named :logger
11
11
 
12
12
  depends_on do
13
- defined?(::Logger) &&
13
+ defined?(Logger) &&
14
14
  NewRelic::Agent.config[:'application_logging.enabled']
15
15
  end
16
16
 
17
17
  executes do
18
- ::NewRelic::Agent.logger.info("Installing Logger instrumentation")
18
+ NewRelic::Agent.logger.info("Installing Logger instrumentation")
19
19
 
20
20
  if use_prepend?
21
- prepend_instrument ::Logger, NewRelic::Agent::Instrumentation::Logger::Prepend
21
+ prepend_instrument Logger, NewRelic::Agent::Instrumentation::Logger::Prepend
22
22
  else
23
23
  chain_instrument NewRelic::Agent::Instrumentation::Logger
24
24
  end
@@ -23,7 +23,7 @@ module NewRelic::Agent::Instrumentation
23
23
  if NewRelic::Agent.config[:capture_memcache_keys]
24
24
  segment.notice_nosql_statement("#{operation} #{args.first.inspect}")
25
25
  end
26
- segment.finish if segment
26
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
27
27
  end
28
28
  end
29
29
 
@@ -50,7 +50,7 @@ module NewRelic::Agent::Instrumentation
50
50
  begin
51
51
  NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
52
52
  ensure
53
- segment.finish if segment
53
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
54
54
  end
55
55
  end
56
56
 
@@ -67,7 +67,7 @@ module NewRelic::Agent::Instrumentation
67
67
  if ::NewRelic::Agent.config[:capture_memcache_keys]
68
68
  segment.notice_nosql_statement("#{MULTIGET_METRIC_NAME} #{keys.inspect}")
69
69
  end
70
- segment.finish if segment
70
+ ::NewRelic::Agent::Transaction::Segment.finish(segment)
71
71
  end
72
72
  end
73
73