newrelic_rpm 7.1.0 → 8.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +189 -6
- data/README.md +5 -1
- data/lib/new_relic/agent/adaptive_sampler.rb +2 -2
- data/lib/new_relic/agent/agent.rb +6 -6
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +7 -3
- data/lib/new_relic/agent/configuration/default_source.rb +86 -15
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +28 -12
- data/lib/new_relic/agent/configuration/manager.rb +1 -2
- data/lib/new_relic/agent/configuration/server_source.rb +3 -2
- data/lib/new_relic/agent/configuration/yaml_source.rb +22 -1
- data/lib/new_relic/agent/connect/request_builder.rb +4 -2
- data/lib/new_relic/agent/custom_event_aggregator.rb +2 -1
- data/lib/new_relic/agent/database.rb +5 -2
- data/lib/new_relic/agent/datastores/mongo.rb +5 -10
- data/lib/new_relic/agent/datastores.rb +7 -7
- data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +10 -6
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +0 -1
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +6 -6
- data/lib/new_relic/agent/error_collector.rb +52 -37
- data/lib/new_relic/agent/error_filter.rb +175 -0
- data/lib/new_relic/agent/event_loop.rb +6 -6
- data/lib/new_relic/agent/external.rb +0 -32
- data/lib/new_relic/agent/http_clients/abstract.rb +2 -2
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +7 -1
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/excon.rb +4 -23
- data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +59 -0
- data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/logger.rb +25 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +5 -1
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +5 -0
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +8 -2
- data/lib/new_relic/agent/instrumentation/mongo.rb +3 -141
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +23 -19
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino.rb +4 -2
- data/lib/new_relic/agent/instrumentation/queue_time.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +2 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -41
- data/lib/new_relic/agent/instrumentation/resque.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -1
- data/lib/new_relic/agent/instrumentation/tilt/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +41 -0
- data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/tilt.rb +25 -0
- data/lib/new_relic/agent/javascript_instrumentor.rb +3 -3
- data/lib/new_relic/agent/logging.rb +5 -6
- data/lib/new_relic/agent/messaging.rb +10 -24
- data/lib/new_relic/agent/method_tracer.rb +137 -138
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +8 -1
- data/lib/new_relic/agent/new_relic_service.rb +16 -23
- data/lib/new_relic/agent/pipe_channel_manager.rb +10 -6
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +9 -6
- data/lib/new_relic/agent/span_event_aggregator.rb +2 -2
- data/lib/new_relic/agent/sql_sampler.rb +1 -1
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
- data/lib/new_relic/agent/stats_engine.rb +1 -1
- data/lib/new_relic/agent/threading/backtrace_service.rb +4 -5
- data/lib/new_relic/agent/threading/thread_profile.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +15 -37
- data/lib/new_relic/agent/transaction/abstract_segment.rb +3 -3
- data/lib/new_relic/agent/transaction/datastore_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +1 -0
- data/lib/new_relic/agent/transaction/external_request_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +5 -11
- data/lib/new_relic/agent/transaction/segment.rb +3 -0
- data/lib/new_relic/agent/transaction.rb +7 -28
- data/lib/new_relic/agent/transaction_time_aggregator.rb +5 -5
- data/lib/new_relic/agent/vm/snapshot.rb +1 -1
- data/lib/new_relic/agent/worker_loop.rb +5 -5
- data/lib/new_relic/agent.rb +6 -5
- data/lib/new_relic/cli/commands/deployments.rb +2 -2
- data/lib/new_relic/constants.rb +0 -4
- data/lib/new_relic/noticed_error.rb +4 -4
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +10 -34
- data/lib/tasks/all.rb +1 -1
- data/newrelic.yml +580 -3
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +27 -2
- metadata +12 -11
- data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +0 -53
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -49
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -44
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +0 -33
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -125
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +0 -46
- data/lib/new_relic/agent/supported_versions.rb +0 -275
- data/lib/new_relic/control/frameworks/merb.rb +0 -29
@@ -31,7 +31,8 @@ module NewRelic::Agent::Instrumentation
|
|
31
31
|
def use_with_newrelic(middleware_class, *args, &block)
|
32
32
|
use_with_tracing(middleware_class) { |wrapped_class| use_without_newrelic(wrapped_class, *args, &block) }
|
33
33
|
end
|
34
|
-
|
34
|
+
ruby2_keywords(:use_with_newrelic) if respond_to?(:ruby2_keywords, true)
|
35
|
+
|
35
36
|
alias_method :use_without_newrelic, :use
|
36
37
|
alias_method :use, :use_with_newrelic
|
37
38
|
end
|
@@ -54,4 +55,4 @@ module NewRelic::Agent::Instrumentation
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
57
|
-
end
|
58
|
+
end
|
@@ -31,6 +31,7 @@ module NewRelic::Agent::Instrumentation
|
|
31
31
|
def use(middleware_class, *args, &blk)
|
32
32
|
use_with_tracing(middleware_class) { |wrapped_class| super(wrapped_class, *args, &blk) }
|
33
33
|
end
|
34
|
+
ruby2_keywords(:use) if respond_to?(:ruby2_keywords, true)
|
34
35
|
end
|
35
36
|
end
|
36
|
-
end
|
37
|
+
end
|
@@ -84,52 +84,16 @@ DependencyDetection.defer do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
|
-
DependencyDetection.defer do
|
88
|
-
@name = :rails30_view
|
89
|
-
|
90
|
-
depends_on do
|
91
|
-
defined?(::Rails::VERSION::MAJOR) && defined?(::Rails::VERSION::MINOR) &&
|
92
|
-
::Rails::VERSION::MAJOR.to_i == 3 && ::Rails::VERSION::MINOR.to_i == 0
|
93
|
-
end
|
94
|
-
|
95
|
-
depends_on do
|
96
|
-
!NewRelic::Agent.config[:disable_view_instrumentation]
|
97
|
-
end
|
98
|
-
|
99
|
-
executes do
|
100
|
-
::NewRelic::Agent.logger.info 'Installing Rails 3.0 view instrumentation'
|
101
|
-
end
|
102
|
-
|
103
|
-
executes do
|
104
|
-
ActionView::Template.class_eval do
|
105
|
-
include NewRelic::Agent::MethodTracer
|
106
|
-
def render_with_newrelic(*args, &block)
|
107
|
-
options = if @virtual_path && @virtual_path.starts_with?('/') # file render
|
108
|
-
{:file => true }
|
109
|
-
else
|
110
|
-
{}
|
111
|
-
end
|
112
|
-
str = "View/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.template_metric(@identifier, options)}/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.render_type(@identifier)}"
|
113
|
-
trace_execution_scoped str do
|
114
|
-
render_without_newrelic(*args, &block)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
alias_method :render_without_newrelic, :render
|
119
|
-
alias_method :render, :render_with_newrelic
|
120
|
-
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
87
|
|
88
|
+
# Though this uses the name :rails31_view, it is used only for rails 3.2 now
|
89
|
+
# Rails 3.1 is no longer supported by the agent.
|
125
90
|
DependencyDetection.defer do
|
126
91
|
@name = :rails31_view
|
127
92
|
|
128
|
-
#
|
129
|
-
# Currently enabled for Rails 3.1 and 3.2
|
93
|
+
# Enabled for Rails 3.2
|
130
94
|
depends_on do
|
131
95
|
defined?(::Rails::VERSION::MAJOR) && defined?(::Rails::VERSION::MINOR) &&
|
132
|
-
::Rails::VERSION::MAJOR.to_i == 3 &&
|
96
|
+
::Rails::VERSION::MAJOR.to_i == 3 && ::Rails::VERSION::MINOR.to_i == 2
|
133
97
|
end
|
134
98
|
|
135
99
|
depends_on do
|
@@ -137,7 +101,7 @@ DependencyDetection.defer do
|
|
137
101
|
end
|
138
102
|
|
139
103
|
executes do
|
140
|
-
::NewRelic::Agent.logger.info 'Installing Rails 3.
|
104
|
+
::NewRelic::Agent.logger.info 'Installing Rails 3.2 view instrumentation'
|
141
105
|
end
|
142
106
|
|
143
107
|
executes do
|
@@ -13,9 +13,9 @@ DependencyDetection.defer do
|
|
13
13
|
defined?(::Resque::Job) && !NewRelic::Agent.config[:disable_resque]
|
14
14
|
end
|
15
15
|
|
16
|
-
# Airbrake uses method chaining on Resque::Job
|
16
|
+
# Airbrake uses method chaining on Resque::Job on versions < 11.0.3
|
17
17
|
conflicts_with_prepend do
|
18
|
-
defined?(::Airbrake)
|
18
|
+
defined?(::Airbrake) && defined?(::Airbrake::AIRBRAKE_VERSION) && ::Gem::Version.create(::Airbrake::AIRBRAKE_VERSION) < ::Gem::Version.create('11.0.3')
|
19
19
|
end
|
20
20
|
|
21
21
|
executes do
|
@@ -60,7 +60,12 @@ DependencyDetection.defer do
|
|
60
60
|
|
61
61
|
class Sidekiq::Extensions::DelayedClass
|
62
62
|
def newrelic_trace_args(msg, queue)
|
63
|
-
(target, method_name, _args) = YAML.
|
63
|
+
(target, method_name, _args) = if YAML.respond_to?(:unsafe_load)
|
64
|
+
YAML.unsafe_load(msg['args'][0])
|
65
|
+
else
|
66
|
+
YAML.load(msg['args'][0])
|
67
|
+
end
|
68
|
+
|
64
69
|
{
|
65
70
|
:name => method_name,
|
66
71
|
:class_name => target.name,
|
@@ -0,0 +1,24 @@
|
|
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::Agent::Instrumentation
|
6
|
+
module Tilt
|
7
|
+
module Chain
|
8
|
+
def self.instrument!
|
9
|
+
::Tilt::Template.module_eval do
|
10
|
+
include NewRelic::Agent::Instrumentation::Tilt
|
11
|
+
|
12
|
+
def render_with_new_relic(*args, &block)
|
13
|
+
render_with_tracing(*args) {
|
14
|
+
render_without_newrelic(*args, &block)
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
alias render_without_newrelic render
|
19
|
+
alias render render_with_new_relic
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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
|
+
module Instrumentation
|
8
|
+
module Tilt
|
9
|
+
|
10
|
+
def metric_name(klass, file)
|
11
|
+
"View/#{klass}/#{file}/Rendering"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Sinatra uses #caller_locations for the file name in Tilt (unlike Rails/Rack)
|
15
|
+
# So here we are only grabbing the file name and name of directory it is in
|
16
|
+
def create_filename_for_metric(file)
|
17
|
+
return file unless defined?(::Sinatra) && defined?(::Sinatra::Base)
|
18
|
+
file.split('/')[-2..-1].join('/')
|
19
|
+
rescue NoMethodError
|
20
|
+
file
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_with_tracing(*args, &block)
|
24
|
+
begin
|
25
|
+
finishable = Tracer.start_segment(
|
26
|
+
name: metric_name(self.class, create_filename_for_metric(self.file))
|
27
|
+
)
|
28
|
+
begin
|
29
|
+
yield
|
30
|
+
rescue => error
|
31
|
+
NewRelic::Agent.notice_error(error)
|
32
|
+
raise
|
33
|
+
end
|
34
|
+
ensure
|
35
|
+
finishable.finish if finishable
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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::Agent::Instrumentation
|
6
|
+
module Tilt::Prepend
|
7
|
+
include NewRelic::Agent::Instrumentation::Tilt
|
8
|
+
|
9
|
+
def render(*args, &block)
|
10
|
+
render_with_tracing { super }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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
|
+
require_relative 'tilt/instrumentation'
|
6
|
+
require_relative 'tilt/chain'
|
7
|
+
require_relative 'tilt/prepend'
|
8
|
+
|
9
|
+
DependencyDetection.defer do
|
10
|
+
named :tilt
|
11
|
+
|
12
|
+
depends_on { defined?(::Tilt) }
|
13
|
+
|
14
|
+
executes do
|
15
|
+
::NewRelic::Agent.logger.info('Installing Tilt instrumentation')
|
16
|
+
end
|
17
|
+
|
18
|
+
executes do
|
19
|
+
if use_prepend?
|
20
|
+
prepend_instrument ::Tilt::Template, NewRelic::Agent::Instrumentation::Tilt::Prepend
|
21
|
+
else
|
22
|
+
chain_instrument NewRelic::Agent::Instrumentation::Tilt::Chain
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -136,9 +136,9 @@ module NewRelic
|
|
136
136
|
|
137
137
|
# NOTE: Internal prototyping may override this, so leave name stable!
|
138
138
|
def data_for_js_agent(transaction)
|
139
|
-
queue_time_in_seconds = [transaction.queue_time
|
140
|
-
start_time_in_seconds = [transaction.start_time
|
141
|
-
app_time_in_seconds =
|
139
|
+
queue_time_in_seconds = [transaction.queue_time, 0.0].max
|
140
|
+
start_time_in_seconds = [transaction.start_time, 0.0].max
|
141
|
+
app_time_in_seconds = Process.clock_gettime(Process::CLOCK_REALTIME) - start_time_in_seconds
|
142
142
|
|
143
143
|
queue_time_in_millis = (1000.0 * queue_time_in_seconds).round
|
144
144
|
app_time_in_millis = (1000.0 * app_time_in_seconds).round
|
@@ -33,6 +33,7 @@ module NewRelic
|
|
33
33
|
COLON = ':'.freeze
|
34
34
|
COMMA = ','.freeze
|
35
35
|
CLOSING_BRACE = '}'.freeze
|
36
|
+
REPLACEMENT_CHAR = '�'
|
36
37
|
|
37
38
|
def initialize
|
38
39
|
Agent.config.register_callback :app_name do
|
@@ -86,12 +87,10 @@ module NewRelic
|
|
86
87
|
message << QUOTE << key << QUOTE << COLON << QUOTE << value << QUOTE
|
87
88
|
end
|
88
89
|
|
89
|
-
def escape
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
message.inspect.to_json
|
94
|
-
end
|
90
|
+
def escape(message)
|
91
|
+
message = message.to_s unless message.is_a?(String)
|
92
|
+
message = message.scrub(REPLACEMENT_CHAR) unless message.valid_encoding?
|
93
|
+
message.to_json
|
95
94
|
end
|
96
95
|
|
97
96
|
def clear_tags!
|
@@ -110,20 +110,15 @@ module NewRelic
|
|
110
110
|
#
|
111
111
|
# @api public
|
112
112
|
#
|
113
|
-
def wrap_message_broker_consume_transaction
|
114
|
-
destination_type
|
115
|
-
destination_name
|
113
|
+
def wrap_message_broker_consume_transaction(library:,
|
114
|
+
destination_type:,
|
115
|
+
destination_name:,
|
116
116
|
headers: nil,
|
117
117
|
routing_key: nil,
|
118
118
|
queue_name: nil,
|
119
119
|
exchange_type: nil,
|
120
120
|
reply_to: nil,
|
121
|
-
correlation_id: nil
|
122
|
-
|
123
|
-
# ruby 2.0.0 does not support required kwargs
|
124
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
125
|
-
raise ArgumentError, 'missing required argument: destination_type' if destination_type.nil?
|
126
|
-
raise ArgumentError, 'missing required argument: destination_name' if destination_name.nil?
|
121
|
+
correlation_id: nil)
|
127
122
|
|
128
123
|
state = Tracer.state
|
129
124
|
return yield if state.current_transaction
|
@@ -185,17 +180,14 @@ module NewRelic
|
|
185
180
|
#
|
186
181
|
# @api public
|
187
182
|
#
|
188
|
-
def start_amqp_publish_segment(library
|
189
|
-
destination_name
|
183
|
+
def start_amqp_publish_segment(library:,
|
184
|
+
destination_name:,
|
190
185
|
headers: nil,
|
191
186
|
routing_key: nil,
|
192
187
|
reply_to: nil,
|
193
188
|
correlation_id: nil,
|
194
189
|
exchange_type: nil)
|
195
190
|
|
196
|
-
# ruby 2.0.0 does not support required kwargs
|
197
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
198
|
-
raise ArgumentError, 'missing required argument: destination_name' if destination_name.nil?
|
199
191
|
raise ArgumentError, 'missing required argument: headers' if headers.nil? && CrossAppTracing.cross_app_enabled?
|
200
192
|
|
201
193
|
original_headers = headers.nil? ? nil : headers.dup
|
@@ -247,20 +239,14 @@ module NewRelic
|
|
247
239
|
#
|
248
240
|
# @api public
|
249
241
|
#
|
250
|
-
def start_amqp_consume_segment(library
|
251
|
-
destination_name
|
252
|
-
delivery_info
|
253
|
-
message_properties
|
242
|
+
def start_amqp_consume_segment(library:,
|
243
|
+
destination_name:,
|
244
|
+
delivery_info:,
|
245
|
+
message_properties:,
|
254
246
|
exchange_type: nil,
|
255
247
|
queue_name: nil,
|
256
248
|
start_time: nil)
|
257
249
|
|
258
|
-
# ruby 2.0.0 does not support required kwargs
|
259
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
260
|
-
raise ArgumentError, 'missing required argument: destination_name' if destination_name.nil?
|
261
|
-
raise ArgumentError, 'missing required argument: delivery_info' if delivery_info.nil?
|
262
|
-
raise ArgumentError, 'missing required argument: message_properties' if message_properties.nil?
|
263
|
-
|
264
250
|
segment = Tracer.start_message_broker_segment(
|
265
251
|
action: :consume,
|
266
252
|
library: library,
|