newrelic_rpm 6.12.0.367 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/CHANGELOG.md +269 -8
- data/CONTRIBUTING.md +54 -11
- data/README.md +40 -16
- data/ROADMAP.md +24 -0
- data/lib/new_relic/agent.rb +3 -10
- data/lib/new_relic/agent/agent.rb +6 -4
- data/lib/new_relic/agent/audit_logger.rb +10 -0
- data/lib/new_relic/agent/autostart.rb +1 -2
- data/lib/new_relic/agent/configuration/default_source.rb +294 -102
- data/lib/new_relic/agent/configuration/manager.rb +2 -2
- data/lib/new_relic/agent/database_adapter.rb +33 -0
- data/lib/new_relic/agent/datastores/redis.rb +0 -4
- data/lib/new_relic/agent/distributed_tracing.rb +0 -66
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +2 -2
- data/lib/new_relic/agent/http_clients/uri_util.rb +8 -8
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +4 -5
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +21 -68
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +0 -16
- 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 +10 -196
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +45 -0
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +152 -0
- data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/curb.rb +9 -259
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +93 -0
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +222 -0
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +63 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +38 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +53 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +34 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +8 -84
- data/lib/new_relic/agent/instrumentation/excon.rb +2 -1
- data/lib/new_relic/agent/instrumentation/grape.rb +13 -113
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +100 -0
- data/lib/new_relic/agent/instrumentation/grape/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/httpclient.rb +8 -30
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +38 -0
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/httprb.rb +29 -0
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +30 -0
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +54 -69
- data/lib/new_relic/agent/instrumentation/memcache/chain.rb +16 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +38 -121
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +56 -0
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +88 -0
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +88 -0
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +4 -10
- data/lib/new_relic/agent/instrumentation/mongo.rb +7 -0
- data/lib/new_relic/agent/instrumentation/net_http.rb +39 -0
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +40 -0
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +21 -0
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino.rb +18 -75
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +34 -0
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +27 -0
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +20 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +29 -160
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +57 -0
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +32 -0
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +73 -0
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +36 -0
- data/lib/new_relic/agent/instrumentation/rake.rb +13 -187
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +144 -0
- data/lib/new_relic/agent/instrumentation/rake/prepend.rb +14 -0
- data/lib/new_relic/agent/instrumentation/redis.rb +10 -188
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +34 -0
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +65 -0
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +24 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +8 -28
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +33 -0
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +16 -0
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +20 -198
- data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +29 -34
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +118 -0
- data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +10 -89
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +82 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +14 -0
- data/lib/new_relic/agent/method_tracer.rb +6 -16
- data/lib/new_relic/agent/new_relic_service.rb +19 -5
- data/lib/new_relic/agent/samplers/memory_sampler.rb +1 -1
- data/lib/new_relic/agent/span_event_primitive.rb +10 -8
- data/lib/new_relic/agent/sql_sampler.rb +1 -1
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +1 -4
- data/lib/new_relic/agent/transaction/abstract_segment.rb +1 -1
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +12 -6
- data/lib/new_relic/agent/transaction/external_request_segment.rb +2 -2
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -0
- data/lib/new_relic/agent/transaction/segment.rb +9 -5
- 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/constants.rb +4 -0
- data/lib/new_relic/control/frameworks/rails.rb +11 -9
- data/lib/new_relic/control/instance_methods.rb +1 -0
- data/lib/new_relic/dependency_detection.rb +119 -9
- data/lib/new_relic/environment_report.rb +1 -7
- data/lib/new_relic/noticed_error.rb +1 -5
- data/lib/new_relic/supportability_helper.rb +3 -2
- data/lib/new_relic/version.rb +2 -2
- data/lib/tasks/multiverse.rb +9 -0
- data/newrelic_rpm.gemspec +2 -3
- data/test/agent_helper.rb +7 -0
- metadata +55 -12
- data/.travis.yml +0 -240
- data/CODE_OF_CONDUCT.md +0 -46
- data/cert/cacert.pem +0 -1177
- data/lib/new_relic/agent/instrumentation/http.rb +0 -49
- data/lib/new_relic/agent/instrumentation/net.rb +0 -87
- data/lib/new_relic/metrics.rb +0 -13
@@ -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::Agent::Instrumentation
|
6
|
+
module Sinatra
|
7
|
+
module Prepend
|
8
|
+
include ::NewRelic::Agent::Instrumentation::Sinatra::Tracer
|
9
|
+
|
10
|
+
def dispatch!
|
11
|
+
dispatch_with_tracing { super }
|
12
|
+
end
|
13
|
+
|
14
|
+
def process_route(*args, &block)
|
15
|
+
process_route_with_tracing(*args) { super }
|
16
|
+
end
|
17
|
+
|
18
|
+
def route_eval(*args, &block)
|
19
|
+
route_eval_with_tracing(*args) { super }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Build
|
24
|
+
module Prepend
|
25
|
+
include ::NewRelic::Agent::Instrumentation::Sinatra::Tracer
|
26
|
+
|
27
|
+
def build(*args, &block)
|
28
|
+
build_with_tracing(*args) { super }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -2,6 +2,10 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
4
|
|
5
|
+
require_relative 'typhoeus/instrumentation'
|
6
|
+
require_relative 'typhoeus/chain'
|
7
|
+
require_relative 'typhoeus/prepend'
|
8
|
+
|
5
9
|
DependencyDetection.defer do
|
6
10
|
named :typhoeus
|
7
11
|
|
@@ -10,7 +14,7 @@ DependencyDetection.defer do
|
|
10
14
|
end
|
11
15
|
|
12
16
|
depends_on do
|
13
|
-
NewRelic::Agent::Instrumentation::
|
17
|
+
NewRelic::Agent::Instrumentation::Typhoeus.is_supported_version?
|
14
18
|
end
|
15
19
|
|
16
20
|
executes do
|
@@ -22,7 +26,7 @@ DependencyDetection.defer do
|
|
22
26
|
# Basic request tracing
|
23
27
|
executes do
|
24
28
|
Typhoeus.before do |request|
|
25
|
-
NewRelic::Agent::Instrumentation::
|
29
|
+
NewRelic::Agent::Instrumentation::Typhoeus.trace(request)
|
26
30
|
|
27
31
|
# Ensure that we always return a truthy value from the before block,
|
28
32
|
# otherwise Typhoeus will bail out of the instrumentation.
|
@@ -32,93 +36,10 @@ DependencyDetection.defer do
|
|
32
36
|
|
33
37
|
# Apply single TT node for Hydra requests until async support
|
34
38
|
executes do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
name: NewRelic::Agent::Instrumentation::TyphoeusTracing::HYDRA_SEGMENT_NAME
|
40
|
-
)
|
41
|
-
|
42
|
-
instance_variable_set :@__newrelic_hydra_segment, segment
|
43
|
-
|
44
|
-
begin
|
45
|
-
run_without_newrelic(*args)
|
46
|
-
ensure
|
47
|
-
segment.finish if segment
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
alias run_without_newrelic run
|
52
|
-
alias run run_with_newrelic
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
module NewRelic
|
59
|
-
module Agent
|
60
|
-
module Instrumentation
|
61
|
-
module TyphoeusTracing
|
62
|
-
|
63
|
-
HYDRA_SEGMENT_NAME = "External/Multiple/Typhoeus::Hydra/run"
|
64
|
-
NOTICIBLE_ERROR_CLASS = "Typhoeus::Errors::TyphoeusError"
|
65
|
-
|
66
|
-
EARLIEST_VERSION = Gem::Version.new("0.5.3")
|
67
|
-
def self.is_supported_version?
|
68
|
-
Gem::Version.new(Typhoeus::VERSION) >= NewRelic::Agent::Instrumentation::TyphoeusTracing::EARLIEST_VERSION
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.request_is_hydra_enabled?(request)
|
72
|
-
request.respond_to?(:hydra) && request.hydra
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.response_message(response)
|
76
|
-
if response.respond_to?(:response_message)
|
77
|
-
response.response_message
|
78
|
-
elsif response.respond_to?(:return_message)
|
79
|
-
response.return_message
|
80
|
-
else
|
81
|
-
# 0.5.4 seems to have lost xxxx_message methods altogether.
|
82
|
-
"timeout"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.trace(request)
|
87
|
-
state = NewRelic::Agent::Tracer.state
|
88
|
-
return unless state.is_execution_traced?
|
89
|
-
|
90
|
-
wrapped_request = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest.new(request)
|
91
|
-
|
92
|
-
parent = if request_is_hydra_enabled?(request)
|
93
|
-
request.hydra.instance_variable_get(:@__newrelic_hydra_segment)
|
94
|
-
end
|
95
|
-
|
96
|
-
segment = NewRelic::Agent::Tracer.start_external_request_segment(
|
97
|
-
library: wrapped_request.type,
|
98
|
-
uri: wrapped_request.uri,
|
99
|
-
procedure: wrapped_request.method,
|
100
|
-
parent: parent
|
101
|
-
)
|
102
|
-
|
103
|
-
segment.add_request_headers wrapped_request
|
104
|
-
|
105
|
-
callback = Proc.new do
|
106
|
-
wrapped_response = HTTPClients::TyphoeusHTTPResponse.new(request.response)
|
107
|
-
|
108
|
-
segment.process_response_headers wrapped_response
|
109
|
-
|
110
|
-
if request.response.code == 0
|
111
|
-
segment.notice_error NoticibleError.new NOTICIBLE_ERROR_CLASS, response_message(request.response)
|
112
|
-
end
|
113
|
-
|
114
|
-
segment.finish if segment
|
115
|
-
end
|
116
|
-
request.on_complete.unshift(callback)
|
117
|
-
|
118
|
-
rescue => e
|
119
|
-
NewRelic::Agent.logger.error("Exception during trace setup for Typhoeus request", e)
|
120
|
-
end
|
121
|
-
end
|
39
|
+
if use_prepend?
|
40
|
+
prepend_instrument Typhoeus::Hydra, NewRelic::Agent::Instrumentation::Typhoeus::Prepend
|
41
|
+
else
|
42
|
+
chain_instrument NewRelic::Agent::Instrumentation::Typhoeus::Chain
|
122
43
|
end
|
123
44
|
end
|
124
45
|
end
|
@@ -0,0 +1,22 @@
|
|
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 Typhoeus
|
7
|
+
module Chain
|
8
|
+
def self.instrument!
|
9
|
+
::Typhoeus::Hydra.class_eval do
|
10
|
+
include NewRelic::Agent::Instrumentation::Typhoeus
|
11
|
+
|
12
|
+
def run_with_newrelic(*args)
|
13
|
+
with_tracing { run_without_newrelic(*args) }
|
14
|
+
end
|
15
|
+
|
16
|
+
alias run_without_newrelic run
|
17
|
+
alias run run_with_newrelic
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,82 @@
|
|
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 Typhoeus
|
9
|
+
|
10
|
+
HYDRA_SEGMENT_NAME = "External/Multiple/Typhoeus::Hydra/run"
|
11
|
+
NOTICIBLE_ERROR_CLASS = "Typhoeus::Errors::TyphoeusError"
|
12
|
+
|
13
|
+
EARLIEST_VERSION = Gem::Version.new("0.5.3")
|
14
|
+
|
15
|
+
def self.is_supported_version?
|
16
|
+
Gem::Version.new(::Typhoeus::VERSION) >= EARLIEST_VERSION
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.request_is_hydra_enabled?(request)
|
20
|
+
request.respond_to?(:hydra) && request.hydra
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.response_message(response)
|
24
|
+
if response.respond_to?(:response_message)
|
25
|
+
response.response_message
|
26
|
+
elsif response.respond_to?(:return_message)
|
27
|
+
response.return_message
|
28
|
+
else
|
29
|
+
# 0.5.4 seems to have lost xxxx_message methods altogether.
|
30
|
+
"timeout"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def with_tracing
|
35
|
+
segment = NewRelic::Agent::Tracer.start_segment name: HYDRA_SEGMENT_NAME
|
36
|
+
instance_variable_set :@__newrelic_hydra_segment, segment
|
37
|
+
begin
|
38
|
+
yield
|
39
|
+
ensure
|
40
|
+
segment.finish if segment
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.trace(request)
|
45
|
+
state = NewRelic::Agent::Tracer.state
|
46
|
+
return unless state.is_execution_traced?
|
47
|
+
|
48
|
+
wrapped_request = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest.new(request)
|
49
|
+
|
50
|
+
parent = if request_is_hydra_enabled?(request)
|
51
|
+
request.hydra.instance_variable_get(:@__newrelic_hydra_segment)
|
52
|
+
end
|
53
|
+
|
54
|
+
segment = NewRelic::Agent::Tracer.start_external_request_segment(
|
55
|
+
library: wrapped_request.type,
|
56
|
+
uri: wrapped_request.uri,
|
57
|
+
procedure: wrapped_request.method,
|
58
|
+
parent: parent
|
59
|
+
)
|
60
|
+
|
61
|
+
segment.add_request_headers wrapped_request
|
62
|
+
|
63
|
+
callback = Proc.new do
|
64
|
+
wrapped_response = HTTPClients::TyphoeusHTTPResponse.new(request.response)
|
65
|
+
|
66
|
+
segment.process_response_headers wrapped_response
|
67
|
+
|
68
|
+
if request.response.code == 0
|
69
|
+
segment.notice_error NoticibleError.new NOTICIBLE_ERROR_CLASS, response_message(request.response)
|
70
|
+
end
|
71
|
+
|
72
|
+
segment.finish if segment
|
73
|
+
end
|
74
|
+
request.on_complete.unshift(callback)
|
75
|
+
|
76
|
+
rescue => e
|
77
|
+
NewRelic::Agent.logger.error("Exception during trace setup for Typhoeus request", e)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,14 @@
|
|
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 Typhoeus
|
7
|
+
module Prepend
|
8
|
+
include NewRelic::Agent::Instrumentation::Typhoeus
|
9
|
+
def run(*args)
|
10
|
+
with_tracing { super }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -173,30 +173,20 @@ module NewRelic
|
|
173
173
|
# instrumentation into effectively one method call overhead
|
174
174
|
# when the agent is disabled
|
175
175
|
def assemble_code_header(method_name, metric_name_code, options)
|
176
|
-
header = "return #{_untraced_method_name(method_name, metric_name_code)}(
|
176
|
+
header = "return #{_untraced_method_name(method_name, metric_name_code)}(#{ARGS_FOR_RUBY_VERSION}) unless NewRelic::Agent.tl_is_execution_traced?\n"
|
177
177
|
header += options[:code_header].to_s
|
178
178
|
header
|
179
179
|
end
|
180
180
|
|
181
|
-
# Positional and Keyword arguments are separated beginning with Ruby 2.7
|
182
|
-
def arguments_for_ruby_version
|
183
|
-
if RUBY_VERSION < "2.7.0"
|
184
|
-
"(*args, &block)"
|
185
|
-
else
|
186
|
-
"(*args, **kwargs, &block)"
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
181
|
# returns an eval-able string that contains the traced
|
191
182
|
# method code used if the agent is not creating a scope for
|
192
183
|
# use in scoped metrics.
|
193
184
|
def method_without_push_scope(method_name, metric_name_code, options)
|
194
|
-
|
195
|
-
"def #{_traced_method_name(method_name, metric_name_code)}#{arguments}
|
185
|
+
"def #{_traced_method_name(method_name, metric_name_code)}(#{ARGS_FOR_RUBY_VERSION})
|
196
186
|
#{assemble_code_header(method_name, metric_name_code, options)}
|
197
187
|
t0 = Time.now
|
198
188
|
begin
|
199
|
-
#{_untraced_method_name(method_name, metric_name_code)}#{
|
189
|
+
#{_untraced_method_name(method_name, metric_name_code)}(#{ARGS_FOR_RUBY_VERSION})\n
|
200
190
|
ensure
|
201
191
|
duration = (Time.now - t0).to_f
|
202
192
|
NewRelic::Agent.record_metric(\"#{metric_name_code}\", duration)
|
@@ -208,12 +198,11 @@ module NewRelic
|
|
208
198
|
# returns an eval-able string that contains the tracing code
|
209
199
|
# for a fully traced metric including scoping
|
210
200
|
def method_with_push_scope(method_name, metric_name_code, options)
|
211
|
-
|
212
|
-
"def #{_traced_method_name(method_name, metric_name_code)}#{arguments}
|
201
|
+
"def #{_traced_method_name(method_name, metric_name_code)}(#{ARGS_FOR_RUBY_VERSION})
|
213
202
|
#{options[:code_header]}
|
214
203
|
result = ::NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(\"#{metric_name_code}\",
|
215
204
|
:metric => #{options[:metric]}) do
|
216
|
-
#{_untraced_method_name(method_name, metric_name_code)}#{
|
205
|
+
#{_untraced_method_name(method_name, metric_name_code)}(#{ARGS_FOR_RUBY_VERSION})
|
217
206
|
end
|
218
207
|
#{options[:code_footer]}
|
219
208
|
result
|
@@ -337,6 +326,7 @@ module NewRelic
|
|
337
326
|
class_eval traced_method, __FILE__, __LINE__
|
338
327
|
alias_method _untraced_method_name(method_name, metric_name_code), method_name
|
339
328
|
alias_method method_name, _traced_method_name(method_name, metric_name_code)
|
329
|
+
ruby2_keywords(_traced_method_name(method_name, metric_name_code)) if respond_to?(:ruby2_keywords, true)
|
340
330
|
send visibility, method_name
|
341
331
|
send visibility, _traced_method_name(method_name, metric_name_code)
|
342
332
|
::NewRelic::Agent.logger.debug("Traced method: class = #{derived_class_name},"+
|
@@ -38,6 +38,7 @@ module NewRelic
|
|
38
38
|
def initialize(license_key=nil, collector=control.server)
|
39
39
|
@license_key = license_key
|
40
40
|
@collector = collector
|
41
|
+
@configured_collector = collector
|
41
42
|
@request_timeout = Agent.config[:timeout]
|
42
43
|
@ssl_cert_store = nil
|
43
44
|
@in_session = nil
|
@@ -290,12 +291,20 @@ module NewRelic
|
|
290
291
|
# installed
|
291
292
|
conn.use_ssl = true
|
292
293
|
conn.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
293
|
-
conn
|
294
|
+
set_cert_store(conn)
|
294
295
|
rescue StandardError, LoadError
|
295
296
|
msg = "SSL is not available in the environment; please install SSL support."
|
296
297
|
raise UnrecoverableAgentException.new(msg)
|
297
298
|
end
|
298
299
|
|
300
|
+
def set_cert_store(conn)
|
301
|
+
if NewRelic::Agent.config[:ca_bundle_path]
|
302
|
+
conn.cert_store = ssl_cert_store
|
303
|
+
else
|
304
|
+
::NewRelic::Agent.logger.debug("Using default security certificates")
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
299
308
|
def start_connection(conn)
|
300
309
|
NewRelic::Agent.logger.debug("Opening TCP connection to #{conn.address}:#{conn.port}")
|
301
310
|
Timeout.timeout(@request_timeout) { conn.start }
|
@@ -337,6 +346,9 @@ module NewRelic
|
|
337
346
|
conn = create_http_connection
|
338
347
|
start_connection(conn)
|
339
348
|
conn
|
349
|
+
rescue Timeout::Error
|
350
|
+
::NewRelic::Agent.logger.info ("Timeout while attempting to connect. You may need to install system-level CA Certificates, as the ruby agent no longer includes these.")
|
351
|
+
raise
|
340
352
|
end
|
341
353
|
|
342
354
|
# The path to the certificate file used to verify the SSL
|
@@ -345,8 +357,6 @@ module NewRelic
|
|
345
357
|
if path_override = NewRelic::Agent.config[:ca_bundle_path]
|
346
358
|
NewRelic::Agent.logger.warn("Couldn't find CA bundle from configured ca_bundle_path: #{path_override}") unless File.exist? path_override
|
347
359
|
path_override
|
348
|
-
else
|
349
|
-
File.expand_path(File.join(control.newrelic_root, 'cert', 'cacert.pem'))
|
350
360
|
end
|
351
361
|
end
|
352
362
|
|
@@ -415,15 +425,18 @@ module NewRelic
|
|
415
425
|
data, encoding = compress_request_if_needed(data, method)
|
416
426
|
size = data.size
|
417
427
|
|
428
|
+
# Preconnect needs to always use the configured collector host, not the redirect host
|
429
|
+
endpoint_specific_collector = (method == :preconnect) ? @configured_collector : @collector
|
430
|
+
|
418
431
|
uri = remote_method_uri(method)
|
419
|
-
full_uri = "#{
|
432
|
+
full_uri = "#{endpoint_specific_collector}#{uri}"
|
420
433
|
|
421
434
|
@audit_logger.log_request(full_uri, payload, @marshaller)
|
422
435
|
request_send_ts = Time.now
|
423
436
|
response = send_request(:data => data,
|
424
437
|
:uri => uri,
|
425
438
|
:encoding => encoding,
|
426
|
-
:collector =>
|
439
|
+
:collector => endpoint_specific_collector,
|
427
440
|
:endpoint => method)
|
428
441
|
response_check_ts = Time.now
|
429
442
|
@marshaller.load(decompress_response(response))
|
@@ -504,6 +517,7 @@ module NewRelic
|
|
504
517
|
else
|
505
518
|
request = Net::HTTP::Post.new(opts[:uri], headers)
|
506
519
|
end
|
520
|
+
@audit_logger.log_request_headers(opts[:uri], headers)
|
507
521
|
request['user-agent'] = user_agent
|
508
522
|
request.content_type = "application/octet-stream"
|
509
523
|
request.body = opts[:data]
|
@@ -29,7 +29,7 @@ module NewRelic
|
|
29
29
|
end
|
30
30
|
elsif platform =~ /darwin9/ # 10.5
|
31
31
|
@sampler = ShellPS.new("ps -o rsz")
|
32
|
-
elsif platform =~ /
|
32
|
+
elsif platform =~ /darwin(1|2)\d+/ # >= 10.6
|
33
33
|
@sampler = ShellPS.new("ps -o rss")
|
34
34
|
elsif platform =~ /freebsd/
|
35
35
|
@sampler = ShellPS.new("ps -o rss")
|
@@ -165,16 +165,18 @@ module NewRelic
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
+
def merge_and_freeze_attributes agent_attributes, error_attributes
|
169
|
+
return agent_attributes.freeze unless error_attributes
|
170
|
+
return error_attributes.freeze if agent_attributes.equal?(NewRelic::EMPTY_HASH)
|
171
|
+
agent_attributes.merge!(error_attributes).freeze
|
172
|
+
end
|
173
|
+
|
168
174
|
def agent_attributes segment
|
169
|
-
|
170
|
-
|
175
|
+
agent_attributes = segment.attributes
|
176
|
+
.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_SPAN_EVENTS)
|
171
177
|
error_attributes = error_attributes(segment)
|
172
|
-
|
173
|
-
|
174
|
-
agent_attributes.freeze
|
175
|
-
else
|
176
|
-
NewRelic::EMPTY_HASH
|
177
|
-
end
|
178
|
+
return NewRelic::EMPTY_HASH unless agent_attributes || error_attributes
|
179
|
+
merge_and_freeze_attributes(agent_attributes, error_attributes)
|
178
180
|
end
|
179
181
|
|
180
182
|
def parent_guid segment
|