ghazel-newrelic_rpm 3.1.0.1 → 3.4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +120 -35
- data/LICENSE +29 -2
- data/README.rdoc +2 -2
- data/bin/mongrel_rpm +0 -0
- data/bin/newrelic +0 -0
- data/bin/newrelic_cmd +0 -0
- data/lib/new_relic/agent.rb +50 -38
- data/lib/new_relic/agent/agent.rb +459 -337
- data/lib/new_relic/agent/beacon_configuration.rb +71 -11
- data/lib/new_relic/agent/browser_monitoring.rb +73 -14
- data/lib/new_relic/agent/busy_calculator.rb +11 -3
- data/lib/new_relic/agent/chained_call.rb +2 -2
- data/lib/new_relic/agent/database.rb +223 -0
- data/lib/new_relic/agent/error_collector.rb +231 -183
- data/lib/new_relic/agent/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +10 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +138 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +7 -1
- data/lib/new_relic/agent/instrumentation/authlogic.rb +6 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +46 -14
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +8 -2
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +11 -3
- data/lib/new_relic/agent/instrumentation/memcache.rb +49 -25
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +7 -2
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +7 -1
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +31 -4
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +1 -5
- data/lib/new_relic/agent/instrumentation/net.rb +8 -2
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +5 -2
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +66 -35
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +7 -1
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +7 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +121 -1
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +7 -1
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +21 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +80 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +46 -20
- data/lib/new_relic/agent/instrumentation/sunspot.rb +6 -0
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +7 -2
- data/lib/new_relic/agent/method_tracer.rb +205 -99
- data/lib/new_relic/agent/new_relic_service.rb +221 -0
- data/lib/new_relic/agent/pipe_channel_manager.rb +161 -0
- data/lib/new_relic/agent/pipe_service.rb +54 -0
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +89 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +6 -7
- data/lib/new_relic/agent/shim_agent.rb +5 -5
- data/lib/new_relic/agent/sql_sampler.rb +282 -0
- data/lib/new_relic/agent/stats_engine.rb +2 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +123 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +35 -30
- data/lib/new_relic/agent/stats_engine/samplers.rb +10 -4
- data/lib/new_relic/agent/stats_engine/transactions.rb +28 -87
- data/lib/new_relic/agent/transaction_info.rb +74 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +18 -3
- data/lib/new_relic/agent/transaction_sampler.rb +108 -20
- data/lib/new_relic/agent/worker_loop.rb +14 -6
- data/lib/new_relic/collection_helper.rb +19 -11
- data/lib/new_relic/command.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +2 -2
- data/lib/new_relic/commands/install.rb +2 -13
- data/lib/new_relic/control.rb +2 -3
- data/lib/new_relic/control/class_methods.rb +12 -6
- data/lib/new_relic/control/configuration.rb +57 -8
- data/lib/new_relic/control/frameworks.rb +10 -0
- data/lib/new_relic/control/frameworks/external.rb +4 -4
- data/lib/new_relic/control/frameworks/merb.rb +2 -1
- data/lib/new_relic/control/frameworks/rails.rb +35 -22
- data/lib/new_relic/control/frameworks/rails3.rb +12 -7
- data/lib/new_relic/control/frameworks/ruby.rb +5 -5
- data/lib/new_relic/control/frameworks/sinatra.rb +1 -4
- data/lib/new_relic/control/instance_methods.rb +38 -12
- data/lib/new_relic/control/instrumentation.rb +23 -4
- data/lib/new_relic/control/logging_methods.rb +70 -15
- data/lib/new_relic/control/server_methods.rb +22 -9
- data/lib/new_relic/delayed_job_injection.rb +16 -3
- data/lib/new_relic/helper.rb +21 -0
- data/lib/new_relic/language_support.rb +95 -0
- data/lib/new_relic/local_environment.rb +92 -48
- data/lib/new_relic/metric_data.rb +7 -2
- data/lib/new_relic/metric_spec.rb +12 -9
- data/lib/new_relic/noticed_error.rb +6 -1
- data/lib/new_relic/rack/browser_monitoring.rb +18 -19
- data/lib/new_relic/rack/developer_mode.rb +3 -2
- data/lib/new_relic/recipes.rb +8 -4
- data/lib/new_relic/stats.rb +17 -60
- data/lib/new_relic/transaction_analysis.rb +2 -1
- data/lib/new_relic/transaction_analysis/segment_summary.rb +4 -2
- data/lib/new_relic/transaction_sample.rb +60 -75
- data/lib/new_relic/transaction_sample/segment.rb +31 -79
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/newrelic.yml +2 -2
- data/newrelic_rpm.gemspec +46 -54
- data/test/active_record_fixtures.rb +3 -3
- data/test/config/newrelic.yml +1 -1
- data/test/fixtures/proc_cpuinfo.txt +575 -0
- data/test/new_relic/agent/agent/connect_test.rb +128 -25
- data/test/new_relic/agent/agent/start_test.rb +9 -94
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +2 -4
- data/test/new_relic/agent/agent_test.rb +51 -78
- data/test/new_relic/agent/agent_test_controller.rb +1 -1
- data/test/new_relic/agent/agent_test_controller_test.rb +49 -33
- data/test/new_relic/agent/beacon_configuration_test.rb +12 -5
- data/test/new_relic/agent/browser_monitoring_test.rb +99 -50
- data/test/new_relic/agent/database_test.rb +161 -0
- data/test/new_relic/agent/error_collector_test.rb +47 -23
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +96 -42
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +0 -2
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +3 -11
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +9 -9
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +6 -11
- data/test/new_relic/agent/memcache_instrumentation_test.rb +54 -18
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
- data/test/new_relic/agent/method_tracer_test.rb +3 -2
- data/test/new_relic/agent/new_relic_service_test.rb +151 -0
- data/test/new_relic/agent/pipe_channel_manager_test.rb +114 -0
- data/test/new_relic/agent/pipe_service_test.rb +113 -0
- data/test/new_relic/agent/rpm_agent_test.rb +4 -31
- data/test/new_relic/agent/sql_sampler_test.rb +192 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +19 -18
- data/test/new_relic/agent/stats_engine_test.rb +41 -6
- data/test/new_relic/agent/transaction_info_test.rb +13 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +27 -4
- data/test/new_relic/agent/transaction_sampler_test.rb +68 -46
- data/test/new_relic/agent/worker_loop_test.rb +3 -3
- data/test/new_relic/agent_test.rb +242 -0
- data/test/new_relic/collection_helper_test.rb +50 -28
- data/test/new_relic/control/configuration_test.rb +77 -0
- data/test/new_relic/control/logging_methods_test.rb +49 -21
- data/test/new_relic/control_test.rb +115 -54
- data/test/new_relic/delayed_job_injection_test.rb +21 -0
- data/test/new_relic/fake_collector.rb +210 -0
- data/test/new_relic/fake_service.rb +44 -0
- data/test/new_relic/local_environment_test.rb +14 -1
- data/test/new_relic/metric_parser/metric_parser_test.rb +11 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +84 -23
- data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
- data/test/new_relic/rack/developer_mode_test.rb +31 -0
- data/test/new_relic/stats_test.rb +3 -18
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +14 -0
- data/test/new_relic/transaction_analysis_test.rb +3 -3
- data/test/new_relic/transaction_sample/segment_test.rb +15 -80
- data/test/new_relic/transaction_sample_test.rb +25 -18
- data/test/script/build_test_gem.sh +51 -0
- data/test/script/ci.sh +140 -0
- data/test/script/ci_agent-tests_runner.sh +82 -0
- data/test/script/ci_bench.sh +52 -0
- data/test/script/ci_multiverse_runner.sh +63 -0
- data/test/test_contexts.rb +1 -0
- data/test/test_helper.rb +18 -5
- data/ui/helpers/developer_mode_helper.rb +14 -8
- data/ui/helpers/google_pie_chart.rb +0 -1
- data/ui/views/newrelic/index.rhtml +2 -2
- data/vendor/gems/dependency_detection-0.0.1.build/LICENSE +4 -18
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +10 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +11 -11
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +17 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +4 -0
- metadata +50 -36
- data/lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb +0 -108
- data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +0 -112
- data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +0 -40
- data/lib/new_relic/data_serialization.rb +0 -84
- data/lib/new_relic/histogram.rb +0 -91
- data/lib/new_relic/rack/metric_app.rb +0 -65
- data/lib/new_relic/rack/mongrel_rpm.ru +0 -28
- data/lib/new_relic/rack/newrelic.yml +0 -27
- data/lib/new_relic/rack_app.rb +0 -6
- data/test/new_relic/data_serialization_test.rb +0 -70
- data/vendor/gems/dependency_detection-0.0.1.build/README +0 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/LICENSE +0 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/README +0 -0
@@ -1,11 +1,16 @@
|
|
1
1
|
require 'set'
|
2
2
|
|
3
3
|
DependencyDetection.defer do
|
4
|
-
|
4
|
+
@name = :merb_controller
|
5
|
+
|
5
6
|
depends_on do
|
6
7
|
defined?(Merb) && defined?(Merb::Controller)
|
7
8
|
end
|
8
|
-
|
9
|
+
|
10
|
+
executes do
|
11
|
+
NewRelic::Agent.logger.debug 'Installing Merb Controller instrumentation'
|
12
|
+
end
|
13
|
+
|
9
14
|
executes do
|
10
15
|
require 'merb-core/controller/merb_controller'
|
11
16
|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
DependencyDetection.defer do
|
2
|
+
@name = :merb_error
|
3
|
+
|
2
4
|
depends_on do
|
3
5
|
defined?(Merb) && defined?(Merb::Dispatcher) && defined?(Merb::Dispatcher::DefaultException)
|
4
6
|
end
|
@@ -6,7 +8,11 @@ DependencyDetection.defer do
|
|
6
8
|
depends_on do
|
7
9
|
Merb::Dispatcher::DefaultException.respond_to?(:before)
|
8
10
|
end
|
9
|
-
|
11
|
+
|
12
|
+
executes do
|
13
|
+
NewRelic::Agent.logger.debug 'Installing Merb Errors instrumentation'
|
14
|
+
end
|
15
|
+
|
10
16
|
executes do
|
11
17
|
|
12
18
|
# Hook in the notification to merb
|
@@ -67,17 +67,18 @@ module NewRelic
|
|
67
67
|
include_class 'java.lang.management.ManagementFactory'
|
68
68
|
include_class 'com.sun.management.OperatingSystemMXBean'
|
69
69
|
@@java_classes_loaded = true
|
70
|
-
rescue
|
70
|
+
rescue => e
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
attr_reader :depth
|
75
75
|
|
76
76
|
def initialize
|
77
|
-
|
77
|
+
@start = Time.now
|
78
78
|
@path_stack = [] # stack of [controller, path] elements
|
79
79
|
@jruby_cpu_start = jruby_cpu_time
|
80
80
|
@process_cpu_start = process_cpu
|
81
|
+
Thread.current[:last_metric_frame] = self
|
81
82
|
end
|
82
83
|
|
83
84
|
def agent
|
@@ -87,15 +88,20 @@ module NewRelic
|
|
87
88
|
def transaction_sampler
|
88
89
|
agent.transaction_sampler
|
89
90
|
end
|
91
|
+
|
92
|
+
def sql_sampler
|
93
|
+
agent.sql_sampler
|
94
|
+
end
|
90
95
|
|
91
96
|
private :agent
|
92
97
|
private :transaction_sampler
|
93
|
-
|
98
|
+
private :sql_sampler
|
94
99
|
|
95
100
|
# Indicate that we are entering a measured controller action or task.
|
96
101
|
# Make sure you unwind every push with a pop call.
|
97
102
|
def push(m)
|
98
103
|
transaction_sampler.notice_first_scope_push(start)
|
104
|
+
sql_sampler.notice_first_scope_push(start)
|
99
105
|
@path_stack.push NewRelic::MetricParser::MetricParser.for_metric_named(m)
|
100
106
|
end
|
101
107
|
|
@@ -127,6 +133,7 @@ module NewRelic
|
|
127
133
|
# Only push the transaction context info once, on entry:
|
128
134
|
if @path_stack.size == 1
|
129
135
|
transaction_sampler.notice_transaction(metric_name, uri, filtered_params)
|
136
|
+
sql_sampler.notice_transaction(metric_name, uri, filtered_params)
|
130
137
|
end
|
131
138
|
end
|
132
139
|
|
@@ -193,11 +200,19 @@ module NewRelic
|
|
193
200
|
def self.add_custom_parameters(p)
|
194
201
|
current.add_custom_parameters(p) if current
|
195
202
|
end
|
196
|
-
|
203
|
+
|
197
204
|
def self.custom_parameters
|
198
205
|
(current && current.custom_parameters) ? current.custom_parameters : {}
|
199
206
|
end
|
200
207
|
|
208
|
+
def self.set_user_attributes(attributes)
|
209
|
+
current.set_user_attributes(attributes) if current
|
210
|
+
end
|
211
|
+
|
212
|
+
def self.user_attributes
|
213
|
+
(current) ? current.user_attributes : {}
|
214
|
+
end
|
215
|
+
|
201
216
|
def record_apdex()
|
202
217
|
return unless recording_web_transaction? && NewRelic::Agent.is_execution_traced?
|
203
218
|
t = Time.now
|
@@ -242,10 +257,22 @@ module NewRelic
|
|
242
257
|
def custom_parameters
|
243
258
|
@custom_parameters ||= {}
|
244
259
|
end
|
260
|
+
|
261
|
+
def user_attributes
|
262
|
+
@user_atrributes ||= {}
|
263
|
+
end
|
264
|
+
|
265
|
+
def queue_time
|
266
|
+
apdex_start - start
|
267
|
+
end
|
245
268
|
|
246
269
|
def add_custom_parameters(p)
|
247
270
|
custom_parameters.merge!(p)
|
248
271
|
end
|
272
|
+
|
273
|
+
def set_user_attributes(attributes)
|
274
|
+
user_attributes.merge!(attributes)
|
275
|
+
end
|
249
276
|
|
250
277
|
def self.recording_web_transaction?
|
251
278
|
c = Thread.current[:newrelic_metric_frame]
|
@@ -17,12 +17,9 @@ module NewRelic
|
|
17
17
|
NewRelic::Agent.logger.error "Underflow in metric frames: #{caller.join("\n ")}"
|
18
18
|
end
|
19
19
|
|
20
|
-
def process_histogram_for_transaction(ending)
|
21
|
-
agent.histogram.process((ending - start).to_f)
|
22
|
-
end
|
23
|
-
|
24
20
|
def notice_scope_empty
|
25
21
|
transaction_sampler.notice_scope_empty
|
22
|
+
sql_sampler.notice_scope_empty
|
26
23
|
end
|
27
24
|
|
28
25
|
def record_transaction_cpu
|
@@ -59,7 +56,6 @@ module NewRelic
|
|
59
56
|
|
60
57
|
def notify_transaction_sampler(web_transaction)
|
61
58
|
record_transaction_cpu
|
62
|
-
process_histogram_for_transaction(Time.now) if web_transaction
|
63
59
|
notice_scope_empty
|
64
60
|
end
|
65
61
|
|
@@ -1,12 +1,18 @@
|
|
1
1
|
DependencyDetection.defer do
|
2
|
+
@name = :net
|
3
|
+
|
2
4
|
depends_on do
|
3
5
|
defined?(Net) && defined?(Net::HTTP)
|
4
6
|
end
|
5
|
-
|
7
|
+
|
8
|
+
executes do
|
9
|
+
NewRelic::Agent.logger.debug 'Installing Net instrumentation'
|
10
|
+
end
|
11
|
+
|
6
12
|
executes do
|
7
13
|
Net::HTTP.class_eval do
|
8
14
|
def request_with_newrelic_trace(*args, &block)
|
9
|
-
metrics = ["External/#{@address}/Net::HTTP/#{args[0].method}","External/#{@address}/all"]
|
15
|
+
metrics = ["External/#{@address}/Net::HTTP/#{args[0].method}", "External/#{@address}/all", "External/all"]
|
10
16
|
if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
|
11
17
|
metrics << "External/allWeb"
|
12
18
|
else
|
@@ -1,4 +1,6 @@
|
|
1
1
|
DependencyDetection.defer do
|
2
|
+
@name = :passenger
|
3
|
+
|
2
4
|
depends_on do
|
3
5
|
defined?(PhusionPassenger)
|
4
6
|
end
|
@@ -26,8 +28,9 @@ DependencyDetection.defer do
|
|
26
28
|
end
|
27
29
|
|
28
30
|
executes do
|
29
|
-
|
30
|
-
|
31
|
+
## We're on an older version of passenger
|
32
|
+
## FIXME: This warning is printing on current version of passenger
|
33
|
+
# NewRelic::Agent.logger.warn "An older version of Phusion Passenger has been detected. We recommend using at least release 2.1.1."
|
31
34
|
|
32
35
|
NewRelic::Agent::Instrumentation::MetricFrame.check_server_connection = true
|
33
36
|
end
|
@@ -172,7 +172,7 @@ module NewRelic
|
|
172
172
|
def record_time_stat(name, start_time, end_time) # (String, Time, Time) -> nil
|
173
173
|
total_time = end_time - start_time
|
174
174
|
if total_time < 0
|
175
|
-
raise "should not provide an end time less than start time: #{end_time} is less than #{start_time}"
|
175
|
+
raise "should not provide an end time less than start time: #{end_time.strftime('%s.%N')} is less than #{start_time.strftime('%s.%N')}. total time is #{total_time}."
|
176
176
|
else
|
177
177
|
NewRelic::Agent.get_stats(name).trace_call(total_time)
|
178
178
|
end
|
@@ -1,73 +1,104 @@
|
|
1
1
|
DependencyDetection.defer do
|
2
|
+
@name = :rails21_view
|
3
|
+
|
2
4
|
depends_on do
|
3
|
-
|
5
|
+
!NewRelic::Control.instance['disable_view_instrumentation'] &&
|
6
|
+
defined?(ActionController) && defined?(ActionController::Base) && defined?(ActionView::PartialTemplate) && defined?(ActionView::Template) &&
|
7
|
+
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.1\./ # Rails 2.1 &&
|
8
|
+
end
|
9
|
+
|
10
|
+
executes do
|
11
|
+
NewRelic::Agent.logger.debug 'Installing Rails 2.1 View instrumentation'
|
4
12
|
end
|
5
13
|
|
6
|
-
|
7
|
-
|
14
|
+
executes do
|
15
|
+
ActionView::PartialTemplate.class_eval do
|
16
|
+
add_method_tracer :render, 'View/#{path_without_extension[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Partial'
|
17
|
+
end
|
18
|
+
# this is for template rendering, as opposed to partial rendering.
|
19
|
+
ActionView::Template.class_eval do
|
20
|
+
add_method_tracer :render, 'View/#{(path_without_extension || @view.controller.newrelic_metric_path)[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Rendering'
|
21
|
+
end
|
8
22
|
end
|
23
|
+
end
|
9
24
|
|
25
|
+
DependencyDetection.defer do
|
26
|
+
@name = :old_rails_view
|
27
|
+
|
10
28
|
depends_on do
|
11
|
-
!NewRelic::Control.instance['disable_view_instrumentation']
|
29
|
+
!NewRelic::Control.instance['disable_view_instrumentation'] &&
|
30
|
+
defined?(ActionController) && defined?(ActionController::Base) &&
|
31
|
+
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^(1\.|2\.0)/ # Rails 1.* - 2.0
|
12
32
|
end
|
13
|
-
|
33
|
+
|
14
34
|
executes do
|
35
|
+
NewRelic::Agent.logger.debug 'Installing Rails 1.* - 2.0 View instrumentation'
|
36
|
+
end
|
37
|
+
|
38
|
+
executes do
|
39
|
+
ActionController::Base.class_eval do
|
40
|
+
add_method_tracer :render, 'View/#{newrelic_metric_path}/Rendering'
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
15
45
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
ActionView::PartialTemplate.class_eval do
|
25
|
-
add_method_tracer :render, 'View/#{path_without_extension[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Partial'
|
26
|
-
end
|
27
|
-
# this is for template rendering, as opposed to partial rendering.
|
28
|
-
ActionView::Template.class_eval do
|
29
|
-
add_method_tracer :render, 'View/#{(path_without_extension || @view.controller.newrelic_metric_path)[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Rendering'
|
30
|
-
end
|
46
|
+
DependencyDetection.defer do
|
47
|
+
@name = :rails23_view
|
48
|
+
|
49
|
+
depends_on do
|
50
|
+
!NewRelic::Control.instance['disable_view_instrumentation'] &&
|
51
|
+
defined?(ActionView) && defined?(ActionView::Template) && defined?(ActionView::RenderablePartial) &&
|
52
|
+
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.[23]/
|
53
|
+
end
|
31
54
|
|
32
|
-
|
33
|
-
|
34
|
-
add_method_tracer :render_partial, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Partial'
|
35
|
-
end
|
36
|
-
ActionView::Template.class_eval do
|
37
|
-
add_method_tracer :render, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Rendering'
|
38
|
-
end
|
39
|
-
end
|
55
|
+
executes do
|
56
|
+
NewRelic::Agent.logger.debug 'Installing Rails 2.2 - 2.3 View instrumentation'
|
40
57
|
end
|
58
|
+
|
59
|
+
executes do
|
60
|
+
ActionView::RenderablePartial.module_eval do
|
61
|
+
add_method_tracer :render_partial, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Partial'
|
62
|
+
end
|
63
|
+
ActionView::Template.class_eval do
|
64
|
+
add_method_tracer :render, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Rendering'
|
65
|
+
end
|
66
|
+
end
|
41
67
|
end
|
42
68
|
|
43
69
|
DependencyDetection.defer do
|
70
|
+
@name = :rails2_controller
|
71
|
+
|
44
72
|
depends_on do
|
45
73
|
defined?(ActionController) && defined?(ActionController::Base)
|
46
74
|
end
|
47
|
-
|
75
|
+
|
48
76
|
depends_on do
|
49
77
|
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 2
|
50
78
|
end
|
51
|
-
|
79
|
+
|
80
|
+
executes do
|
81
|
+
NewRelic::Agent.logger.debug 'Installing Rails 2 Controller instrumentation'
|
82
|
+
end
|
83
|
+
|
52
84
|
executes do
|
53
|
-
|
54
85
|
ActionController::Base.class_eval do
|
55
86
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
56
|
-
|
87
|
+
|
57
88
|
# Compare with #alias_method_chain, which is not available in
|
58
89
|
# Rails 1.1:
|
59
90
|
alias_method :perform_action_without_newrelic_trace, :perform_action
|
60
91
|
alias_method :perform_action, :perform_action_with_newrelic_trace
|
61
92
|
private :perform_action
|
62
|
-
|
93
|
+
|
63
94
|
def self.newrelic_write_attr(attr_name, value) # :nodoc:
|
64
95
|
write_inheritable_attribute(attr_name, value)
|
65
96
|
end
|
66
|
-
|
97
|
+
|
67
98
|
def self.newrelic_read_attr(attr_name) # :nodoc:
|
68
99
|
read_inheritable_attribute(attr_name)
|
69
100
|
end
|
70
|
-
|
101
|
+
|
71
102
|
# determine the path that is used in the metric name for
|
72
103
|
# the called controller action
|
73
104
|
def newrelic_metric_path(action_name_override = nil)
|
@@ -1,8 +1,14 @@
|
|
1
1
|
DependencyDetection.defer do
|
2
|
+
@name = :rails_action_web_service
|
3
|
+
|
2
4
|
depends_on do
|
3
5
|
defined?(ActionWebService)
|
4
6
|
end
|
5
|
-
|
7
|
+
|
8
|
+
executes do
|
9
|
+
NewRelic::Agent.logger.debug 'Installing Rails ActionWebService instrumentation'
|
10
|
+
end
|
11
|
+
|
6
12
|
executes do
|
7
13
|
# NewRelic Agent instrumentation for WebServices
|
8
14
|
|
@@ -1,12 +1,18 @@
|
|
1
1
|
DependencyDetection.defer do
|
2
|
+
@name = :rails2_error
|
3
|
+
|
2
4
|
depends_on do
|
3
5
|
defined?(ActionController) && defined?(ActionController::Base)
|
4
6
|
end
|
5
7
|
|
6
8
|
depends_on do
|
7
|
-
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 2
|
9
|
+
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 2
|
8
10
|
end
|
9
11
|
|
12
|
+
executes do
|
13
|
+
NewRelic::Agent.logger.debug 'Installing Rails 2 Error instrumentation'
|
14
|
+
end
|
15
|
+
|
10
16
|
executes do
|
11
17
|
|
12
18
|
ActionController::Base.class_eval do
|
@@ -36,20 +36,51 @@ module NewRelic
|
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
39
|
+
|
40
|
+
module ActionView
|
41
|
+
module NewRelic
|
42
|
+
extend self
|
43
|
+
def template_metric(identifier, options = {})
|
44
|
+
if options[:file]
|
45
|
+
"file"
|
46
|
+
elsif identifier.nil?
|
47
|
+
"(unknown)"
|
48
|
+
elsif identifier.include? '/' # this is a filepath
|
49
|
+
identifier.split('/')[-2..-1].join('/')
|
50
|
+
else
|
51
|
+
identifier
|
52
|
+
end
|
53
|
+
end
|
54
|
+
def render_type(file_path)
|
55
|
+
file = File.basename(file_path)
|
56
|
+
if file.starts_with?('_')
|
57
|
+
return 'Partial'
|
58
|
+
else
|
59
|
+
return 'Rendering'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
39
64
|
end
|
40
65
|
end
|
41
66
|
end
|
42
67
|
end
|
43
68
|
|
44
69
|
DependencyDetection.defer do
|
70
|
+
@name = :rails3_controller
|
71
|
+
|
45
72
|
depends_on do
|
46
|
-
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 3
|
73
|
+
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
|
47
74
|
end
|
48
75
|
|
49
76
|
depends_on do
|
50
77
|
defined?(ActionController) && defined?(ActionController::Base)
|
51
78
|
end
|
52
79
|
|
80
|
+
executes do
|
81
|
+
NewRelic::Agent.logger.debug 'Installing Rails 3 Controller instrumentation'
|
82
|
+
end
|
83
|
+
|
53
84
|
executes do
|
54
85
|
class ActionController::Base
|
55
86
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
@@ -57,4 +88,93 @@ DependencyDetection.defer do
|
|
57
88
|
end
|
58
89
|
end
|
59
90
|
end
|
91
|
+
DependencyDetection.defer do
|
92
|
+
@name = :rails30_view
|
93
|
+
|
94
|
+
depends_on do
|
95
|
+
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3 && ::Rails::VERSION::MINOR.to_i == 0
|
96
|
+
end
|
97
|
+
|
98
|
+
depends_on do
|
99
|
+
!NewRelic::Control.instance['disable_view_instrumentation']
|
100
|
+
end
|
101
|
+
|
102
|
+
executes do
|
103
|
+
NewRelic::Agent.logger.debug 'Installing Rails 3.0 view instrumentation'
|
104
|
+
end
|
105
|
+
|
106
|
+
executes do
|
107
|
+
ActionView::Template.class_eval do
|
108
|
+
include NewRelic::Agent::MethodTracer
|
109
|
+
def render_with_newrelic(*args, &block)
|
110
|
+
options = if @virtual_path && @virtual_path.starts_with?('/') # file render
|
111
|
+
{:file => true }
|
112
|
+
else
|
113
|
+
{}
|
114
|
+
end
|
115
|
+
str = "View/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.template_metric(@identifier, options)}/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.render_type(@identifier)}"
|
116
|
+
trace_execution_scoped str do
|
117
|
+
render_without_newrelic(*args, &block)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
alias_method :render_without_newrelic, :render
|
122
|
+
alias_method :render, :render_with_newrelic
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
DependencyDetection.defer do
|
129
|
+
@name = :rails31_view
|
130
|
+
|
131
|
+
# We can't be sure that this wil work with future versions of Rails 3.
|
132
|
+
# Currently enabled for Rails 3.1 and 3.2
|
133
|
+
depends_on do
|
134
|
+
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3 && ([1,2].member?(::Rails::VERSION::MINOR.to_i))
|
135
|
+
end
|
136
|
+
|
137
|
+
depends_on do
|
138
|
+
!NewRelic::Control.instance['disable_view_instrumentation']
|
139
|
+
end
|
140
|
+
|
141
|
+
executes do
|
142
|
+
NewRelic::Agent.logger.debug 'Installing Rails 3.1/3.2 view instrumentation'
|
143
|
+
end
|
60
144
|
|
145
|
+
executes do
|
146
|
+
ActionView::TemplateRenderer.class_eval do
|
147
|
+
include NewRelic::Agent::MethodTracer
|
148
|
+
# namespaced helper methods
|
149
|
+
|
150
|
+
def render_with_newrelic(context, options)
|
151
|
+
# This is needed for rails 3.2 compatibility
|
152
|
+
@details = extract_details(options) if respond_to? :extract_details
|
153
|
+
identifier = determine_template(options) ? determine_template(options).identifier : nil
|
154
|
+
str = "View/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.template_metric(identifier, options)}/Rendering"
|
155
|
+
trace_execution_scoped str do
|
156
|
+
render_without_newrelic(context, options)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
alias_method :render_without_newrelic, :render
|
161
|
+
alias_method :render, :render_with_newrelic
|
162
|
+
end
|
163
|
+
|
164
|
+
ActionView::PartialRenderer.class_eval do
|
165
|
+
include NewRelic::Agent::MethodTracer
|
166
|
+
|
167
|
+
def render_with_newrelic(*args, &block)
|
168
|
+
setup(*args, &block)
|
169
|
+
identifier = find_partial ? find_partial.identifier : nil
|
170
|
+
str = "View/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.template_metric(identifier)}/Partial"
|
171
|
+
trace_execution_scoped str do
|
172
|
+
render_without_newrelic(*args, &block)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
alias_method :render_without_newrelic, :render
|
177
|
+
alias_method :render, :render_with_newrelic
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|