newrelic_rpm 8.15.0 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -28
- data/.rubocop_todo.yml +41 -3
- data/CHANGELOG.md +191 -38
- data/CONTRIBUTING.md +1 -1
- data/README.md +3 -1
- data/bin/nrdebug +16 -16
- data/lib/new_relic/agent/agent_helpers/connect.rb +1 -1
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +1 -2
- data/lib/new_relic/agent/attribute_filter.rb +0 -2
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +3 -3
- data/lib/new_relic/agent/configuration/default_source.rb +139 -476
- data/lib/new_relic/agent/configuration/high_security_source.rb +0 -2
- data/lib/new_relic/agent/configuration/security_policy_source.rb +0 -16
- data/lib/new_relic/agent/database.rb +0 -14
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +1 -2
- data/lib/new_relic/agent/error_collector.rb +1 -1
- data/lib/new_relic/agent/error_filter.rb +3 -3
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +6 -19
- data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +39 -0
- data/lib/new_relic/agent/instrumentation/action_dispatch.rb +31 -0
- data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +64 -0
- data/lib/new_relic/agent/instrumentation/action_mailbox.rb +30 -0
- data/lib/new_relic/agent/instrumentation/action_mailbox_subscriber.rb +33 -0
- data/lib/new_relic/agent/instrumentation/action_mailer.rb +30 -0
- data/lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb +85 -0
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +7 -7
- data/lib/new_relic/agent/instrumentation/active_job.rb +15 -2
- data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/active_storage.rb +4 -0
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +2 -30
- data/lib/new_relic/agent/instrumentation/active_support.rb +21 -6
- data/lib/new_relic/agent/instrumentation/active_support_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/custom_events.rb +12 -0
- data/lib/new_relic/agent/instrumentation/fiber/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +24 -0
- data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +18 -0
- data/lib/new_relic/agent/instrumentation/fiber.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
- data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +13 -1
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +1 -8
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sequel.rb +4 -5
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +3 -7
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +0 -1
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +0 -1
- data/lib/new_relic/agent/new_relic_service.rb +1 -1
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +0 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +10 -1
- data/lib/new_relic/agent/transaction/abstract_segment.rb +2 -2
- data/lib/new_relic/agent/transaction/tracing.rb +2 -2
- data/lib/new_relic/agent/transaction.rb +17 -16
- data/lib/new_relic/agent.rb +1 -19
- data/lib/new_relic/cli/commands/install.rb +9 -9
- data/lib/new_relic/control/instance_methods.rb +1 -1
- data/lib/new_relic/local_environment.rb +0 -10
- data/lib/new_relic/supportability_helper.rb +0 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +3 -3
- data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +3 -3
- data/lib/tasks/helpers/format.rb +1 -1
- data/lib/tasks/instrumentation_generator/instrumentation.thor +7 -10
- data/lib/tasks/instrumentation_generator/templates/Envfile.tt +1 -1
- data/newrelic.yml +15 -9
- data/newrelic_rpm.gemspec +17 -13
- data/test/agent_helper.rb +1 -1
- metadata +37 -14
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -83
- data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -33
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -215
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +0 -36
- data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -41
@@ -1,215 +0,0 @@
|
|
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
|
-
DependencyDetection.defer do
|
6
|
-
named :data_mapper
|
7
|
-
|
8
|
-
depends_on do
|
9
|
-
defined?(DataMapper) &&
|
10
|
-
defined?(DataMapper::Model) &&
|
11
|
-
defined?(DataMapper::Resource) &&
|
12
|
-
defined?(DataMapper::Collection)
|
13
|
-
end
|
14
|
-
|
15
|
-
executes do
|
16
|
-
NewRelic::Agent.logger.info('Installing DataMapper instrumentation')
|
17
|
-
require 'new_relic/agent/datastores/metric_helper'
|
18
|
-
|
19
|
-
deprecation_msg = 'The instrumentation for DataMapper is deprecated. ' \
|
20
|
-
'It will be removed in version 9.0.0.' \
|
21
|
-
'Visit https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks ' \
|
22
|
-
'to learn about supported gems.'
|
23
|
-
|
24
|
-
NewRelic::Agent.logger.log_once(
|
25
|
-
:warn,
|
26
|
-
:deprecated_datamapper,
|
27
|
-
deprecation_msg
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
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)
|
47
|
-
end
|
48
|
-
|
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!)
|
56
|
-
end
|
57
|
-
|
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)
|
63
|
-
|
64
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :lazy_load)
|
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!)
|
72
|
-
|
73
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :aggregate)
|
74
|
-
end
|
75
|
-
|
76
|
-
executes do
|
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)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
executes do
|
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)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
executes do
|
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)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
executes do
|
99
|
-
if defined?(DataObjects::Connection)
|
100
|
-
DataObjects::Connection.class_eval do
|
101
|
-
include NewRelic::Agent::Instrumentation::DataMapperInstrumentation
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
module NewRelic
|
108
|
-
module Agent
|
109
|
-
module DataMapperTracing
|
110
|
-
def self.add_tracer(clazz, method_name, operation_only = false)
|
111
|
-
clazz.class_eval do
|
112
|
-
if method_defined?(method_name) || private_method_defined?(method_name)
|
113
|
-
define_method("#{method_name}_with_newrelic",
|
114
|
-
NewRelic::Agent::DataMapperTracing.method_body(clazz, method_name, operation_only))
|
115
|
-
|
116
|
-
alias_method("#{method_name}_without_newrelic", method_name)
|
117
|
-
alias_method(method_name, "#{method_name}_with_newrelic")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
DATA_MAPPER = "DataMapper".freeze
|
123
|
-
PASSWORD_REGEX = /&password=.*?(&|$)/
|
124
|
-
AMPERSAND = '&'.freeze
|
125
|
-
PASSWORD_PARAM = '&password='.freeze
|
126
|
-
|
127
|
-
def self.method_body(clazz, method_name, operation_only)
|
128
|
-
use_model_name = NewRelic::Helper.instance_methods_include?(clazz, :model)
|
129
|
-
metric_operation = method_name.to_s.gsub(/[!?]/, "")
|
130
|
-
|
131
|
-
proc do |*args, &blk|
|
132
|
-
begin
|
133
|
-
if operation_only
|
134
|
-
# Used by direct SQL, like ::DataMapper::Adapters::DataObjectsAdapter#select
|
135
|
-
name = nil
|
136
|
-
elsif use_model_name
|
137
|
-
# Used by ::DataMapper::Collection to get contained model name
|
138
|
-
name = self.model.name
|
139
|
-
elsif self.is_a?(Class)
|
140
|
-
# Used by class-style access, like Model.first()
|
141
|
-
name = self.name
|
142
|
-
else
|
143
|
-
# Used by instance-style access, like model.update(attr: "new")
|
144
|
-
name = self.class.name
|
145
|
-
end
|
146
|
-
|
147
|
-
segment = NewRelic::Agent::Tracer.start_datastore_segment(
|
148
|
-
product: DATA_MAPPER,
|
149
|
-
operation: metric_operation,
|
150
|
-
collection: name
|
151
|
-
)
|
152
|
-
|
153
|
-
begin
|
154
|
-
NewRelic::Agent::Tracer.capture_segment_error(segment) do
|
155
|
-
self.send("#{method_name}_without_newrelic", *args, &blk)
|
156
|
-
end
|
157
|
-
rescue ::DataObjects::ConnectionError => e
|
158
|
-
raise
|
159
|
-
rescue ::DataObjects::SQLError => e
|
160
|
-
e.uri.gsub!(PASSWORD_REGEX, AMPERSAND) if e.uri.include?(PASSWORD_PARAM)
|
161
|
-
|
162
|
-
strategy = NewRelic::Agent::Database.record_sql_method(:slow_sql)
|
163
|
-
case strategy
|
164
|
-
when :obfuscated
|
165
|
-
adapter_name = if self.respond_to?(:options)
|
166
|
-
self.options[:adapter]
|
167
|
-
else
|
168
|
-
if self.repository.adapter.respond_to?(:options)
|
169
|
-
self.repository.adapter.options[:adapter]
|
170
|
-
else
|
171
|
-
# DataMapper < 0.10.0
|
172
|
-
self.repository.adapter.uri.scheme
|
173
|
-
end
|
174
|
-
end
|
175
|
-
statement = NewRelic::Agent::Database::Statement.new(e.query, :adapter => adapter_name)
|
176
|
-
obfuscated_sql = NewRelic::Agent::Database.obfuscate_sql(statement)
|
177
|
-
e.instance_variable_set(:@query, obfuscated_sql)
|
178
|
-
when :off
|
179
|
-
e.instance_variable_set(:@query, nil)
|
180
|
-
end
|
181
|
-
|
182
|
-
raise
|
183
|
-
ensure
|
184
|
-
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
module Instrumentation
|
192
|
-
module DataMapperInstrumentation
|
193
|
-
# Unlike in AR, log is called in DM after the query actually ran,
|
194
|
-
# complete with metrics. Since DO has already calculated the
|
195
|
-
# duration, there's nothing more to measure, so just record and log.
|
196
|
-
#
|
197
|
-
# We rely on the assumption that all possible entry points have been
|
198
|
-
# hooked with tracers, ensuring that notice_sql attaches this SQL to
|
199
|
-
# the proper call scope.
|
200
|
-
def log(msg) # THREAD_LOCAL_ACCESS
|
201
|
-
state = NewRelic::Agent::Tracer.state
|
202
|
-
return unless state.is_execution_traced?
|
203
|
-
|
204
|
-
txn = state.current_transaction
|
205
|
-
|
206
|
-
if txn && txn.current_segment.respond_to?(:notice_sql)
|
207
|
-
txn.current_segment.notice_sql(msg.query)
|
208
|
-
end
|
209
|
-
ensure
|
210
|
-
super
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
@@ -1,36 +0,0 @@
|
|
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
|
-
DependencyDetection.defer do
|
6
|
-
@name = :rainbows
|
7
|
-
|
8
|
-
depends_on do
|
9
|
-
defined?(Rainbows) && defined?(Rainbows::HttpServer)
|
10
|
-
end
|
11
|
-
|
12
|
-
executes do
|
13
|
-
NewRelic::Agent.logger.info('Installing Rainbows instrumentation')
|
14
|
-
NewRelic::Agent.logger.info('Detected Rainbows, please see additional documentation: https://newrelic.com/docs/troubleshooting/im-using-unicorn-and-i-dont-see-any-data')
|
15
|
-
|
16
|
-
deprecation_msg = 'The dispatcher rainbows is deprecated. It will be removed ' \
|
17
|
-
'in version 9.0.0. Please use a supported dispatcher instead. ' \
|
18
|
-
'Visit https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks for options.'
|
19
|
-
|
20
|
-
NewRelic::Agent.logger.log_once(
|
21
|
-
:warn,
|
22
|
-
:deprecated_rainbows_dispatcher,
|
23
|
-
deprecation_msg
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
executes do
|
28
|
-
Rainbows::HttpServer.class_eval do
|
29
|
-
old_worker_loop = instance_method(:worker_loop)
|
30
|
-
define_method(:worker_loop) do |worker|
|
31
|
-
NewRelic::Agent.after_fork(:force_reconnect => true)
|
32
|
-
old_worker_loop.bind(self).call(worker)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,41 +0,0 @@
|
|
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
|
-
DependencyDetection.defer do
|
6
|
-
@name = :sunspot
|
7
|
-
|
8
|
-
depends_on do
|
9
|
-
defined?(Sunspot)
|
10
|
-
end
|
11
|
-
|
12
|
-
executes do
|
13
|
-
NewRelic::Agent.logger.info('Installing Rails Sunspot instrumentation')
|
14
|
-
deprecation_msg = 'The instrumentation for Sunspot is deprecated. ' \
|
15
|
-
'It will be removed in version 9.0.0.'
|
16
|
-
|
17
|
-
NewRelic::Agent.logger.log_once(
|
18
|
-
:warn,
|
19
|
-
:deprecated_sunspot,
|
20
|
-
deprecation_msg
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
executes do
|
25
|
-
Sunspot.module_eval do
|
26
|
-
class << self
|
27
|
-
%w[index index!].each do |method|
|
28
|
-
add_method_tracer method, 'SolrClient/Sunspot/index'
|
29
|
-
end
|
30
|
-
add_method_tracer :commit, 'SolrClient/Sunspot/commit'
|
31
|
-
|
32
|
-
%w[search more_like_this].each do |method|
|
33
|
-
add_method_tracer method, 'SolrClient/Sunspot/query'
|
34
|
-
end
|
35
|
-
%w[remove remove! remove_by_id remove_by_id! remove_all remove_all!].each do |method|
|
36
|
-
add_method_tracer method, 'SolrClient/Sunspot/delete'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|