newrelic_rpm 6.14.0 → 6.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -2
- data/lib/new_relic/agent.rb +1 -0
- data/lib/new_relic/agent/agent.rb +2 -4
- data/lib/new_relic/agent/configuration/default_source.rb +13 -1
- data/lib/new_relic/agent/database_adapter.rb +33 -0
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +21 -68
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +23 -57
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -15
- data/lib/new_relic/agent/instrumentation/bunny.rb +27 -71
- data/lib/new_relic/agent/instrumentation/curb.rb +12 -30
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +8 -21
- data/lib/new_relic/agent/instrumentation/net.rb +33 -57
- data/lib/new_relic/agent/instrumentation/net_prepend.rb +21 -53
- data/lib/new_relic/agent/instrumentation/padrino.rb +15 -37
- data/lib/new_relic/agent/instrumentation/rack.rb +6 -17
- data/lib/new_relic/agent/instrumentation/rake.rb +19 -53
- data/lib/new_relic/agent/instrumentation/redis.rb +59 -138
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +22 -62
- data/lib/new_relic/agent/span_event_primitive.rb +10 -8
- data/lib/new_relic/agent/transaction/abstract_segment.rb +1 -1
- data/lib/new_relic/agent/vm/mri_vm.rb +6 -4
- data/lib/new_relic/cli/commands/deployments.rb +0 -1
- data/lib/new_relic/dependency_detection.rb +4 -0
- data/lib/new_relic/environment_report.rb +1 -13
- data/lib/new_relic/supportability_helper.rb +1 -0
- data/lib/new_relic/version.rb +1 -1
- data/test/agent_helper.rb +1 -0
- metadata +3 -2
@@ -32,48 +32,30 @@ DependencyDetection.defer do
|
|
32
32
|
|
33
33
|
# We have to hook these three methods separately, as they don't use
|
34
34
|
# Curl::Easy#http
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
http_head_without_newrelic(*args, &blk)
|
39
|
-
end
|
40
|
-
else
|
41
|
-
def http_head_with_newrelic(*args, **kwargs, &blk)
|
42
|
-
self._nr_http_verb = :HEAD
|
43
|
-
http_head_without_newrelic(*args, **kwargs, &blk)
|
44
|
-
end
|
35
|
+
def http_head_with_newrelic(*args, &blk)
|
36
|
+
self._nr_http_verb = :HEAD
|
37
|
+
http_head_without_newrelic(*args, &blk)
|
45
38
|
end
|
46
39
|
|
40
|
+
|
47
41
|
alias_method :http_head_without_newrelic, :http_head
|
48
42
|
alias_method :http_head, :http_head_with_newrelic
|
49
43
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
http_post_without_newrelic(*args, &blk)
|
54
|
-
end
|
55
|
-
else
|
56
|
-
def http_post_with_newrelic(*args, **kwargs, &blk)
|
57
|
-
self._nr_http_verb = :POST
|
58
|
-
http_post_without_newrelic(*args, **kwargs, &blk)
|
59
|
-
end
|
44
|
+
def http_post_with_newrelic(*args, &blk)
|
45
|
+
self._nr_http_verb = :POST
|
46
|
+
http_post_without_newrelic(*args, &blk)
|
60
47
|
end
|
61
48
|
|
49
|
+
|
62
50
|
alias_method :http_post_without_newrelic, :http_post
|
63
51
|
alias_method :http_post, :http_post_with_newrelic
|
64
52
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
http_put_without_newrelic(*args, &blk)
|
69
|
-
end
|
70
|
-
else
|
71
|
-
def http_put_with_newrelic(*args, **kwargs, &blk)
|
72
|
-
self._nr_http_verb = :PUT
|
73
|
-
http_put_without_newrelic(*args, **kwargs, &blk)
|
74
|
-
end
|
53
|
+
def http_put_with_newrelic(*args, &blk)
|
54
|
+
self._nr_http_verb = :PUT
|
55
|
+
http_put_without_newrelic(*args, &blk)
|
75
56
|
end
|
76
57
|
|
58
|
+
|
77
59
|
alias_method :http_put_without_newrelic, :http_put
|
78
60
|
alias_method :http_put, :http_put_with_newrelic
|
79
61
|
|
@@ -120,27 +120,14 @@ DependencyDetection.defer do
|
|
120
120
|
|
121
121
|
alias_method :invoke_job_without_new_relic, :invoke_job
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
invoke_job_without_new_relic(*args, &block)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
else
|
135
|
-
def invoke_job(*args, **kwargs, &block)
|
136
|
-
options = {
|
137
|
-
:category => NR_TRANSACTION_CATEGORY,
|
138
|
-
:path => ::NewRelic::Agent::Instrumentation::DelayedJob::Naming.name_from_payload(payload_object)
|
139
|
-
}
|
140
|
-
|
141
|
-
perform_action_with_newrelic_trace(options) do
|
142
|
-
invoke_job_without_new_relic(*args, **kwargs, &block)
|
143
|
-
end
|
123
|
+
def invoke_job(*args, &block)
|
124
|
+
options = {
|
125
|
+
:category => NR_TRANSACTION_CATEGORY,
|
126
|
+
:path => ::NewRelic::Agent::Instrumentation::DelayedJob::Naming.name_from_payload(payload_object)
|
127
|
+
}
|
128
|
+
|
129
|
+
perform_action_with_newrelic_trace(options) do
|
130
|
+
invoke_job_without_new_relic(*args, &block)
|
144
131
|
end
|
145
132
|
end
|
146
133
|
|
@@ -15,8 +15,14 @@ DependencyDetection.defer do
|
|
15
15
|
require 'new_relic/agent/http_clients/net_http_wrappers'
|
16
16
|
end
|
17
17
|
|
18
|
+
def monkey_patched
|
19
|
+
defined?(::Airbrake) ||
|
20
|
+
defined?(::Rack::MiniProfiler) ||
|
21
|
+
source_location_for(Net::HTTP, "request") =~ /airbrake|profiler/i
|
22
|
+
end
|
23
|
+
|
18
24
|
executes do
|
19
|
-
if ::NewRelic::Agent.config[:prepend_net_instrumentation]
|
25
|
+
if ::NewRelic::Agent.config[:prepend_net_instrumentation] && !monkey_patched
|
20
26
|
if RUBY_VERSION < "2.1.0"
|
21
27
|
::Net::HTTP.send(:prepend, ::NewRelic::Agent::Instrumentation::NetPrepend)
|
22
28
|
else
|
@@ -24,66 +30,36 @@ DependencyDetection.defer do
|
|
24
30
|
end
|
25
31
|
else
|
26
32
|
NewRelic::Agent.record_metric("Supportability/Instrumentation/NetHTTP/MethodChaining", 0.0)
|
33
|
+
|
27
34
|
class Net::HTTP
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
NewRelic::Agent.
|
45
|
-
|
46
|
-
request_without_newrelic_trace(request, *args, &block)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
wrapped_response = NewRelic::Agent::HTTPClients::NetHTTPResponse.new response
|
51
|
-
segment.process_response_headers wrapped_response
|
52
|
-
response
|
53
|
-
ensure
|
54
|
-
segment.finish
|
55
|
-
end
|
56
|
-
end
|
57
|
-
else
|
58
|
-
def request_with_newrelic_trace(request, *args, **kwargs, &block)
|
59
|
-
wrapped_request = NewRelic::Agent::HTTPClients::NetHTTPRequest.new(self, request)
|
60
|
-
|
61
|
-
segment = NewRelic::Agent::Tracer.start_external_request_segment(
|
62
|
-
library: wrapped_request.type,
|
63
|
-
uri: wrapped_request.uri,
|
64
|
-
procedure: wrapped_request.method
|
65
|
-
)
|
66
|
-
|
67
|
-
begin
|
68
|
-
response = nil
|
69
|
-
segment.add_request_headers wrapped_request
|
70
|
-
|
71
|
-
# RUBY-1244 Disable further tracing in request to avoid double
|
72
|
-
# counting if connection wasn't started (which calls request again).
|
73
|
-
NewRelic::Agent.disable_all_tracing do
|
74
|
-
response = NewRelic::Agent::Tracer.capture_segment_error segment do
|
75
|
-
request_without_newrelic_trace(request, *args, **kwargs, &block)
|
76
|
-
end
|
35
|
+
def request_with_newrelic_trace(request, *args, &block)
|
36
|
+
wrapped_request = NewRelic::Agent::HTTPClients::NetHTTPRequest.new(self, request)
|
37
|
+
|
38
|
+
segment = NewRelic::Agent::Tracer.start_external_request_segment(
|
39
|
+
library: wrapped_request.type,
|
40
|
+
uri: wrapped_request.uri,
|
41
|
+
procedure: wrapped_request.method
|
42
|
+
)
|
43
|
+
|
44
|
+
begin
|
45
|
+
response = nil
|
46
|
+
segment.add_request_headers wrapped_request
|
47
|
+
|
48
|
+
# RUBY-1244 Disable further tracing in request to avoid double
|
49
|
+
# counting if connection wasn't started (which calls request again).
|
50
|
+
NewRelic::Agent.disable_all_tracing do
|
51
|
+
response = NewRelic::Agent::Tracer.capture_segment_error segment do
|
52
|
+
request_without_newrelic_trace(request, *args, &block)
|
77
53
|
end
|
78
|
-
|
79
|
-
wrapped_response = NewRelic::Agent::HTTPClients::NetHTTPResponse.new response
|
80
|
-
segment.process_response_headers wrapped_response
|
81
|
-
response
|
82
|
-
ensure
|
83
|
-
segment.finish
|
84
54
|
end
|
55
|
+
|
56
|
+
wrapped_response = NewRelic::Agent::HTTPClients::NetHTTPResponse.new response
|
57
|
+
segment.process_response_headers wrapped_response
|
58
|
+
response
|
59
|
+
ensure
|
60
|
+
segment.finish
|
85
61
|
end
|
86
|
-
end
|
62
|
+
end
|
87
63
|
|
88
64
|
alias request_without_newrelic_trace request
|
89
65
|
alias request request_with_newrelic_trace
|
@@ -6,64 +6,32 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
module Instrumentation
|
8
8
|
module NetPrepend
|
9
|
+
def request(request, *args, &block)
|
10
|
+
wrapped_request = NewRelic::Agent::HTTPClients::NetHTTPRequest.new(self, request)
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
wrapped_request
|
12
|
+
segment = NewRelic::Agent::Tracer.start_external_request_segment(
|
13
|
+
library: wrapped_request.type,
|
14
|
+
uri: wrapped_request.uri,
|
15
|
+
procedure: wrapped_request.method
|
16
|
+
)
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
procedure: wrapped_request.method
|
18
|
-
)
|
19
|
-
|
20
|
-
begin
|
21
|
-
response = nil
|
22
|
-
segment.add_request_headers wrapped_request
|
23
|
-
|
24
|
-
# RUBY-1244 Disable further tracing in request to avoid double
|
25
|
-
# counting if connection wasn't started (which calls request again).
|
26
|
-
NewRelic::Agent.disable_all_tracing do
|
27
|
-
response = NewRelic::Agent::Tracer.capture_segment_error segment do
|
28
|
-
super
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
wrapped_response = NewRelic::Agent::HTTPClients::NetHTTPResponse.new response
|
33
|
-
segment.process_response_headers wrapped_response
|
34
|
-
response
|
35
|
-
ensure
|
36
|
-
segment.finish
|
37
|
-
end
|
38
|
-
end
|
39
|
-
else
|
40
|
-
def request(request, *args, **kwargs, &block)
|
41
|
-
wrapped_request = NewRelic::Agent::HTTPClients::NetHTTPRequest.new(self, request)
|
18
|
+
begin
|
19
|
+
response = nil
|
20
|
+
segment.add_request_headers wrapped_request
|
42
21
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
begin
|
50
|
-
response = nil
|
51
|
-
segment.add_request_headers wrapped_request
|
52
|
-
|
53
|
-
# RUBY-1244 Disable further tracing in request to avoid double
|
54
|
-
# counting if connection wasn't started (which calls request again).
|
55
|
-
NewRelic::Agent.disable_all_tracing do
|
56
|
-
response = NewRelic::Agent::Tracer.capture_segment_error segment do
|
57
|
-
super
|
58
|
-
end
|
22
|
+
# RUBY-1244 Disable further tracing in request to avoid double
|
23
|
+
# counting if connection wasn't started (which calls request again).
|
24
|
+
NewRelic::Agent.disable_all_tracing do
|
25
|
+
response = NewRelic::Agent::Tracer.capture_segment_error segment do
|
26
|
+
super
|
59
27
|
end
|
60
|
-
|
61
|
-
wrapped_response = NewRelic::Agent::HTTPClients::NetHTTPResponse.new response
|
62
|
-
segment.process_response_headers wrapped_response
|
63
|
-
response
|
64
|
-
ensure
|
65
|
-
segment.finish
|
66
28
|
end
|
29
|
+
|
30
|
+
wrapped_response = NewRelic::Agent::HTTPClients::NetHTTPResponse.new response
|
31
|
+
segment.process_response_headers wrapped_response
|
32
|
+
response
|
33
|
+
ensure
|
34
|
+
segment.finish
|
67
35
|
end
|
68
36
|
end
|
69
37
|
end
|
@@ -44,46 +44,24 @@ module NewRelic
|
|
44
44
|
module Instrumentation
|
45
45
|
module Padrino
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
::NewRelic::Agent.logger.debug("Failed determining last route in Padrino", e)
|
53
|
-
end
|
54
|
-
|
55
|
-
begin
|
56
|
-
txn_name = ::NewRelic::Agent::Instrumentation::Sinatra::TransactionNamer.transaction_name_for_route(env, request)
|
57
|
-
unless txn_name.nil?
|
58
|
-
::NewRelic::Agent::Transaction.set_default_transaction_name(
|
59
|
-
"#{self.class.name}/#{txn_name}", :sinatra)
|
60
|
-
end
|
61
|
-
rescue => e
|
62
|
-
::NewRelic::Agent.logger.debug("Failed during invoke_route to set transaction name", e)
|
63
|
-
end
|
64
|
-
|
65
|
-
invoke_route_without_newrelic(*args, &block)
|
47
|
+
def invoke_route_with_newrelic(*args, &block)
|
48
|
+
begin
|
49
|
+
env["newrelic.last_route"] = args[0].original_path
|
50
|
+
rescue => e
|
51
|
+
::NewRelic::Agent.logger.debug("Failed determining last route in Padrino", e)
|
66
52
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
begin
|
76
|
-
txn_name = ::NewRelic::Agent::Instrumentation::Sinatra::TransactionNamer.transaction_name_for_route(env, request)
|
77
|
-
unless txn_name.nil?
|
78
|
-
::NewRelic::Agent::Transaction.set_default_transaction_name(
|
79
|
-
"#{self.class.name}/#{txn_name}", :sinatra)
|
80
|
-
end
|
81
|
-
rescue => e
|
82
|
-
::NewRelic::Agent.logger.debug("Failed during invoke_route to set transaction name", e)
|
53
|
+
|
54
|
+
begin
|
55
|
+
txn_name = ::NewRelic::Agent::Instrumentation::Sinatra::TransactionNamer.transaction_name_for_route(env, request)
|
56
|
+
unless txn_name.nil?
|
57
|
+
::NewRelic::Agent::Transaction.set_default_transaction_name(
|
58
|
+
"#{self.class.name}/#{txn_name}", :sinatra)
|
83
59
|
end
|
84
|
-
|
85
|
-
|
60
|
+
rescue => e
|
61
|
+
::NewRelic::Agent.logger.debug("Failed during invoke_route to set transaction name", e)
|
86
62
|
end
|
63
|
+
|
64
|
+
invoke_route_without_newrelic(*args, &block)
|
87
65
|
end
|
88
66
|
|
89
67
|
end
|
@@ -82,23 +82,12 @@ module NewRelic
|
|
82
82
|
|
83
83
|
module RackBuilder
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
run_without_newrelic(app, *args)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
else
|
95
|
-
def run_with_newrelic(app, *args, **kwargs)
|
96
|
-
if ::NewRelic::Agent::Instrumentation::RackHelpers.middleware_instrumentation_enabled?
|
97
|
-
wrapped_app = ::NewRelic::Agent::Instrumentation::MiddlewareProxy.wrap(app, true)
|
98
|
-
run_without_newrelic(wrapped_app, *args, **kwargs)
|
99
|
-
else
|
100
|
-
run_without_newrelic(app, *args, **kwargs)
|
101
|
-
end
|
85
|
+
def run_with_newrelic(app, *args)
|
86
|
+
if ::NewRelic::Agent::Instrumentation::RackHelpers.middleware_instrumentation_enabled?
|
87
|
+
wrapped_app = ::NewRelic::Agent::Instrumentation::MiddlewareProxy.wrap(app, true)
|
88
|
+
run_without_newrelic(wrapped_app, *args)
|
89
|
+
else
|
90
|
+
run_without_newrelic(app, *args)
|
102
91
|
end
|
103
92
|
end
|
104
93
|
|
@@ -24,51 +24,26 @@ DependencyDetection.defer do
|
|
24
24
|
class Task
|
25
25
|
alias_method :invoke_without_newrelic, :invoke
|
26
26
|
|
27
|
+
def invoke(*args)
|
28
|
+
unless NewRelic::Agent::Instrumentation::RakeInstrumentation.should_trace? name
|
29
|
+
return invoke_without_newrelic(*args)
|
30
|
+
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
begin
|
35
|
-
timeout = NewRelic::Agent.config[:'rake.connect_timeout']
|
36
|
-
NewRelic::Agent.instance.wait_on_connect(timeout)
|
37
|
-
rescue => e
|
38
|
-
NewRelic::Agent.logger.error("Exception in wait_on_connect", e)
|
39
|
-
return invoke_without_newrelic(*args)
|
40
|
-
end
|
41
|
-
|
42
|
-
NewRelic::Agent::Instrumentation::RakeInstrumentation.before_invoke_transaction(self)
|
43
|
-
|
44
|
-
NewRelic::Agent::Tracer.in_transaction(name: "OtherTransaction/Rake/invoke/#{name}", category: :rake) do
|
45
|
-
NewRelic::Agent::Instrumentation::RakeInstrumentation.record_attributes(args, self)
|
46
|
-
invoke_without_newrelic(*args)
|
47
|
-
end
|
32
|
+
begin
|
33
|
+
timeout = NewRelic::Agent.config[:'rake.connect_timeout']
|
34
|
+
NewRelic::Agent.instance.wait_on_connect(timeout)
|
35
|
+
rescue => e
|
36
|
+
NewRelic::Agent.logger.error("Exception in wait_on_connect", e)
|
37
|
+
return invoke_without_newrelic(*args)
|
48
38
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
begin
|
56
|
-
timeout = NewRelic::Agent.config[:'rake.connect_timeout']
|
57
|
-
NewRelic::Agent.instance.wait_on_connect(timeout)
|
58
|
-
rescue => e
|
59
|
-
NewRelic::Agent.logger.error("Exception in wait_on_connect", e)
|
60
|
-
return invoke_without_newrelic(*args, **kwargs)
|
61
|
-
end
|
62
|
-
|
63
|
-
NewRelic::Agent::Instrumentation::RakeInstrumentation.before_invoke_transaction(self)
|
64
|
-
|
65
|
-
NewRelic::Agent::Tracer.in_transaction(name: "OtherTransaction/Rake/invoke/#{name}", category: :rake) do
|
66
|
-
NewRelic::Agent::Instrumentation::RakeInstrumentation.record_attributes(args, self)
|
67
|
-
invoke_without_newrelic(*args, **kwargs)
|
68
|
-
end
|
39
|
+
|
40
|
+
NewRelic::Agent::Instrumentation::RakeInstrumentation.before_invoke_transaction(self)
|
41
|
+
|
42
|
+
NewRelic::Agent::Tracer.in_transaction(name: "OtherTransaction/Rake/invoke/#{name}", category: :rake) do
|
43
|
+
NewRelic::Agent::Instrumentation::RakeInstrumentation.record_attributes(args, self)
|
44
|
+
invoke_without_newrelic(*args)
|
69
45
|
end
|
70
46
|
end
|
71
|
-
|
72
47
|
end
|
73
48
|
end
|
74
49
|
end
|
@@ -112,20 +87,11 @@ module NewRelic
|
|
112
87
|
|
113
88
|
task.instance_variable_set(:@__newrelic_instrumented_execute, true)
|
114
89
|
task.instance_eval do
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
super
|
119
|
-
end
|
120
|
-
end
|
121
|
-
else
|
122
|
-
def execute(*args, **kwargs, &block)
|
123
|
-
NewRelic::Agent::MethodTracer.trace_execution_scoped("Rake/execute/#{self.name}") do
|
124
|
-
super
|
125
|
-
end
|
90
|
+
def execute(*args, &block)
|
91
|
+
NewRelic::Agent::MethodTracer.trace_execution_scoped("Rake/execute/#{self.name}") do
|
92
|
+
super
|
126
93
|
end
|
127
94
|
end
|
128
|
-
|
129
95
|
end
|
130
96
|
|
131
97
|
instrument_execute_on_prereqs(task)
|