ghazel-newrelic_rpm 3.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +525 -0
- data/LICENSE +37 -0
- data/README.rdoc +179 -0
- data/bin/mongrel_rpm +33 -0
- data/bin/newrelic +13 -0
- data/bin/newrelic_cmd +5 -0
- data/cert/cacert.pem +118 -0
- data/cert/oldsite.pem +28 -0
- data/cert/site.pem +27 -0
- data/install.rb +9 -0
- data/lib/conditional_vendored_dependency_detection.rb +3 -0
- data/lib/conditional_vendored_metric_parser.rb +5 -0
- data/lib/new_relic/agent.rb +423 -0
- data/lib/new_relic/agent/agent.rb +1040 -0
- data/lib/new_relic/agent/beacon_configuration.rb +61 -0
- data/lib/new_relic/agent/browser_monitoring.rb +83 -0
- data/lib/new_relic/agent/busy_calculator.rb +91 -0
- data/lib/new_relic/agent/chained_call.rb +13 -0
- data/lib/new_relic/agent/error_collector.rb +203 -0
- data/lib/new_relic/agent/instrumentation.rb +9 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +21 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +62 -0
- data/lib/new_relic/agent/instrumentation/authlogic.rb +13 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +413 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +232 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +44 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +56 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +36 -0
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +23 -0
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +326 -0
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +84 -0
- data/lib/new_relic/agent/instrumentation/net.rb +23 -0
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +34 -0
- data/lib/new_relic/agent/instrumentation/queue_time.rb +210 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +98 -0
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +83 -0
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +36 -0
- data/lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb +108 -0
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +36 -0
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +60 -0
- data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +112 -0
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +31 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +54 -0
- data/lib/new_relic/agent/instrumentation/sunspot.rb +23 -0
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +16 -0
- data/lib/new_relic/agent/method_tracer.rb +422 -0
- data/lib/new_relic/agent/sampler.rb +50 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +58 -0
- data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +40 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +144 -0
- data/lib/new_relic/agent/samplers/object_sampler.rb +26 -0
- data/lib/new_relic/agent/shim_agent.rb +29 -0
- data/lib/new_relic/agent/stats_engine.rb +24 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +182 -0
- data/lib/new_relic/agent/stats_engine/samplers.rb +89 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +184 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +101 -0
- data/lib/new_relic/agent/transaction_sampler.rb +378 -0
- data/lib/new_relic/agent/worker_loop.rb +81 -0
- data/lib/new_relic/collection_helper.rb +69 -0
- data/lib/new_relic/command.rb +85 -0
- data/lib/new_relic/commands/deployments.rb +105 -0
- data/lib/new_relic/commands/install.rb +91 -0
- data/lib/new_relic/control.rb +48 -0
- data/lib/new_relic/control/class_methods.rb +47 -0
- data/lib/new_relic/control/configuration.rb +157 -0
- data/lib/new_relic/control/frameworks/external.rb +16 -0
- data/lib/new_relic/control/frameworks/merb.rb +30 -0
- data/lib/new_relic/control/frameworks/rails.rb +151 -0
- data/lib/new_relic/control/frameworks/rails3.rb +70 -0
- data/lib/new_relic/control/frameworks/ruby.rb +42 -0
- data/lib/new_relic/control/frameworks/sinatra.rb +23 -0
- data/lib/new_relic/control/instance_methods.rb +154 -0
- data/lib/new_relic/control/instrumentation.rb +81 -0
- data/lib/new_relic/control/logging_methods.rb +88 -0
- data/lib/new_relic/control/profiling.rb +25 -0
- data/lib/new_relic/control/server_methods.rb +104 -0
- data/lib/new_relic/data_serialization.rb +84 -0
- data/lib/new_relic/delayed_job_injection.rb +38 -0
- data/lib/new_relic/histogram.rb +91 -0
- data/lib/new_relic/local_environment.rb +391 -0
- data/lib/new_relic/merbtasks.rb +6 -0
- data/lib/new_relic/metric_data.rb +46 -0
- data/lib/new_relic/metric_spec.rb +73 -0
- data/lib/new_relic/metrics.rb +9 -0
- data/lib/new_relic/noticed_error.rb +24 -0
- data/lib/new_relic/rack/browser_monitoring.rb +68 -0
- data/lib/new_relic/rack/developer_mode.rb +267 -0
- data/lib/new_relic/rack/metric_app.rb +65 -0
- data/lib/new_relic/rack/mongrel_rpm.ru +28 -0
- data/lib/new_relic/rack/newrelic.yml +27 -0
- data/lib/new_relic/rack_app.rb +6 -0
- data/lib/new_relic/recipes.rb +73 -0
- data/lib/new_relic/stats.rb +378 -0
- data/lib/new_relic/timer_lib.rb +27 -0
- data/lib/new_relic/transaction_analysis.rb +76 -0
- data/lib/new_relic/transaction_analysis/segment_summary.rb +47 -0
- data/lib/new_relic/transaction_sample.rb +272 -0
- data/lib/new_relic/transaction_sample/composite_segment.rb +27 -0
- data/lib/new_relic/transaction_sample/fake_segment.rb +9 -0
- data/lib/new_relic/transaction_sample/segment.rb +251 -0
- data/lib/new_relic/transaction_sample/summary_segment.rb +21 -0
- data/lib/new_relic/url_rule.rb +14 -0
- data/lib/new_relic/version.rb +55 -0
- data/lib/newrelic_rpm.rb +49 -0
- data/lib/tasks/all.rb +4 -0
- data/lib/tasks/install.rake +7 -0
- data/lib/tasks/tests.rake +19 -0
- data/newrelic.yml +265 -0
- data/newrelic_rpm.gemspec +330 -0
- data/recipes/newrelic.rb +6 -0
- data/test/active_record_fixtures.rb +77 -0
- data/test/config/newrelic.yml +48 -0
- data/test/config/test_control.rb +48 -0
- data/test/new_relic/agent/agent/connect_test.rb +316 -0
- data/test/new_relic/agent/agent/start_test.rb +340 -0
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +155 -0
- data/test/new_relic/agent/agent_test.rb +173 -0
- data/test/new_relic/agent/agent_test_controller.rb +77 -0
- data/test/new_relic/agent/agent_test_controller_test.rb +366 -0
- data/test/new_relic/agent/apdex_from_server_test.rb +9 -0
- data/test/new_relic/agent/beacon_configuration_test.rb +104 -0
- data/test/new_relic/agent/browser_monitoring_test.rb +274 -0
- data/test/new_relic/agent/busy_calculator_test.rb +81 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +257 -0
- data/test/new_relic/agent/error_collector_test.rb +168 -0
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +522 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +36 -0
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +11 -0
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +179 -0
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +50 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +84 -0
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +387 -0
- data/test/new_relic/agent/instrumentation/rack_test.rb +35 -0
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +184 -0
- data/test/new_relic/agent/memcache_instrumentation_test.rb +107 -0
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +164 -0
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +234 -0
- data/test/new_relic/agent/method_tracer_test.rb +386 -0
- data/test/new_relic/agent/mock_scope_listener.rb +23 -0
- data/test/new_relic/agent/rpm_agent_test.rb +149 -0
- data/test/new_relic/agent/sampler_test.rb +19 -0
- data/test/new_relic/agent/shim_agent_test.rb +20 -0
- data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +150 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +81 -0
- data/test/new_relic/agent/stats_engine/samplers_test.rb +99 -0
- data/test/new_relic/agent/stats_engine_test.rb +185 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +195 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +945 -0
- data/test/new_relic/agent/worker_loop_test.rb +66 -0
- data/test/new_relic/collection_helper_test.rb +127 -0
- data/test/new_relic/command/deployments_test.rb +68 -0
- data/test/new_relic/control/class_methods_test.rb +62 -0
- data/test/new_relic/control/logging_methods_test.rb +157 -0
- data/test/new_relic/control_test.rb +195 -0
- data/test/new_relic/data_serialization_test.rb +70 -0
- data/test/new_relic/local_environment_test.rb +72 -0
- data/test/new_relic/metric_data_test.rb +125 -0
- data/test/new_relic/metric_spec_test.rb +95 -0
- data/test/new_relic/rack/all_test.rb +11 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +84 -0
- data/test/new_relic/rack/developer_mode_test.rb +43 -0
- data/test/new_relic/stats_test.rb +426 -0
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +77 -0
- data/test/new_relic/transaction_analysis_test.rb +121 -0
- data/test/new_relic/transaction_sample/composite_segment_test.rb +35 -0
- data/test/new_relic/transaction_sample/fake_segment_test.rb +17 -0
- data/test/new_relic/transaction_sample/segment_test.rb +454 -0
- data/test/new_relic/transaction_sample/summary_segment_test.rb +31 -0
- data/test/new_relic/transaction_sample_subtest_test.rb +56 -0
- data/test/new_relic/transaction_sample_test.rb +170 -0
- data/test/new_relic/version_number_test.rb +89 -0
- data/test/test_contexts.rb +29 -0
- data/test/test_helper.rb +144 -0
- data/ui/helpers/developer_mode_helper.rb +351 -0
- data/ui/helpers/google_pie_chart.rb +49 -0
- data/ui/views/layouts/newrelic_default.rhtml +47 -0
- data/ui/views/newrelic/_explain_plans.rhtml +27 -0
- data/ui/views/newrelic/_sample.rhtml +20 -0
- data/ui/views/newrelic/_segment.rhtml +28 -0
- data/ui/views/newrelic/_segment_limit_message.rhtml +1 -0
- data/ui/views/newrelic/_segment_row.rhtml +12 -0
- data/ui/views/newrelic/_show_sample_detail.rhtml +24 -0
- data/ui/views/newrelic/_show_sample_sql.rhtml +24 -0
- data/ui/views/newrelic/_show_sample_summary.rhtml +3 -0
- data/ui/views/newrelic/_sql_row.rhtml +16 -0
- data/ui/views/newrelic/_stack_trace.rhtml +15 -0
- data/ui/views/newrelic/_table.rhtml +12 -0
- data/ui/views/newrelic/explain_sql.rhtml +43 -0
- data/ui/views/newrelic/file/images/arrow-close.png +0 -0
- data/ui/views/newrelic/file/images/arrow-open.png +0 -0
- data/ui/views/newrelic/file/images/blue_bar.gif +0 -0
- data/ui/views/newrelic/file/images/file_icon.png +0 -0
- data/ui/views/newrelic/file/images/gray_bar.gif +0 -0
- data/ui/views/newrelic/file/images/new-relic-rpm-desktop.gif +0 -0
- data/ui/views/newrelic/file/images/new_relic_rpm_desktop.gif +0 -0
- data/ui/views/newrelic/file/images/textmate.png +0 -0
- data/ui/views/newrelic/file/javascript/jquery-1.4.2.js +6240 -0
- data/ui/views/newrelic/file/javascript/transaction_sample.js +120 -0
- data/ui/views/newrelic/file/stylesheets/style.css +490 -0
- data/ui/views/newrelic/index.rhtml +71 -0
- data/ui/views/newrelic/sample_not_found.rhtml +2 -0
- data/ui/views/newrelic/show_sample.rhtml +80 -0
- data/ui/views/newrelic/show_source.rhtml +3 -0
- data/ui/views/newrelic/threads.rhtml +53 -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
- data/vendor/gems/metric_parser-0.1.0.pre1/LICENSE +0 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/README +0 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/metric_parser.rb +1 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +64 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +14 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +31 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +33 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +89 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +46 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +67 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +43 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +17 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +48 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +24 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +28 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +17 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/errors.rb +11 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +55 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +40 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +20 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +31 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +17 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +34 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +55 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +122 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +27 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +40 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +27 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +15 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +54 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_controller.rb +6 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_view.rb +6 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +20 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +20 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/version.rb +5 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +66 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb +18 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb +14 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +133 -0
- metadata +399 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
DependencyDetection.defer do
|
2
|
+
depends_on do
|
3
|
+
defined?(ActionController) && defined?(ActionController::Base)
|
4
|
+
end
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 2
|
8
|
+
end
|
9
|
+
|
10
|
+
depends_on do
|
11
|
+
!NewRelic::Control.instance['disable_view_instrumentation']
|
12
|
+
end
|
13
|
+
|
14
|
+
executes do
|
15
|
+
|
16
|
+
case Rails::VERSION::STRING
|
17
|
+
|
18
|
+
when /^(1\.|2\.0)/ # Rails 1.* - 2.0
|
19
|
+
ActionController::Base.class_eval do
|
20
|
+
add_method_tracer :render, 'View/#{newrelic_metric_path}/Rendering'
|
21
|
+
end
|
22
|
+
|
23
|
+
when /^2\.1\./ # Rails 2.1
|
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
|
31
|
+
|
32
|
+
when /^2\./ # Rails 2.2-2.*
|
33
|
+
ActionView::RenderablePartial.module_eval do
|
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
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
DependencyDetection.defer do
|
44
|
+
depends_on do
|
45
|
+
defined?(ActionController) && defined?(ActionController::Base)
|
46
|
+
end
|
47
|
+
|
48
|
+
depends_on do
|
49
|
+
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 2
|
50
|
+
end
|
51
|
+
|
52
|
+
executes do
|
53
|
+
|
54
|
+
ActionController::Base.class_eval do
|
55
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
56
|
+
|
57
|
+
# Compare with #alias_method_chain, which is not available in
|
58
|
+
# Rails 1.1:
|
59
|
+
alias_method :perform_action_without_newrelic_trace, :perform_action
|
60
|
+
alias_method :perform_action, :perform_action_with_newrelic_trace
|
61
|
+
private :perform_action
|
62
|
+
|
63
|
+
def self.newrelic_write_attr(attr_name, value) # :nodoc:
|
64
|
+
write_inheritable_attribute(attr_name, value)
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.newrelic_read_attr(attr_name) # :nodoc:
|
68
|
+
read_inheritable_attribute(attr_name)
|
69
|
+
end
|
70
|
+
|
71
|
+
# determine the path that is used in the metric name for
|
72
|
+
# the called controller action
|
73
|
+
def newrelic_metric_path(action_name_override = nil)
|
74
|
+
action_part = action_name_override || action_name
|
75
|
+
if action_name_override || self.class.action_methods.include?(action_part)
|
76
|
+
"#{self.class.controller_path}/#{action_part}"
|
77
|
+
else
|
78
|
+
"#{self.class.controller_path}/(other)"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
DependencyDetection.defer do
|
2
|
+
depends_on do
|
3
|
+
defined?(ActionWebService)
|
4
|
+
end
|
5
|
+
|
6
|
+
executes do
|
7
|
+
# NewRelic Agent instrumentation for WebServices
|
8
|
+
|
9
|
+
# Note Action Web Service is removed from default package in rails
|
10
|
+
# 2.0, this is purely here as a service to our legacy customers.
|
11
|
+
|
12
|
+
# instrumentation for Web Service martialing - XML RPC
|
13
|
+
ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.class_eval do
|
14
|
+
add_method_tracer :decode_request, "WebService/Xml Rpc/XML Decode"
|
15
|
+
add_method_tracer :encode_request, "WebService/Xml Rpc/XML Encode"
|
16
|
+
add_method_tracer :decode_response, "WebService/Xml Rpc/XML Decode"
|
17
|
+
add_method_tracer :encode_response, "WebService/Xml Rpc/XML Encode"
|
18
|
+
end
|
19
|
+
|
20
|
+
# instrumentation for Web Service martialing - Soap
|
21
|
+
ActionWebService::Protocol::Soap::SoapProtocol.class_eval do
|
22
|
+
add_method_tracer :decode_request, "WebService/Soap/XML Decode"
|
23
|
+
add_method_tracer :encode_request, "WebService/Soap/XML Encode"
|
24
|
+
add_method_tracer :decode_response, "WebService/Soap/XML Decode"
|
25
|
+
add_method_tracer :encode_response, "WebService/Soap/XML Encode"
|
26
|
+
end
|
27
|
+
|
28
|
+
if defined?(ActionController) && defined?(ActionController::Base)
|
29
|
+
ActionController::Base.class_eval do
|
30
|
+
if method_defined? :perform_invocation
|
31
|
+
add_method_tracer :perform_invocation, 'WebService/#{controller_name}/#{args.first}'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module NewRelic
|
2
|
+
module Agent
|
3
|
+
module Instrumentation
|
4
|
+
module ActiveRecordInstrumentation
|
5
|
+
|
6
|
+
def self.included(instrumented_class)
|
7
|
+
instrumented_class.class_eval do
|
8
|
+
alias_method :log_without_newrelic_instrumentation, :log
|
9
|
+
alias_method :log, :log_with_newrelic_instrumentation
|
10
|
+
protected :log
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def log_with_newrelic_instrumentation(sql, name, &block)
|
15
|
+
|
16
|
+
return log_without_newrelic_instrumentation(sql, name, &block) unless NewRelic::Agent.is_execution_traced?
|
17
|
+
|
18
|
+
# Capture db config if we are going to try to get the explain plans
|
19
|
+
if (defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)) ||
|
20
|
+
(defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && self.is_a?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)) ||
|
21
|
+
(defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter))
|
22
|
+
supported_config = @config
|
23
|
+
end
|
24
|
+
if name && (parts = name.split " ") && parts.size == 2
|
25
|
+
model = parts.first
|
26
|
+
operation = parts.last.downcase
|
27
|
+
metric_name = case operation
|
28
|
+
when 'load' then 'find'
|
29
|
+
when 'indexes', 'columns' then nil # fall back to DirectSQL
|
30
|
+
when 'destroy', 'find', 'save', 'create' then operation
|
31
|
+
when 'update' then 'save'
|
32
|
+
else
|
33
|
+
if model == 'Join'
|
34
|
+
operation
|
35
|
+
end
|
36
|
+
end
|
37
|
+
metric = "ActiveRecord/#{model}/#{metric_name}" if metric_name
|
38
|
+
end
|
39
|
+
|
40
|
+
if metric.nil?
|
41
|
+
metric = NewRelic::Agent::Instrumentation::MetricFrame.database_metric_name
|
42
|
+
if metric.nil?
|
43
|
+
if sql =~ /^(select|update|insert|delete|show)/i
|
44
|
+
# Could not determine the model/operation so let's find a better
|
45
|
+
# metric. If it doesn't match the regex, it's probably a show
|
46
|
+
# command or some DDL which we'll ignore.
|
47
|
+
metric = "Database/SQL/#{$1.downcase}"
|
48
|
+
else
|
49
|
+
metric = "Database/SQL/other"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
if !metric
|
55
|
+
log_without_newrelic_instrumentation(sql, name, &block)
|
56
|
+
else
|
57
|
+
metrics = [metric, "ActiveRecord/all"]
|
58
|
+
metrics << "ActiveRecord/#{metric_name}" if metric_name
|
59
|
+
self.class.trace_execution_scoped(metrics) do
|
60
|
+
t0 = Time.now
|
61
|
+
begin
|
62
|
+
log_without_newrelic_instrumentation(sql, name, &block)
|
63
|
+
ensure
|
64
|
+
NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, supported_config, (Time.now - t0).to_f)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
DependencyDetection.defer do
|
76
|
+
depends_on do
|
77
|
+
defined?(ActiveRecord) && defined?(ActiveRecord::Base)
|
78
|
+
end
|
79
|
+
|
80
|
+
depends_on do
|
81
|
+
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 2
|
82
|
+
end
|
83
|
+
|
84
|
+
depends_on do
|
85
|
+
!NewRelic::Control.instance['skip_ar_instrumentation']
|
86
|
+
end
|
87
|
+
|
88
|
+
depends_on do
|
89
|
+
!NewRelic::Control.instance['disable_activerecord_instrumentation']
|
90
|
+
end
|
91
|
+
|
92
|
+
executes do
|
93
|
+
ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
|
94
|
+
include ::NewRelic::Agent::Instrumentation::ActiveRecordInstrumentation
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
executes do
|
99
|
+
ActiveRecord::Base.class_eval do
|
100
|
+
class << self
|
101
|
+
add_method_tracer :find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql', :metric => false
|
102
|
+
add_method_tracer :transaction, 'ActiveRecord/#{self.name}/transaction', :metric => false
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
DependencyDetection.detect!
|
@@ -0,0 +1,36 @@
|
|
1
|
+
DependencyDetection.defer do
|
2
|
+
depends_on do
|
3
|
+
defined?(ActionController) && defined?(ActionController::Base)
|
4
|
+
end
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 2
|
8
|
+
end
|
9
|
+
|
10
|
+
executes do
|
11
|
+
|
12
|
+
ActionController::Base.class_eval do
|
13
|
+
|
14
|
+
# Make a note of an exception associated with the currently executing
|
15
|
+
# controller action. Note that this used to be available on Object
|
16
|
+
# but we replaced that global method with NewRelic::Agent#notice_error.
|
17
|
+
# Use that one outside of controller actions.
|
18
|
+
def newrelic_notice_error(exception, custom_params = {})
|
19
|
+
NewRelic::Agent::Instrumentation::MetricFrame.notice_error exception, :custom_params => custom_params, :request => request
|
20
|
+
end
|
21
|
+
|
22
|
+
def rescue_action_with_newrelic_trace(exception)
|
23
|
+
rescue_action_without_newrelic_trace exception
|
24
|
+
NewRelic::Agent::Instrumentation::MetricFrame.notice_error exception, :request => request
|
25
|
+
end
|
26
|
+
|
27
|
+
# Compare with #alias_method_chain, which is not available in
|
28
|
+
# Rails 1.1:
|
29
|
+
alias_method :rescue_action_without_newrelic_trace, :rescue_action
|
30
|
+
alias_method :rescue_action, :rescue_action_with_newrelic_trace
|
31
|
+
protected :rescue_action
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module NewRelic
|
2
|
+
module Agent
|
3
|
+
module Instrumentation
|
4
|
+
module Rails3
|
5
|
+
module ActionController
|
6
|
+
def self.newrelic_write_attr(attr_name, value) # :nodoc:
|
7
|
+
write_inheritable_attribute(attr_name, value)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.newrelic_read_attr(attr_name) # :nodoc:
|
11
|
+
read_inheritable_attribute(attr_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
# determine the path that is used in the metric name for
|
15
|
+
# the called controller action
|
16
|
+
def newrelic_metric_path(action_name_override = nil)
|
17
|
+
action_part = action_name_override || action_name
|
18
|
+
if action_name_override || self.class.action_methods.include?(action_part)
|
19
|
+
"#{self.class.controller_path}/#{action_part}"
|
20
|
+
else
|
21
|
+
"#{self.class.controller_path}/(other)"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def process_action(*args)
|
26
|
+
# skip instrumentation if we are in an ignored action
|
27
|
+
if _is_filtered?('do_not_trace')
|
28
|
+
NewRelic::Agent.disable_all_tracing do
|
29
|
+
return super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
perform_action_with_newrelic_trace(:category => :controller, :name => self.action_name, :path => newrelic_metric_path, :params => request.filtered_parameters, :class_name => self.class.name) do
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
DependencyDetection.defer do
|
45
|
+
depends_on do
|
46
|
+
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 3
|
47
|
+
end
|
48
|
+
|
49
|
+
depends_on do
|
50
|
+
defined?(ActionController) && defined?(ActionController::Base)
|
51
|
+
end
|
52
|
+
|
53
|
+
executes do
|
54
|
+
class ActionController::Base
|
55
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
56
|
+
include NewRelic::Agent::Instrumentation::Rails3::ActionController
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module NewRelic
|
2
|
+
module Agent
|
3
|
+
module Instrumentation
|
4
|
+
module ActiveRecordInstrumentation
|
5
|
+
|
6
|
+
def self.included(instrumented_class)
|
7
|
+
instrumented_class.class_eval do
|
8
|
+
unless instrumented_class.method_defined?(:log_without_newrelic_instrumentation)
|
9
|
+
alias_method :log_without_newrelic_instrumentation, :log
|
10
|
+
alias_method :log, :log_with_newrelic_instrumentation
|
11
|
+
protected :log
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def log_with_newrelic_instrumentation(sql, name, &block)
|
17
|
+
|
18
|
+
return log_without_newrelic_instrumentation(sql, name, &block) unless NewRelic::Agent.is_execution_traced?
|
19
|
+
|
20
|
+
# Capture db config if we are going to try to get the explain plans
|
21
|
+
if (defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)) ||
|
22
|
+
(defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && self.is_a?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)) ||
|
23
|
+
(defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter))
|
24
|
+
supported_config = @config
|
25
|
+
end
|
26
|
+
if name && (parts = name.split " ") && parts.size == 2
|
27
|
+
model = parts.first
|
28
|
+
operation = parts.last.downcase
|
29
|
+
metric_name = case operation
|
30
|
+
when 'load' then 'find'
|
31
|
+
when 'indexes', 'columns' then nil # fall back to DirectSQL
|
32
|
+
when 'destroy', 'find', 'save', 'create' then operation
|
33
|
+
when 'update' then 'save'
|
34
|
+
else
|
35
|
+
if model == 'Join'
|
36
|
+
operation
|
37
|
+
end
|
38
|
+
end
|
39
|
+
metric = "ActiveRecord/#{model}/#{metric_name}" if metric_name
|
40
|
+
end
|
41
|
+
|
42
|
+
if metric.nil?
|
43
|
+
metric = NewRelic::Agent::Instrumentation::MetricFrame.database_metric_name
|
44
|
+
if metric.nil?
|
45
|
+
if sql =~ /^(select|update|insert|delete|show)/i
|
46
|
+
# Could not determine the model/operation so let's find a better
|
47
|
+
# metric. If it doesn't match the regex, it's probably a show
|
48
|
+
# command or some DDL which we'll ignore.
|
49
|
+
metric = "Database/SQL/#{$1.downcase}"
|
50
|
+
else
|
51
|
+
metric = "Database/SQL/other"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if !metric
|
57
|
+
log_without_newrelic_instrumentation(sql, name, &block)
|
58
|
+
else
|
59
|
+
metrics = [metric, "ActiveRecord/all"]
|
60
|
+
metrics << "ActiveRecord/#{metric_name}" if metric_name
|
61
|
+
self.class.trace_execution_scoped(metrics) do
|
62
|
+
t0 = Time.now
|
63
|
+
begin
|
64
|
+
log_without_newrelic_instrumentation(sql, name, &block)
|
65
|
+
ensure
|
66
|
+
NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, supported_config, (Time.now - t0).to_f)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
DependencyDetection.defer do
|
78
|
+
depends_on do
|
79
|
+
defined?(ActiveRecord) && defined?(ActiveRecord::Base)
|
80
|
+
end
|
81
|
+
|
82
|
+
depends_on do
|
83
|
+
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 3
|
84
|
+
end
|
85
|
+
|
86
|
+
depends_on do
|
87
|
+
!NewRelic::Control.instance['skip_ar_instrumentation']
|
88
|
+
end
|
89
|
+
|
90
|
+
depends_on do
|
91
|
+
!NewRelic::Control.instance['disable_activerecord_instrumentation']
|
92
|
+
end
|
93
|
+
|
94
|
+
executes do
|
95
|
+
Rails.configuration.after_initialize do
|
96
|
+
ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
|
97
|
+
include ::NewRelic::Agent::Instrumentation::ActiveRecordInstrumentation
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
executes do
|
103
|
+
Rails.configuration.after_initialize do
|
104
|
+
ActiveRecord::Base.class_eval do
|
105
|
+
class << self
|
106
|
+
add_method_tracer :find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql', :metric => false
|
107
|
+
add_method_tracer :transaction, 'ActiveRecord/#{self.name}/transaction', :metric => false
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module NewRelic
|
2
|
+
module Agent
|
3
|
+
module Instrumentation
|
4
|
+
module Rails3
|
5
|
+
module Errors
|
6
|
+
def newrelic_notice_error(exception, custom_params = {})
|
7
|
+
filtered_params = (respond_to? :filter_parameters) ? filter_parameters(params) : params
|
8
|
+
filtered_params.merge!(custom_params)
|
9
|
+
NewRelic::Agent.agent.error_collector.notice_error(exception, request, newrelic_metric_path, filtered_params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
DependencyDetection.defer do
|
18
|
+
depends_on do
|
19
|
+
defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_i == 3
|
20
|
+
end
|
21
|
+
|
22
|
+
depends_on do
|
23
|
+
defined?(ActionController) && defined?(ActionController::Base)
|
24
|
+
end
|
25
|
+
|
26
|
+
executes do
|
27
|
+
class ActionController::Base
|
28
|
+
include NewRelic::Agent::Instrumentation::Rails3::Errors
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|