newrelic_rpm 6.13.0 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +231 -0
  4. data/CONTRIBUTING.md +13 -2
  5. data/README.md +2 -2
  6. data/lib/new_relic/agent.rb +5 -8
  7. data/lib/new_relic/agent/agent.rb +4 -5
  8. data/lib/new_relic/agent/audit_logger.rb +10 -0
  9. data/lib/new_relic/agent/autostart.rb +1 -2
  10. data/lib/new_relic/agent/configuration/default_source.rb +412 -220
  11. data/lib/new_relic/agent/configuration/manager.rb +2 -2
  12. data/lib/new_relic/agent/database_adapter.rb +33 -0
  13. data/lib/new_relic/agent/datastores/redis.rb +0 -4
  14. data/lib/new_relic/agent/distributed_tracing.rb +0 -66
  15. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +2 -2
  16. data/lib/new_relic/agent/http_clients/uri_util.rb +1 -1
  17. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +4 -5
  18. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +21 -68
  19. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +0 -16
  20. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +23 -57
  21. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -3
  22. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -15
  23. data/lib/new_relic/agent/instrumentation/bunny.rb +10 -196
  24. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +45 -0
  25. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +152 -0
  26. data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +35 -0
  27. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -0
  28. data/lib/new_relic/agent/instrumentation/curb.rb +9 -259
  29. data/lib/new_relic/agent/instrumentation/curb/chain.rb +93 -0
  30. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +222 -0
  31. data/lib/new_relic/agent/instrumentation/curb/prepend.rb +63 -0
  32. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +38 -0
  33. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +53 -0
  34. data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +34 -0
  35. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +8 -84
  36. data/lib/new_relic/agent/instrumentation/excon.rb +2 -1
  37. data/lib/new_relic/agent/instrumentation/grape.rb +13 -113
  38. data/lib/new_relic/agent/instrumentation/grape/chain.rb +25 -0
  39. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +100 -0
  40. data/lib/new_relic/agent/instrumentation/grape/prepend.rb +17 -0
  41. data/lib/new_relic/agent/instrumentation/httpclient.rb +8 -30
  42. data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +25 -0
  43. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +38 -0
  44. data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +17 -0
  45. data/lib/new_relic/agent/instrumentation/httprb.rb +29 -0
  46. data/lib/new_relic/agent/instrumentation/httprb/chain.rb +22 -0
  47. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +30 -0
  48. data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +15 -0
  49. data/lib/new_relic/agent/instrumentation/memcache.rb +54 -69
  50. data/lib/new_relic/agent/instrumentation/memcache/chain.rb +16 -0
  51. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +38 -121
  52. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +56 -0
  53. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +88 -0
  54. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +88 -0
  55. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +4 -10
  56. data/lib/new_relic/agent/instrumentation/mongo.rb +7 -0
  57. data/lib/new_relic/agent/instrumentation/net_http.rb +44 -0
  58. data/lib/new_relic/agent/instrumentation/net_http/chain.rb +25 -0
  59. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +40 -0
  60. data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +21 -0
  61. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +1 -1
  62. data/lib/new_relic/agent/instrumentation/padrino.rb +18 -75
  63. data/lib/new_relic/agent/instrumentation/padrino/chain.rb +34 -0
  64. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +27 -0
  65. data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +20 -0
  66. data/lib/new_relic/agent/instrumentation/rack.rb +29 -160
  67. data/lib/new_relic/agent/instrumentation/rack/chain.rb +57 -0
  68. data/lib/new_relic/agent/instrumentation/rack/helpers.rb +32 -0
  69. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +73 -0
  70. data/lib/new_relic/agent/instrumentation/rack/prepend.rb +36 -0
  71. data/lib/new_relic/agent/instrumentation/rake.rb +13 -188
  72. data/lib/new_relic/agent/instrumentation/rake/chain.rb +25 -0
  73. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +144 -0
  74. data/lib/new_relic/agent/instrumentation/rake/prepend.rb +14 -0
  75. data/lib/new_relic/agent/instrumentation/redis.rb +12 -186
  76. data/lib/new_relic/agent/instrumentation/redis/chain.rb +34 -0
  77. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +65 -0
  78. data/lib/new_relic/agent/instrumentation/redis/prepend.rb +24 -0
  79. data/lib/new_relic/agent/instrumentation/resque.rb +21 -32
  80. data/lib/new_relic/agent/instrumentation/resque/chain.rb +22 -0
  81. data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
  82. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +35 -0
  83. data/lib/new_relic/agent/instrumentation/resque/prepend.rb +16 -0
  84. data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -1
  85. data/lib/new_relic/agent/instrumentation/sinatra.rb +20 -198
  86. data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +55 -0
  87. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +29 -34
  88. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +124 -0
  89. data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
  90. data/lib/new_relic/agent/instrumentation/typhoeus.rb +10 -89
  91. data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +22 -0
  92. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +82 -0
  93. data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +14 -0
  94. data/lib/new_relic/agent/javascript_instrumentor.rb +12 -7
  95. data/lib/new_relic/agent/method_tracer.rb +6 -16
  96. data/lib/new_relic/agent/new_relic_service.rb +16 -13
  97. data/lib/new_relic/agent/samplers/memory_sampler.rb +1 -1
  98. data/lib/new_relic/agent/span_event_primitive.rb +10 -8
  99. data/lib/new_relic/agent/sql_sampler.rb +3 -3
  100. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -1
  101. data/lib/new_relic/agent/transaction.rb +1 -4
  102. data/lib/new_relic/agent/transaction/abstract_segment.rb +1 -1
  103. data/lib/new_relic/agent/transaction/distributed_tracer.rb +12 -6
  104. data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -0
  105. data/lib/new_relic/agent/vm/mri_vm.rb +6 -4
  106. data/lib/new_relic/cli/commands/deployments.rb +0 -1
  107. data/lib/new_relic/constants.rb +4 -0
  108. data/lib/new_relic/control/frameworks/rails.rb +11 -9
  109. data/lib/new_relic/control/instance_methods.rb +1 -0
  110. data/lib/new_relic/dependency_detection.rb +119 -9
  111. data/lib/new_relic/environment_report.rb +1 -7
  112. data/lib/new_relic/noticed_error.rb +1 -5
  113. data/lib/new_relic/supportability_helper.rb +3 -2
  114. data/lib/new_relic/version.rb +2 -2
  115. data/lib/tasks/config.html.erb +14 -25
  116. data/lib/tasks/config.rake +8 -7
  117. data/newrelic_rpm.gemspec +2 -2
  118. data/test/agent_helper.rb +1 -0
  119. metadata +55 -32
  120. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  121. data/.github/ISSUE_TEMPLATE/config.yml +0 -5
  122. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -24
  123. data/.github/actions/annotate/README.md +0 -79
  124. data/.github/actions/annotate/action.yml +0 -6
  125. data/.github/actions/annotate/dist/index.js +0 -433
  126. data/.github/actions/annotate/index.js +0 -25
  127. data/.github/actions/annotate/package-lock.json +0 -172
  128. data/.github/actions/annotate/package.json +0 -30
  129. data/.github/actions/annotate/pre-commit +0 -5
  130. data/.github/actions/build-ruby/README.md +0 -79
  131. data/.github/actions/build-ruby/action.yml +0 -15
  132. data/.github/actions/build-ruby/dist/index.js +0 -52683
  133. data/.github/actions/build-ruby/index.js +0 -514
  134. data/.github/actions/build-ruby/package-lock.json +0 -581
  135. data/.github/actions/build-ruby/package.json +0 -32
  136. data/.github/actions/build-ruby/pre-commit +0 -5
  137. data/.github/pull_request_template.md +0 -16
  138. data/.github/workflows/ci.yml +0 -212
  139. data/.github/workflows/pr_review_checklist.yml +0 -22
  140. data/.github/workflows/release.yml +0 -78
  141. data/.github/workflows/scripts/rubygems-authenticate.py +0 -13
  142. data/.github/workflows/scripts/rubygems-publish.rb +0 -32
  143. data/.github/workflows/snyk.yml +0 -27
  144. data/.github/workflows/stale.yml +0 -21
  145. data/cert/cacert.pem +0 -1177
  146. data/lib/new_relic/agent/instrumentation/http.rb +0 -49
  147. data/lib/new_relic/agent/instrumentation/net.rb +0 -87
@@ -23,7 +23,7 @@ module NewRelic
23
23
  end
24
24
 
25
25
  def has_key?(key)
26
- @cache.has_key?[key]
26
+ @cache.has_key? key
27
27
  end
28
28
 
29
29
  def keys
@@ -345,7 +345,7 @@ module NewRelic
345
345
  end
346
346
 
347
347
  def reset_cache
348
- @cache = Hash.new {|hash,key| hash[key] = self.fetch(key) }
348
+ @cache = Hash.new { |hash,key| hash[key] = self.fetch(key) }
349
349
  end
350
350
 
351
351
  def log_config(direction, source)
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
+
5
+ module NewRelic
6
+ module Agent
7
+ class DatabaseAdapter
8
+ VERSIONS = {
9
+ '6.1.0' => proc { ActiveRecord::Base.connection_db_config.configuration_hash[:adapter] },
10
+ '4.0.0' => proc { ActiveRecord::Base.connection_config[:adapter] },
11
+ '3.0.0' => proc { |env| ActiveRecord::Base.configurations[env]['adapter'] }
12
+ }
13
+
14
+ def self.value
15
+ return unless defined? ActiveRecord::Base
16
+ new(::NewRelic::Control.instance.env, ActiveRecord::VERSION::STRING).value
17
+ end
18
+
19
+ attr_reader :env, :version
20
+
21
+ def initialize(env, version)
22
+ @env = env
23
+ @version = Gem::Version.new(version)
24
+ end
25
+
26
+ def value
27
+ match = VERSIONS.keys.find { |key| version >= Gem::Version.new(key) }
28
+ return unless match
29
+ VERSIONS[match].call(env)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -6,11 +6,7 @@ module NewRelic
6
6
  module Agent
7
7
  module Datastores
8
8
  module Redis
9
- MULTI_OPERATION = 'multi'
10
- PIPELINE_OPERATION = 'pipeline'
11
9
  BINARY_DATA_PLACEHOLDER = "<binary data>"
12
- PRODUCT_NAME = 'Redis'
13
- CONNECT = 'connect'
14
10
 
15
11
  MAXIMUM_COMMAND_LENGTH = 1000
16
12
  MAXIMUM_ARGUMENT_LENGTH = 64
@@ -24,72 +24,6 @@ module NewRelic
24
24
  extend NewRelic::SupportabilityHelper
25
25
  extend self
26
26
 
27
- # Create a payload object containing the current transaction's
28
- # tracing properties (e.g., duration, priority). You can use
29
- # this object to generate headers to inject into a network
30
- # request, so that the downstream service can participate in a
31
- # distributed trace.
32
- #
33
- # @return [DistributedTracePayload] Payload for the current
34
- # transaction, or +nil+ if we
35
- # could not create the payload
36
- #
37
- # @api public
38
- #
39
- # @deprecated See {#create_distributed_trace_headers} instead.
40
- #
41
- def create_distributed_trace_payload
42
- Deprecator.deprecate :create_distributed_trace_payload, :create_distributed_trace_headers
43
-
44
- unless Agent.config[:'distributed_tracing.enabled']
45
- NewRelic::Agent.logger.warn "Not configured to create New Relic distributed trace payload"
46
- return nil
47
- end
48
-
49
- return unless transaction = Transaction.tl_current
50
- transaction.distributed_tracer.create_distributed_trace_payload
51
- rescue => e
52
- NewRelic::Agent.logger.error 'error during create_distributed_trace_payload', e
53
- nil
54
- end
55
-
56
- # Decode a JSON string containing distributed trace properties
57
- # (e.g., calling application, priority) and apply them to the
58
- # current transaction. You can use it to receive distributed
59
- # tracing information protocols the agent does not already
60
- # support.
61
- #
62
- # This method will fail if you call it after calling
63
- # {#create_distributed_trace_payload}.
64
- #
65
- # @param payload [String] Incoming distributed trace payload,
66
- # either as a JSON string or as a
67
- # header-friendly string returned from
68
- # {DistributedTracePayload#http_safe}
69
- #
70
- # @return nil
71
- #
72
- # @api public
73
- #
74
- # @deprecated See {#accept_distributed_trace_headers} instead
75
- #
76
- def accept_distributed_trace_payload payload
77
- Deprecator.deprecate :accept_distributed_trace_payload, :accept_distributed_trace_headers
78
-
79
- unless Agent.config[:'distributed_tracing.enabled']
80
- NewRelic::Agent.logger.warn "Not configured to accept New Relic distributed trace payload"
81
- return nil
82
- end
83
-
84
- return unless transaction = Transaction.tl_current
85
- transaction.distributed_tracer.accept_distributed_trace_payload(payload)
86
- nil
87
- rescue => e
88
- NewRelic::Agent.logger.error 'error during accept_distributed_trace_payload', e
89
- nil
90
- end
91
-
92
-
93
27
  # Adds the Distributed Trace headers so that the downstream service can participate in a
94
28
  # distributed trace. This method should be called every time an outbound call is made
95
29
  # since the header payload contains a timestamp.
@@ -52,14 +52,14 @@ module NewRelic
52
52
  result
53
53
  end
54
54
 
55
- def insert_cross_app_header request
55
+ def insert_cross_app_header headers
56
56
  return unless CrossAppTracing.cross_app_enabled?
57
57
  @is_cross_app_caller = true
58
58
  txn_guid = transaction.guid
59
59
  trip_id = cat_trip_id
60
60
  path_hash = cat_path_hash
61
61
 
62
- insert_request_headers request, txn_guid, trip_id, path_hash
62
+ insert_request_headers headers, txn_guid, trip_id, path_hash
63
63
  end
64
64
 
65
65
  def add_message_cat_headers headers
@@ -28,7 +28,7 @@ module NewRelic
28
28
  # accept that the stdlib URI module doesn't handle. If we find that
29
29
  # Addressable is around, use that to normalize out our URL's.
30
30
  def self.parse_and_normalize_url(url)
31
- uri = url
31
+ uri = url.dup
32
32
  unless ::URI === uri
33
33
  if defined?(::Addressable::URI)
34
34
  address = ::Addressable::URI.parse(url)
@@ -23,12 +23,11 @@ module NewRelic
23
23
  log_notification_error(e, name, 'start')
24
24
  end
25
25
 
26
- def finish(name, id, payload) #THREAD_LOCAL_ACCESS
26
+ def finish(name, id, payload)
27
27
  if segment = pop_segment(id)
28
-
29
- if exception = exception_object(payload)
30
- segment.notice_error exception
31
- end
28
+ if exception = exception_object(payload)
29
+ segment.notice_error exception
30
+ end
32
31
  segment.finish
33
32
  end
34
33
  rescue => e
@@ -20,37 +20,19 @@ module NewRelic
20
20
  ::ActiveRecord::Base.class_eval do
21
21
  alias_method :save_without_newrelic, :save
22
22
 
23
- if RUBY_VERSION < "2.7.0"
24
- def save(*args, &blk)
25
- ::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
26
- save_without_newrelic(*args, &blk)
27
- end
28
- end
29
- else
30
- def save(*args, **kwargs, &blk)
31
- ::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
32
- save_without_newrelic(*args, **kwargs, &blk)
33
- end
23
+ def save(*args, &blk)
24
+ ::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
25
+ save_without_newrelic(*args, &blk)
34
26
  end
35
-
36
27
  end
37
28
 
38
29
  alias_method :save_without_newrelic!, :save!
39
30
 
40
- if RUBY_VERSION < "2.7.0"
41
- def save!(*args, &blk)
42
- ::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
43
- save_without_newrelic!(*args, &blk)
44
- end
45
- end
46
- else
47
- def save!(*args, **kwargs, &blk)
48
- ::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
49
- save_without_newrelic!(*args, **kwargs, &blk)
50
- end
31
+ def save!(*args, &blk)
32
+ ::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
33
+ save_without_newrelic!(*args, &blk)
51
34
  end
52
35
  end
53
-
54
36
  end
55
37
  end
56
38
 
@@ -58,17 +40,9 @@ module NewRelic
58
40
  ::ActiveRecord::Relation.class_eval do
59
41
  alias_method :update_all_without_newrelic, :update_all
60
42
 
61
- if RUBY_VERSION < "2.7.0"
62
- def update_all(*args, &blk)
63
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
64
- update_all_without_newrelic(*args, &blk)
65
- end
66
- end
67
- else
68
- def update_all(*args, **kwargs, &blk)
69
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
70
- update_all_without_newrelic(*args, **kwargs, &blk)
71
- end
43
+ def update_all(*args, &blk)
44
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
45
+ update_all_without_newrelic(*args, &blk)
72
46
  end
73
47
  end
74
48
 
@@ -90,52 +64,31 @@ module NewRelic
90
64
 
91
65
  alias_method :destroy_all_without_newrelic, :destroy_all
92
66
 
93
- if RUBY_VERSION < "2.7.0"
94
- def destroy_all(*args, &blk)
95
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
96
- destroy_all_without_newrelic(*args, &blk)
97
- end
98
- end
99
- else
100
- def destroy_all(*args, **kwargs, &blk)
101
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
102
- destroy_all_without_newrelic(*args, **kwargs, &blk)
103
- end
67
+ def destroy_all(*args, &blk)
68
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
69
+ destroy_all_without_newrelic(*args, &blk)
104
70
  end
105
71
  end
106
72
 
73
+
107
74
  alias_method :calculate_without_newrelic, :calculate
108
75
 
109
- if RUBY_VERSION < "2.7.0"
110
- def calculate(*args, &blk)
111
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
112
- calculate_without_newrelic(*args, &blk)
113
- end
114
- end
115
- else
116
- def calculate(*args, **kwargs, &blk)
117
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
118
- calculate_without_newrelic(*args, **kwargs, &blk)
119
- end
76
+ def calculate(*args, &blk)
77
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
78
+ calculate_without_newrelic(*args, &blk)
120
79
  end
121
80
  end
122
81
 
82
+
123
83
  if method_defined?(:pluck)
124
84
  alias_method :pluck_without_newrelic, :pluck
125
85
 
126
- if RUBY_VERSION < "2.7.0"
127
- def pluck(*args, &blk)
128
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
129
- pluck_without_newrelic(*args, &blk)
130
- end
131
- end
132
- else
133
- def pluck(*args, **kwargs, &blk)
134
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
135
- pluck_without_newrelic(*args, **kwargs, &blk)
136
- end
86
+ def pluck(*args, &blk)
87
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
88
+ pluck_without_newrelic(*args, &blk)
137
89
  end
138
90
  end
91
+
139
92
  end
140
93
  end
141
94
  end
@@ -92,22 +92,6 @@ DependencyDetection.defer do
92
92
  !NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.subscribed?
93
93
  end
94
94
 
95
-
96
- depends_on do
97
- # If the deprecated :disable_active_record_4 setting is true, and
98
- # the active record version is four, disable!
99
- NewRelic::Agent.config[:disable_active_record_4] == false \
100
- || ::ActiveRecord::VERSION::MAJOR.to_i != 4
101
- end
102
-
103
- depends_on do
104
- # If the deprecated :disable_active_record_5 setting is true, and
105
- # the active record version is five, disable!
106
- NewRelic::Agent.config[:disable_active_record_5] == false \
107
- || ::ActiveRecord::VERSION::MAJOR.to_i != 5
108
- end
109
-
110
-
111
95
  executes do
112
96
  ::NewRelic::Agent.logger.info 'Installing notifications based Active Record instrumentation'
113
97
  end
@@ -62,68 +62,34 @@ module NewRelic
62
62
  end
63
63
 
64
64
  module RelationExtensions
65
- if RUBY_VERSION < "2.7.0"
66
- def update_all(*args, &blk)
67
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
68
- super
69
- end
70
- end
71
-
72
- def delete_all(*args, &blk)
73
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
74
- super
75
- end
76
- end
77
-
78
- def destroy_all(*args, &blk)
79
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
80
- super
81
- end
82
- end
83
-
84
- def calculate(*args, &blk)
85
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
86
- super
87
- end
88
- end
89
-
90
- def pluck(*args, &blk)
91
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
92
- super
93
- end
94
- end
95
-
96
- else
97
- def update_all(*args, **kwargs, &blk)
98
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
99
- super
100
- end
65
+ def update_all(*args, &blk)
66
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
67
+ super
101
68
  end
102
-
103
- def delete_all(*args, **kwargs, &blk)
104
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
105
- super
106
- end
107
- end
108
-
109
- def destroy_all(*args, **kwargs, &blk)
110
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
111
- super
112
- end
69
+ end
70
+
71
+ def delete_all(*args, &blk)
72
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
73
+ super
113
74
  end
114
-
115
- def calculate(*args, **kwargs, &blk)
116
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
117
- super
118
- end
75
+ end
76
+
77
+ def destroy_all(*args, &blk)
78
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
79
+ super
119
80
  end
120
-
121
- def pluck(*args, **kwargs, &blk)
122
- ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
123
- super
124
- end
81
+ end
82
+
83
+ def calculate(*args, &blk)
84
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
85
+ super
125
86
  end
87
+ end
126
88
 
89
+ def pluck(*args, &blk)
90
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
91
+ super
92
+ end
127
93
  end
128
94
  end
129
95
  end
@@ -84,8 +84,6 @@ module NewRelic
84
84
  end
85
85
 
86
86
  def active_record_config(payload)
87
- return unless payload[:connection_id]
88
-
89
87
  # handle if the notification payload provides the AR connection
90
88
  # available in Rails 6+ & our ActiveRecordNotifications#log extension
91
89
  if payload[:connection]
@@ -93,8 +91,8 @@ module NewRelic
93
91
  return connection_config if connection_config
94
92
  end
95
93
 
94
+ return unless connection_id = payload[:connection_id]
96
95
  connection = nil
97
- connection_id = payload[:connection_id]
98
96
 
99
97
  ::ActiveRecord::Base.connection_handler.connection_pool_list.each do |handler|
100
98
  connection = handler.connections.detect do |conn|