newrelic_rpm 2.13.5.beta4 → 2.13.6.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of newrelic_rpm might be problematic. Click here for more details.
- data/CHANGELOG +8 -0
- data/cert/cacert.pem +21 -0
- data/lib/conditional_vendored_dependency_detection.rb +3 -0
- data/lib/new_relic/agent/agent.rb +14 -1
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +15 -12
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +38 -21
- data/lib/new_relic/agent/instrumentation/authlogic.rb +9 -4
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +364 -364
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +142 -121
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +17 -16
- data/lib/new_relic/agent/instrumentation/memcache.rb +40 -26
- data/lib/new_relic/agent/instrumentation/net.rb +19 -13
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +27 -15
- data/lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb +80 -71
- data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +84 -72
- data/lib/new_relic/agent/instrumentation/sequel.rb +84 -70
- data/lib/new_relic/agent/instrumentation/sinatra.rb +44 -37
- data/lib/new_relic/agent/instrumentation/sunspot.rb +18 -12
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +13 -7
- data/lib/new_relic/agent/method_tracer.rb +1 -1
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +2 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +1 -1
- data/lib/new_relic/control.rb +1 -0
- data/lib/new_relic/control/instrumentation.rb +1 -0
- data/lib/new_relic/delayed_job_injection.rb +23 -14
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +5 -0
- data/newrelic_rpm.gemspec +25 -23
- data/test/new_relic/agent/{agent_connect_test.rb → agent/connect_test.rb} +2 -2
- data/test/new_relic/agent/{agent_start_test.rb → agent/start_test.rb} +17 -3
- data/test/new_relic/agent/{agent_start_worker_thread_test.rb → agent/start_worker_thread_test.rb} +2 -2
- data/test/new_relic/agent/{agent_controller_test.rb → agent_test_controller_test.rb} +6 -3
- data/test/new_relic/agent/{error_collector_notice_error_test.rb → error_collector/notice_error_test.rb} +2 -2
- data/test/new_relic/agent/{active_record_instrumentation_test.rb → instrumentation/active_record_instrumentation_test.rb} +2 -2
- data/test/new_relic/agent/{metric_frame_test.rb → instrumentation/metric_frame_test.rb} +2 -3
- data/test/new_relic/agent/{net_instrumentation_test.rb → instrumentation/net_instrumentation_test.rb} +4 -4
- data/test/new_relic/agent/{queue_time_test.rb → instrumentation/queue_time_test.rb} +1 -1
- data/test/new_relic/agent/{task_instrumentation_test.rb → instrumentation/task_instrumentation_test.rb} +29 -32
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +165 -0
- data/test/new_relic/agent/{method_tracer_trace_execution_scoped_test.rb → method_tracer/instance_methods/trace_execution_scoped_test.rb} +2 -2
- data/test/new_relic/agent/method_tracer_test.rb +31 -3
- data/test/new_relic/agent/rpm_agent_test.rb +8 -3
- data/test/new_relic/{agent/collection_helper_test.rb → collection_helper_test.rb} +4 -4
- data/test/new_relic/{deployments_api_test.rb → command/deployments_test.rb} +3 -5
- data/test/new_relic/control_test.rb +3 -3
- data/test/new_relic/{environment_test.rb → local_environment_test.rb} +2 -5
- data/test/new_relic/metric_spec_test.rb +32 -122
- data/test/new_relic/stats_test.rb +0 -1
- data/test/new_relic/{agent/transaction_sample_subtest_test.rb → transaction_sample_subtest_test.rb} +0 -0
- data/test/new_relic/{agent/transaction_sample_test.rb → transaction_sample_test.rb} +1 -2
- data/test/test_helper.rb +1 -0
- data/vendor/gems/dependency_detection-0.0.1.build/LICENSE +19 -0
- data/vendor/gems/dependency_detection-0.0.1.build/README +0 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +57 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +3 -0
- metadata +29 -27
- data/test/new_relic/agent/add_method_tracer_test.rb +0 -158
- data/test/new_relic/agent/metric_data_test.rb +0 -53
- data/test/new_relic/agent/testable_agent.rb +0 -13
- data/test/new_relic/shim_agent_test.rb +0 -9
@@ -37,145 +37,166 @@
|
|
37
37
|
# non-first metric in trace_execution_scoped() (docs say only first counts
|
38
38
|
# towards scope) so they don't show up ine normal call graph/trace.
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
::DataMapper::Model.class_eval do
|
44
|
-
|
45
|
-
add_method_tracer :get, 'ActiveRecord/#{self.name}/get'
|
46
|
-
add_method_tracer :first, 'ActiveRecord/#{self.name}/first'
|
47
|
-
add_method_tracer :last, 'ActiveRecord/#{self.name}/last'
|
48
|
-
add_method_tracer :all, 'ActiveRecord/#{self.name}/all'
|
49
|
-
|
50
|
-
add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
|
51
|
-
add_method_tracer :create!, 'ActiveRecord/#{self.name}/create'
|
52
|
-
add_method_tracer :update, 'ActiveRecord/#{self.name}/update'
|
53
|
-
add_method_tracer :update!, 'ActiveRecord/#{self.name}/update'
|
54
|
-
add_method_tracer :destroy, 'ActiveRecord/#{self.name}/destroy'
|
55
|
-
add_method_tracer :destroy!, 'ActiveRecord/#{self.name}/destroy'
|
56
|
-
|
57
|
-
# For dm-aggregates and partial dm-ar-finders support:
|
58
|
-
for method in [ :aggregate, :find, :find_by_sql ] do
|
59
|
-
next unless method_defined? method
|
60
|
-
add_method_tracer(method, 'ActiveRecord/#{self.name}/' + method.to_s)
|
61
|
-
end
|
62
|
-
|
40
|
+
DependencyDetector.defer do
|
41
|
+
depends_on do
|
42
|
+
defined?(::DataMapper)
|
63
43
|
end
|
44
|
+
|
45
|
+
executes_on(:'DataMapper::Model') do
|
46
|
+
class_eval do
|
47
|
+
add_method_tracer :get, 'ActiveRecord/#{self.name}/get'
|
48
|
+
add_method_tracer :first, 'ActiveRecord/#{self.name}/first'
|
49
|
+
add_method_tracer :last, 'ActiveRecord/#{self.name}/last'
|
50
|
+
add_method_tracer :all, 'ActiveRecord/#{self.name}/all'
|
51
|
+
|
52
|
+
add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
|
53
|
+
add_method_tracer :create!, 'ActiveRecord/#{self.name}/create'
|
54
|
+
add_method_tracer :update, 'ActiveRecord/#{self.name}/update'
|
55
|
+
add_method_tracer :update!, 'ActiveRecord/#{self.name}/update'
|
56
|
+
add_method_tracer :destroy, 'ActiveRecord/#{self.name}/destroy'
|
57
|
+
add_method_tracer :destroy!, 'ActiveRecord/#{self.name}/destroy'
|
58
|
+
|
59
|
+
# For dm-aggregates and partial dm-ar-finders support:
|
60
|
+
for method in [ :aggregate, :find, :find_by_sql ] do
|
61
|
+
next unless method_defined? method
|
62
|
+
add_method_tracer(method, 'ActiveRecord/#{self.name}/' + method.to_s)
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
executes_on(:'DataMapper::Resource') do
|
69
|
+
class_eval do
|
70
|
+
add_method_tracer :update, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/update'
|
71
|
+
add_method_tracer :update!, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/update'
|
72
|
+
add_method_tracer :save, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/save'
|
73
|
+
add_method_tracer :save!, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/save'
|
74
|
+
add_method_tracer :destroy, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/destroy'
|
75
|
+
add_method_tracer :destroy!, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/destroy'
|
74
76
|
|
77
|
+
end
|
75
78
|
end
|
76
79
|
|
77
|
-
|
78
|
-
|
80
|
+
executes_on(:'DataMapper::Collection') do
|
81
|
+
class_eval do
|
82
|
+
# DM's Collection instance methods
|
83
|
+
add_method_tracer :get, 'ActiveRecord/#{self.name}/get'
|
84
|
+
add_method_tracer :first, 'ActiveRecord/#{self.name}/first'
|
85
|
+
add_method_tracer :last, 'ActiveRecord/#{self.name}/last'
|
86
|
+
add_method_tracer :all, 'ActiveRecord/#{self.name}/all'
|
87
|
+
|
88
|
+
add_method_tracer :lazy_load, 'ActiveRecord/#{self.name}/lazy_load'
|
89
|
+
|
90
|
+
add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
|
91
|
+
add_method_tracer :create!, 'ActiveRecord/#{self.name}/create'
|
92
|
+
add_method_tracer :update, 'ActiveRecord/#{self.name}/update'
|
93
|
+
add_method_tracer :update!, 'ActiveRecord/#{self.name}/update'
|
94
|
+
add_method_tracer :destroy, 'ActiveRecord/#{self.name}/destroy'
|
95
|
+
add_method_tracer :destroy!, 'ActiveRecord/#{self.name}/destroy'
|
96
|
+
|
97
|
+
# For dm-aggregates support:
|
98
|
+
for method in [ :aggregate ] do
|
99
|
+
next unless method_defined? method
|
100
|
+
add_method_tracer(method, 'ActiveRecord/#{self.name}/' + method.to_s)
|
101
|
+
end
|
79
102
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
add_method_tracer :all, 'ActiveRecord/#{self.name}/all'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
84
106
|
|
85
|
-
|
107
|
+
DependencyDetection.defer do
|
108
|
+
executes_on(:'DataMapper::Adapters::DataObjectsAdapter') do
|
109
|
+
# Catch the two entry points into DM::Repository::Adapter that bypass CRUD
|
110
|
+
# (for when SQL is run directly).
|
111
|
+
class_eval do
|
86
112
|
|
87
|
-
|
88
|
-
|
89
|
-
add_method_tracer :update, 'ActiveRecord/#{self.name}/update'
|
90
|
-
add_method_tracer :update!, 'ActiveRecord/#{self.name}/update'
|
91
|
-
add_method_tracer :destroy, 'ActiveRecord/#{self.name}/destroy'
|
92
|
-
add_method_tracer :destroy!, 'ActiveRecord/#{self.name}/destroy'
|
113
|
+
add_method_tracer :select, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/select'
|
114
|
+
add_method_tracer :execute, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/execute'
|
93
115
|
|
94
|
-
# For dm-aggregates support:
|
95
|
-
for method in [ :aggregate ] do
|
96
|
-
next unless method_defined? method
|
97
|
-
add_method_tracer(method, 'ActiveRecord/#{self.name}/' + method.to_s)
|
98
116
|
end
|
99
|
-
|
100
117
|
end
|
118
|
+
end
|
101
119
|
|
102
|
-
|
103
|
-
# (for when SQL is run directly).
|
104
|
-
::DataMapper::Adapters::DataObjectsAdapter.class_eval do
|
105
|
-
|
106
|
-
add_method_tracer :select, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/select'
|
107
|
-
add_method_tracer :execute, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/execute'
|
108
|
-
|
109
|
-
end if defined? ::DataMapper::Adapters::DataObjectsAdapter
|
120
|
+
DependencyDetection.defer do
|
110
121
|
|
111
122
|
# DM::Validations overrides Model#create, but currently in a way that makes it
|
112
123
|
# impossible to instrument from one place. I've got a patch pending inclusion
|
113
124
|
# to make it instrumentable by putting the create method inside ClassMethods.
|
114
125
|
# This will pick it up if/when that patch is accepted.
|
115
|
-
|
116
|
-
|
117
|
-
next unless method_defined? :create
|
118
|
-
add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
|
119
|
-
|
120
|
-
end if defined? ::DataMapper::Validations::ClassMethods
|
121
|
-
|
122
|
-
# NOTE: DM::Transaction basically calls commit() twice, so as-is it will show
|
123
|
-
# up in traces twice -- second time subordinate to the first's scope. Works
|
124
|
-
# well enough.
|
125
|
-
::DataMapper::Transaction.module_eval do
|
126
|
-
add_method_tracer :commit, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/commit'
|
127
|
-
end if defined? ::DataMapper::Transaction
|
128
|
-
|
129
|
-
module NewRelic
|
130
|
-
module Agent
|
131
|
-
module Instrumentation
|
132
|
-
module DataMapperInstrumentation
|
133
|
-
|
134
|
-
def self.included(klass)
|
135
|
-
klass.class_eval do
|
136
|
-
alias_method :log_without_newrelic_instrumentation, :log
|
137
|
-
alias_method :log, :log_with_newrelic_instrumentation
|
138
|
-
end
|
139
|
-
end
|
126
|
+
executes_on(:'DataMapper::Validations::ClassMethods') do
|
127
|
+
class_eval do
|
140
128
|
|
141
|
-
|
142
|
-
|
143
|
-
# duration, there's nothing more to measure, so just record and log.
|
144
|
-
#
|
145
|
-
# We rely on the assumption that all possible entry points have been
|
146
|
-
# hooked with tracers, ensuring that notice_sql attaches this SQL to
|
147
|
-
# the proper call scope.
|
148
|
-
def log_with_newrelic_instrumentation(msg)
|
149
|
-
return unless NewRelic::Agent.is_execution_traced?
|
150
|
-
return unless operation = case msg.query
|
151
|
-
when /^\s*select/i then 'find'
|
152
|
-
when /^\s*(update|insert)/i then 'save'
|
153
|
-
when /^\s*delete/i then 'destroy'
|
154
|
-
else nil
|
155
|
-
end
|
156
|
-
|
157
|
-
# FYI: self.to_s will yield connection URI string.
|
158
|
-
duration = msg.duration / 1000000.0
|
159
|
-
|
160
|
-
# Attach SQL to current segment/scope.
|
161
|
-
NewRelic::Agent.instance.transaction_sampler.notice_sql(msg.query, nil, duration)
|
162
|
-
|
163
|
-
# Record query duration associated with each of the desired metrics.
|
164
|
-
metrics = [ "ActiveRecord/#{operation}", 'ActiveRecord/all' ]
|
165
|
-
metrics.each do |metric|
|
166
|
-
NewRelic::Agent.instance.stats_engine.get_stats_no_scope(metric).trace_call(duration)
|
167
|
-
end
|
168
|
-
ensure
|
169
|
-
log_without_newrelic_instrumentation(msg)
|
170
|
-
end
|
129
|
+
next unless method_defined? :create
|
130
|
+
add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
|
171
131
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
DependencyDetection.defer do
|
137
|
+
# NOTE: DM::Transaction basically calls commit() twice, so as-is it will show
|
138
|
+
# up in traces twice -- second time subordinate to the first's scope. Works
|
139
|
+
# well enough.
|
140
|
+
executes_on(:'DataMapper::Transaction') do
|
141
|
+
module_eval do
|
142
|
+
add_method_tracer :commit, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/commit'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
176
146
|
|
177
|
-
::DataObjects::Connection.class_eval do
|
178
|
-
include ::NewRelic::Agent::Instrumentation::DataMapperInstrumentation
|
179
|
-
end if defined? ::DataObjects::Connection
|
180
147
|
|
181
|
-
|
148
|
+
module NewRelic
|
149
|
+
module Agent
|
150
|
+
module Instrumentation
|
151
|
+
module DataMapperInstrumentation
|
152
|
+
|
153
|
+
def self.included(klass)
|
154
|
+
klass.class_eval do
|
155
|
+
alias_method :log_without_newrelic_instrumentation, :log
|
156
|
+
alias_method :log, :log_with_newrelic_instrumentation
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Unlike in AR, log is called in DM after the query actually ran,
|
161
|
+
# complete with metrics. Since DO has already calculated the
|
162
|
+
# duration, there's nothing more to measure, so just record and log.
|
163
|
+
#
|
164
|
+
# We rely on the assumption that all possible entry points have been
|
165
|
+
# hooked with tracers, ensuring that notice_sql attaches this SQL to
|
166
|
+
# the proper call scope.
|
167
|
+
def log_with_newrelic_instrumentation(msg)
|
168
|
+
return unless NewRelic::Agent.is_execution_traced?
|
169
|
+
return unless operation = case msg.query
|
170
|
+
when /^\s*select/i then 'find'
|
171
|
+
when /^\s*(update|insert)/i then 'save'
|
172
|
+
when /^\s*delete/i then 'destroy'
|
173
|
+
else nil
|
174
|
+
end
|
175
|
+
|
176
|
+
# FYI: self.to_s will yield connection URI string.
|
177
|
+
duration = msg.duration / 1000000.0
|
178
|
+
|
179
|
+
# Attach SQL to current segment/scope.
|
180
|
+
NewRelic::Agent.instance.transaction_sampler.notice_sql(msg.query, nil, duration)
|
181
|
+
|
182
|
+
# Record query duration associated with each of the desired metrics.
|
183
|
+
metrics = [ "ActiveRecord/#{operation}", 'ActiveRecord/all' ]
|
184
|
+
metrics.each do |metric|
|
185
|
+
NewRelic::Agent.instance.stats_engine.get_stats_no_scope(metric).trace_call(duration)
|
186
|
+
end
|
187
|
+
ensure
|
188
|
+
log_without_newrelic_instrumentation(msg)
|
189
|
+
end
|
190
|
+
|
191
|
+
end # DataMapperInstrumentation
|
192
|
+
end # Instrumentation
|
193
|
+
end # Agent
|
194
|
+
end # NewRelic
|
195
|
+
|
196
|
+
DependencyDetection.defer do
|
197
|
+
executes_on(:'DataObjects::Connection') do
|
198
|
+
class_eval do
|
199
|
+
include ::NewRelic::Agent::Instrumentation::DataMapperInstrumentation
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -1,22 +1,23 @@
|
|
1
1
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
module DelayedJobInstrumentation
|
8
|
-
|
9
|
-
Delayed::Job.class_eval do
|
10
|
-
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
11
|
-
if self.instance_methods.include?('name')
|
12
|
-
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob', :path => '#{self.name}'
|
13
|
-
else
|
14
|
-
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob'
|
15
|
-
end
|
16
|
-
end
|
3
|
+
DependencyDetection.defer do
|
4
|
+
depends_on do
|
5
|
+
!NewRelic::Control.instance['disable_dj']
|
6
|
+
end
|
17
7
|
|
18
|
-
|
19
|
-
|
8
|
+
depends_on do
|
9
|
+
defined?(::Delayed) && defined?(::Delayed::Job)
|
10
|
+
end
|
11
|
+
|
12
|
+
executes do
|
13
|
+
Delayed::Job.class_eval do
|
14
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
15
|
+
if self.instance_methods.include?('name')
|
16
|
+
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob', :path => '#{self.name}'
|
17
|
+
else
|
18
|
+
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob'
|
20
19
|
end
|
21
20
|
end
|
21
|
+
end
|
22
22
|
end
|
23
|
+
|
@@ -4,39 +4,53 @@
|
|
4
4
|
# http://www.deveiate.org/code/Ruby-MemCache/ (Gem: Ruby-MemCache)
|
5
5
|
# http://seattlerb.rubyforge.org/memcache-client/ (Gem: memcache-client)
|
6
6
|
# http://github.com/mperham/dalli (Gem: dalli)
|
7
|
-
unless NewRelic::Control.instance['disable_memcache_instrumentation']
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module Instrumentation
|
11
|
+
module Memcache
|
12
|
+
module_function
|
13
|
+
def instrument_method(the_class, method_name)
|
14
|
+
return unless the_class.method_defined? method_name.to_sym
|
15
|
+
the_class.class_eval <<-EOD
|
16
|
+
def #{method_name}_with_newrelic_trace(*args)
|
17
|
+
metrics = ["MemCache/#{method_name}",
|
18
|
+
(NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'MemCache/allWeb' : 'MemCache/allOther')]
|
19
|
+
self.class.trace_execution_scoped(metrics) do
|
20
|
+
t0 = Time.now
|
21
|
+
begin
|
22
|
+
#{method_name}_without_newrelic_trace(*args)
|
23
|
+
ensure
|
24
|
+
#{memcache_key_snippet(method_name)}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
alias #{method_name}_without_newrelic_trace #{method_name}
|
29
|
+
alias #{method_name} #{method_name}_with_newrelic_trace
|
30
|
+
EOD
|
31
|
+
end
|
32
|
+
def memcache_key_snippet(method_name)
|
33
|
+
return "" unless NewRelic::Control.instance['capture_memcache_keys']
|
34
|
+
"NewRelic::Agent.instance.transaction_sampler.notice_nosql(args.first.inspect, (Time.now - t0).to_f) rescue nil"
|
23
35
|
end
|
24
|
-
alias #{method_name}_without_newrelic_trace #{method_name}
|
25
|
-
alias #{method_name} #{method_name}_with_newrelic_trace
|
26
|
-
EOD
|
27
36
|
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
28
40
|
|
29
|
-
def self.memcache_key_snippet(method_name)
|
30
|
-
return "" unless NewRelic::Control.instance['capture_memcache_keys']
|
31
|
-
"NewRelic::Agent.instance.transaction_sampler.notice_nosql(args.first.inspect, (Time.now - t0).to_f) rescue nil"
|
32
|
-
end
|
33
41
|
|
34
42
|
|
35
43
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
instrument_method(::Dalli::Client, method_name) if defined? ::Dalli::Client
|
44
|
+
DependencyDetection.defer do
|
45
|
+
depends_on do
|
46
|
+
!NewRelic::Control.instance['disable_memcache_instrumentation']
|
40
47
|
end
|
41
48
|
|
49
|
+
executes do
|
50
|
+
%w[get get_multi set add incr decr delete replace append prepend cas].each do | method_name |
|
51
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_method(::MemCache, method_name) if defined? ::MemCache
|
52
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_method(::Memcached, method_name) if defined? ::Memcached
|
53
|
+
NewRelic::Agent::Instrumentation::Memcache.instrument_method(::Dalli::Client, method_name) if defined? ::Dalli::Client
|
54
|
+
end
|
55
|
+
end
|
42
56
|
end
|
@@ -1,17 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
DependencyDetection.defer do
|
2
|
+
depends_on do
|
3
|
+
defined?(Net) && defined?(Net::HTTP)
|
4
|
+
end
|
5
|
+
|
6
|
+
executes do
|
7
|
+
Net::HTTP.class_eval do
|
8
|
+
def request_with_newrelic_trace(*args, &block)
|
9
|
+
metrics = ["External/#{@address}/Net::HTTP/#{args[0].method}","External/#{@address}/all"]
|
10
|
+
if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
|
11
|
+
metrics << "External/allWeb"
|
12
|
+
else
|
13
|
+
metrics << "External/allOther"
|
14
|
+
end
|
15
|
+
self.class.trace_execution_scoped metrics do
|
16
|
+
request_without_newrelic_trace(*args, &block)
|
17
|
+
end
|
12
18
|
end
|
19
|
+
alias request_without_newrelic_trace request
|
20
|
+
alias request request_with_newrelic_trace
|
13
21
|
end
|
14
|
-
alias request_without_newrelic_trace request
|
15
|
-
alias request request_with_newrelic_trace
|
16
22
|
end
|
17
23
|
end
|
@@ -1,22 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
PhusionPassenger.on_event(:stopping_worker_process) do
|
5
|
-
NewRelic::Agent.logger.debug "Passenger stopping this process, shutdown the agent."
|
6
|
-
NewRelic::Agent.instance.shutdown
|
1
|
+
DependencyDetection.defer do
|
2
|
+
depends_on do
|
3
|
+
defined?(PhusionPassenger)
|
7
4
|
end
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
executes do
|
7
|
+
NewRelic::Agent.logger.debug "Installing Passenger event hooks."
|
8
|
+
|
9
|
+
PhusionPassenger.on_event(:stopping_worker_process) do
|
10
|
+
NewRelic::Agent.logger.debug "Passenger stopping this process, shutdown the agent."
|
11
|
+
NewRelic::Agent.instance.shutdown
|
12
|
+
end
|
13
|
+
|
14
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
15
|
+
# We want to reset the stats from the stats engine in case any carried
|
16
|
+
# over into the spawned process. Don't clear them in case any were
|
17
|
+
# cached. We do this even in conservative spawning.
|
18
|
+
NewRelic::Agent.after_fork(:force_reconnect => true)
|
19
|
+
end
|
14
20
|
end
|
21
|
+
end
|
15
22
|
|
16
|
-
|
17
|
-
|
18
|
-
|
23
|
+
DependencyDetection.defer do
|
24
|
+
depends_on do
|
25
|
+
defined?(::Passenger) && defined?(::Passenger::AbstractServer) || defined?(::IN_PHUSION_PASSENGER)
|
26
|
+
end
|
19
27
|
|
20
|
-
|
28
|
+
executes do
|
29
|
+
# We're on an older version of passenger
|
30
|
+
NewRelic::Agent.logger.warn "An older version of Phusion Passenger has been detected. We recommend using at least release 2.1.1."
|
21
31
|
|
32
|
+
NewRelic::Agent::Instrumentation::MetricFrame.check_server_connection = true
|
33
|
+
end
|
22
34
|
end
|