newrelic_rpm 3.8.1.221 → 3.9.0.229
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.yardopts +2 -0
- data/CHANGELOG +95 -0
- data/README.md +9 -3
- data/Rakefile +6 -0
- data/lib/new_relic/agent.rb +37 -52
- data/lib/new_relic/agent/agent.rb +32 -64
- data/lib/new_relic/agent/agent_logger.rb +3 -2
- data/lib/new_relic/agent/audit_logger.rb +2 -1
- data/lib/new_relic/agent/busy_calculator.rb +10 -8
- data/lib/new_relic/agent/configuration.rb +0 -13
- data/lib/new_relic/agent/configuration/default_source.rb +27 -20
- data/lib/new_relic/agent/configuration/manager.rb +101 -27
- data/lib/new_relic/agent/cross_app_monitor.rb +43 -50
- data/lib/new_relic/agent/cross_app_tracing.rb +13 -12
- data/lib/new_relic/agent/error_collector.rb +31 -35
- data/lib/new_relic/agent/harvester.rb +5 -1
- data/lib/new_relic/agent/hostname.rb +17 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/uri_util.rb +13 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +18 -32
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +15 -15
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +6 -4
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +3 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +18 -20
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +79 -93
- data/lib/new_relic/agent/instrumentation/curb.rb +3 -3
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +5 -4
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +96 -0
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +69 -0
- data/lib/new_relic/agent/instrumentation/net.rb +1 -1
- data/lib/new_relic/agent/instrumentation/queue_time.rb +21 -13
- data/lib/new_relic/agent/instrumentation/rack.rb +85 -74
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +3 -1
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +39 -0
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +28 -5
- data/lib/new_relic/agent/instrumentation/sinatra.rb +4 -4
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +4 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +34 -30
- data/lib/new_relic/agent/memory_logger.rb +12 -12
- data/lib/new_relic/agent/method_tracer.rb +34 -74
- data/lib/new_relic/agent/new_relic_service.rb +1 -1
- data/lib/new_relic/agent/pipe_channel_manager.rb +3 -3
- data/lib/new_relic/agent/request_sampler.rb +10 -11
- data/lib/new_relic/agent/samplers/vm_sampler.rb +6 -6
- data/lib/new_relic/agent/shim_agent.rb +2 -1
- data/lib/new_relic/agent/sql_sampler.rb +52 -27
- data/lib/new_relic/agent/stats.rb +24 -10
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +5 -17
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +106 -58
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +20 -24
- data/lib/new_relic/agent/supported_versions.rb +3 -1
- data/lib/new_relic/agent/threading/agent_thread.rb +42 -11
- data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
- data/lib/new_relic/agent/threading/thread_profile.rb +2 -2
- data/lib/new_relic/agent/traced_method_stack.rb +28 -18
- data/lib/new_relic/agent/transaction.rb +249 -196
- data/lib/new_relic/agent/transaction_metrics.rb +57 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +10 -7
- data/lib/new_relic/agent/transaction_sampler.rb +81 -45
- data/lib/new_relic/agent/transaction_state.rb +38 -49
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +15 -18
- data/lib/new_relic/agent/vm/rubinius_vm.rb +4 -2
- data/lib/new_relic/cli/commands/deployments.rb +3 -2
- data/lib/new_relic/control/frameworks/ruby.rb +2 -3
- data/lib/new_relic/control/frameworks/sinatra.rb +0 -7
- data/lib/new_relic/control/instance_methods.rb +3 -5
- data/lib/new_relic/json_wrapper.rb +2 -0
- data/lib/new_relic/language_support.rb +1 -1
- data/lib/new_relic/local_environment.rb +0 -16
- data/lib/new_relic/metric_spec.rb +10 -38
- data/lib/new_relic/noticed_error.rb +16 -11
- data/lib/new_relic/rack/agent_hooks.rb +4 -10
- data/lib/new_relic/rack/agent_middleware.rb +31 -0
- data/lib/new_relic/rack/browser_monitoring.rb +7 -13
- data/lib/new_relic/rack/developer_mode.rb +16 -59
- data/lib/new_relic/rack/error_collector.rb +16 -54
- data/lib/new_relic/recipes.rb +8 -101
- data/lib/new_relic/recipes/capistrano3.rb +66 -0
- data/lib/new_relic/recipes/capistrano_legacy.rb +98 -0
- data/lib/new_relic/transaction_sample.rb +6 -54
- data/lib/new_relic/transaction_sample/composite_segment.rb +1 -1
- data/lib/new_relic/transaction_sample/segment.rb +12 -4
- data/lib/new_relic/transaction_sample/summary_segment.rb +1 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +19 -19
- data/lib/tasks/tests.rake +20 -1
- data/lib/tasks/versions.html.erb +0 -4
- data/lib/tasks/versions.rake +4 -3
- data/newrelic.yml +4 -12
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +146 -44
- data/test/config/newrelic.yml +0 -1
- data/test/environments/norails/Gemfile +1 -1
- data/test/environments/rails21/Gemfile +1 -1
- data/test/environments/rails22/Gemfile +1 -1
- data/test/environments/rails23/Gemfile +1 -1
- data/test/environments/rails30/Gemfile +1 -1
- data/test/environments/rails31/Gemfile +1 -1
- data/test/environments/rails32/Gemfile +1 -1
- data/test/environments/rails40/Gemfile +1 -1
- data/test/environments/rails41/Gemfile +1 -1
- data/test/multiverse/lib/multiverse/runner.rb +13 -1
- data/test/multiverse/lib/multiverse/suite.rb +26 -9
- data/test/multiverse/suites/active_record/config/newrelic.yml +0 -1
- data/test/multiverse/suites/activemerchant/Envfile +18 -1
- data/test/multiverse/suites/agent_only/audit_log_test.rb +4 -3
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +35 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +0 -1
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +1 -0
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +3 -2
- data/test/multiverse/suites/agent_only/exclusive_time_test.rb +178 -0
- data/test/multiverse/suites/agent_only/logging_test.rb +10 -6
- data/test/multiverse/suites/agent_only/marshaling_test.rb +11 -9
- data/test/multiverse/suites/agent_only/script/loading.rb +1 -1
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +5 -1
- data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +2 -1
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +9 -9
- data/test/multiverse/suites/capistrano/Capfile +26 -0
- data/test/multiverse/suites/capistrano/Envfile +18 -0
- data/test/multiverse/suites/capistrano/config/deploy.rb +10 -0
- data/test/multiverse/suites/capistrano/config/deploy/production.rb +9 -0
- data/test/multiverse/suites/capistrano/config/newrelic.yml +21 -0
- data/test/multiverse/suites/capistrano/deployment_test.rb +47 -0
- data/test/multiverse/suites/capistrano2/Capfile +4 -0
- data/test/multiverse/suites/capistrano2/Envfile +4 -0
- data/test/multiverse/suites/capistrano2/config/deploy.rb +19 -0
- data/test/multiverse/suites/capistrano2/config/newrelic.yml +21 -0
- data/test/multiverse/suites/capistrano2/deployment_test.rb +38 -0
- data/test/multiverse/suites/curb/Envfile +10 -1
- data/test/multiverse/suites/curb/config/newrelic.yml +0 -1
- data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -1
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +0 -1
- data/test/multiverse/suites/excon/config/newrelic.yml +0 -1
- data/test/multiverse/suites/httpclient/config/newrelic.yml +0 -1
- data/test/multiverse/suites/mongo/config/newrelic.yml +0 -1
- data/test/multiverse/suites/net_http/config/newrelic.yml +0 -1
- data/test/multiverse/suites/padrino/config/newrelic.yml +0 -1
- data/test/multiverse/suites/rack/Envfile +25 -0
- data/test/multiverse/suites/rack/example_app.rb +50 -0
- data/test/multiverse/suites/rack/nested_non_rack_app_test.rb +66 -0
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +143 -0
- data/test/multiverse/suites/rack/rack_unsupported_version_test.rb +45 -0
- data/test/multiverse/suites/rack/url_map_test.rb +120 -0
- data/test/multiverse/suites/rails/Envfile +10 -0
- data/test/multiverse/suites/rails/app.rb +28 -63
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +2 -4
- data/test/multiverse/suites/rails/config/newrelic.yml +1 -2
- data/test/multiverse/suites/rails/dummy.txt +1 -0
- data/test/multiverse/suites/rails/error_tracing_test.rb +46 -31
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +0 -1
- data/test/multiverse/suites/rails/ignore_test.rb +9 -3
- data/test/multiverse/suites/rails/middleware_instrumentation_test.rb +41 -0
- data/test/multiverse/suites/rails/middlewares.rb +19 -0
- data/test/multiverse/suites/rails/parameter_capture_test.rb +169 -0
- data/test/multiverse/suites/rails/queue_time_test.rb +14 -4
- data/test/multiverse/suites/rails/rails2_app/app/controllers/application.rb +7 -0
- data/test/multiverse/suites/rails/rails2_app/config/boot.rb +127 -0
- data/test/multiverse/suites/rails/rails2_app/config/database.yml +18 -0
- data/test/multiverse/suites/rails/rails2_app/config/environment.rb +16 -0
- data/test/multiverse/suites/rails/rails2_app/config/environments/development.rb +10 -0
- data/test/multiverse/suites/rails/rails2_app/config/initializers/load_newrelic_rpm.rb +9 -0
- data/test/multiverse/suites/rails/rails2_app/config/preinitializer.rb +25 -0
- data/test/multiverse/suites/rails/rails2_app/config/routes.rb +18 -0
- data/test/multiverse/suites/rails/rails2_app/db/schema.rb +5 -0
- data/test/multiverse/suites/rails/rails3_app/app_rails3_plus.rb +76 -0
- data/test/multiverse/suites/rails/request_statistics_test.rb +2 -4
- data/test/multiverse/suites/rails/transaction_ignoring_test.rb +3 -5
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +73 -42
- data/test/multiverse/suites/resque/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sequel/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sidekiq/Envfile +4 -0
- data/test/multiverse/suites/sidekiq/after_suite.rb +7 -0
- data/test/multiverse/suites/sidekiq/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +55 -34
- data/test/multiverse/suites/sidekiq/sidekiq_server.rb +30 -0
- data/test/multiverse/suites/sidekiq/test_worker.rb +60 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sinatra/ignoring_test.rb +33 -11
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +3 -1
- data/test/multiverse/suites/typhoeus/Envfile +9 -0
- data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -1
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +10 -0
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
- data/test/new_relic/agent/agent/connect_test.rb +3 -10
- data/test/new_relic/agent/agent_logger_test.rb +24 -6
- data/test/new_relic/agent/agent_test.rb +7 -8
- data/test/new_relic/agent/agent_test_controller.rb +2 -2
- data/test/new_relic/agent/audit_logger_test.rb +5 -1
- data/test/new_relic/agent/busy_calculator_test.rb +1 -1
- data/test/new_relic/agent/configuration/manager_test.rb +68 -69
- data/test/new_relic/agent/cross_app_monitor_test.rb +32 -14
- data/test/new_relic/agent/cross_app_tracing_test.rb +2 -2
- data/test/new_relic/agent/error_collector/notice_error_test.rb +9 -33
- data/test/new_relic/agent/error_collector_test.rb +45 -14
- data/test/new_relic/agent/harvester_test.rb +9 -0
- data/test/new_relic/agent/hostname_test.rb +41 -0
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +27 -19
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_test.rb +3 -3
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +95 -14
- data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +189 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +18 -1
- data/test/new_relic/agent/instrumentation/rack_test.rb +10 -1
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +3 -1
- data/test/new_relic/agent/javascript_instrumentor_test.rb +28 -41
- data/test/new_relic/agent/memory_logger_test.rb +14 -0
- data/test/new_relic/agent/method_interrobang_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -30
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +5 -21
- data/test/new_relic/agent/method_tracer_test.rb +5 -4
- data/test/new_relic/agent/mock_scope_listener.rb +2 -2
- data/test/new_relic/agent/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/pipe_channel_manager_test.rb +17 -5
- data/test/new_relic/agent/request_sampler_test.rb +16 -16
- data/test/new_relic/agent/rpm_agent_test.rb +23 -29
- data/test/new_relic/agent/sql_sampler_test.rb +39 -31
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +189 -117
- data/test/new_relic/agent/stats_engine_test.rb +1 -1
- data/test/new_relic/agent/stats_hash_test.rb +28 -1
- data/test/new_relic/agent/stats_test.rb +1 -12
- data/test/new_relic/agent/threading/agent_thread_test.rb +23 -9
- data/test/new_relic/agent/threading/backtrace_service_test.rb +33 -32
- data/test/new_relic/agent/threading/fake_thread.rb +4 -8
- data/test/new_relic/agent/threading/threaded_test_case.rb +4 -14
- data/test/new_relic/agent/traced_method_stack_test.rb +43 -27
- data/test/new_relic/agent/transaction_interrobang_test.rb +1 -1
- data/test/new_relic/agent/transaction_metrics_test.rb +113 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -61
- data/test/new_relic/agent/transaction_sampler_test.rb +176 -228
- data/test/new_relic/agent/transaction_state_test.rb +62 -26
- data/test/new_relic/agent/transaction_test.rb +198 -80
- data/test/new_relic/agent/vm/monotonic_gc_profiler_test.rb +4 -4
- data/test/new_relic/agent/vm/rubinius_vm_test.rb +68 -0
- data/test/new_relic/agent_test.rb +31 -27
- data/test/new_relic/cli/commands/deployments_test.rb +7 -2
- data/test/new_relic/control/instance_methods_test.rb +4 -4
- data/test/new_relic/control_test.rb +28 -22
- data/test/new_relic/dependency_detection_test.rb +14 -0
- data/test/new_relic/fake_external_server.rb +1 -0
- data/test/new_relic/fake_rpm_site.rb +35 -0
- data/test/new_relic/http_client_test_cases.rb +12 -3
- data/test/new_relic/json_wrapper_test.rb +5 -0
- data/test/new_relic/language_support_test.rb +7 -0
- data/test/new_relic/license_test.rb +11 -5
- data/test/new_relic/local_environment_test.rb +0 -18
- data/test/new_relic/metric_data_test.rb +2 -2
- data/test/new_relic/metric_spec_test.rb +4 -23
- data/test/new_relic/multiverse_helpers.rb +1 -3
- data/test/new_relic/noticed_error_test.rb +6 -22
- data/test/new_relic/rack/agent_hooks_test.rb +5 -1
- data/test/new_relic/rack/agent_middleware_test.rb +32 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +14 -1
- data/test/new_relic/rack/developer_mode_helper_test.rb +0 -8
- data/test/new_relic/rack/developer_mode_test.rb +1 -1
- data/test/new_relic/rack/error_collector_test.rb +6 -30
- data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -2
- data/test/new_relic/transaction_sample/segment_test.rb +47 -47
- data/test/new_relic/transaction_sample_test.rb +9 -8
- data/test/performance/lib/performance/instrumentation/stackprof.rb +11 -8
- data/test/performance/script/runner +13 -0
- data/test/performance/suites/config.rb +5 -2
- data/test/performance/suites/rack_middleware.rb +84 -0
- data/test/performance/suites/rum_autoinsertion.rb +1 -1
- data/test/performance/suites/thread_profiling.rb +1 -1
- data/test/test_helper.rb +12 -10
- data/ui/helpers/developer_mode_helper.rb +3 -43
- data/ui/views/layouts/newrelic_default.rhtml +2 -2
- data/ui/views/newrelic/_sample.rhtml +2 -2
- data/ui/views/newrelic/_sql_row.rhtml +11 -11
- data/ui/views/newrelic/index.rhtml +21 -22
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +15 -10
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +2 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/middleware.rb +34 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/nested.rb +24 -0
- metadata +108 -31
- metadata.gz.sig +0 -0
- data/lib/new_relic/rack/transaction_reset.rb +0 -20
- data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +0 -42
- data/test/new_relic/rack/transaction_reset_test.rb +0 -35
- data/ui/views/newrelic/show_source.rhtml +0 -3
@@ -7,8 +7,6 @@
|
|
7
7
|
require './app'
|
8
8
|
|
9
9
|
class QueueController < ApplicationController
|
10
|
-
include Rails.application.routes.url_helpers
|
11
|
-
|
12
10
|
def queued
|
13
11
|
respond_to do |format|
|
14
12
|
format.html { render :text => "<html><head></head><body>Queued</body></html>" }
|
@@ -25,7 +23,7 @@ class QueueController < ApplicationController
|
|
25
23
|
add_transaction_tracer :nested_transaction
|
26
24
|
end
|
27
25
|
|
28
|
-
class QueueTimeTest <
|
26
|
+
class QueueTimeTest < RailsMultiverseTest
|
29
27
|
|
30
28
|
REQUEST_START_HEADER = 'HTTP_X_REQUEST_START'
|
31
29
|
|
@@ -72,8 +70,20 @@ class QueueTimeTest < ActionDispatch::IntegrationTest
|
|
72
70
|
end
|
73
71
|
|
74
72
|
def extract_queue_time_from_response
|
75
|
-
|
73
|
+
get_last_response_body =~ /\"queueTime\":(\d+.*)/
|
76
74
|
refute_nil $1, "Should have found queue time in #{@response.body.inspect}"
|
77
75
|
$1.to_i
|
78
76
|
end
|
77
|
+
|
78
|
+
def get_last_response_body
|
79
|
+
if Rails::VERSION::MAJOR >= 3
|
80
|
+
@response.body
|
81
|
+
else
|
82
|
+
# In Rails 2 integration tests, @response.body is always the response from
|
83
|
+
# the controller itself, not the middleware stack. Since we want the
|
84
|
+
# response from the middleware stack, we grab it off of the integration
|
85
|
+
# session.
|
86
|
+
@integration_session.body
|
87
|
+
end
|
88
|
+
end
|
79
89
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
class ApplicationController < ActionController::Base
|
6
|
+
helper :all # include all helpers, all the time
|
7
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
# Don't change this file!
|
6
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
7
|
+
|
8
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
9
|
+
|
10
|
+
module Rails
|
11
|
+
class << self
|
12
|
+
def boot!
|
13
|
+
unless booted?
|
14
|
+
preinitialize
|
15
|
+
pick_boot.run
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def booted?
|
20
|
+
defined? Rails::Initializer
|
21
|
+
end
|
22
|
+
|
23
|
+
def pick_boot
|
24
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
25
|
+
end
|
26
|
+
|
27
|
+
def vendor_rails?
|
28
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
29
|
+
end
|
30
|
+
|
31
|
+
def preinitialize
|
32
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
33
|
+
end
|
34
|
+
|
35
|
+
def preinitializer_path
|
36
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Boot
|
41
|
+
def run
|
42
|
+
load_initializer
|
43
|
+
Rails::Initializer.run(:set_load_path)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class VendorBoot < Boot
|
48
|
+
def load_initializer
|
49
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
50
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class GemBoot < Boot
|
55
|
+
def load_initializer
|
56
|
+
self.class.load_rubygems
|
57
|
+
load_rails_gem
|
58
|
+
require 'initializer'
|
59
|
+
end
|
60
|
+
|
61
|
+
def load_rails_gem
|
62
|
+
if version = self.class.gem_version
|
63
|
+
gem 'rails', version
|
64
|
+
else
|
65
|
+
gem 'rails'
|
66
|
+
end
|
67
|
+
rescue Gem::LoadError => load_error
|
68
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
69
|
+
exit 1
|
70
|
+
end
|
71
|
+
|
72
|
+
class << self
|
73
|
+
def rubygems_version
|
74
|
+
Gem::RubyGemsVersion rescue nil
|
75
|
+
end
|
76
|
+
|
77
|
+
def gem_version
|
78
|
+
if defined? RAILS_GEM_VERSION
|
79
|
+
RAILS_GEM_VERSION
|
80
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
81
|
+
ENV['RAILS_GEM_VERSION']
|
82
|
+
else
|
83
|
+
parse_gem_version(read_environment_rb)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def load_rubygems
|
88
|
+
require 'rubygems'
|
89
|
+
min_version = '1.3.1'
|
90
|
+
unless rubygems_version >= min_version
|
91
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
92
|
+
exit 1
|
93
|
+
end
|
94
|
+
|
95
|
+
rescue LoadError
|
96
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
97
|
+
exit 1
|
98
|
+
end
|
99
|
+
|
100
|
+
def parse_gem_version(text)
|
101
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
def read_environment_rb
|
106
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class Rails::Boot
|
113
|
+
def run
|
114
|
+
load_initializer
|
115
|
+
|
116
|
+
Rails::Initializer.class_eval do
|
117
|
+
def load_gems
|
118
|
+
@bundler_loaded ||= Bundler.require :default, Rails.env
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
Rails::Initializer.run(:set_load_path)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# All that for this:
|
127
|
+
Rails.boot!
|
@@ -0,0 +1,18 @@
|
|
1
|
+
sqlite3: &sqlite3
|
2
|
+
<% if defined?(JRuby) %>
|
3
|
+
adapter: jdbcsqlite3
|
4
|
+
<% else %>
|
5
|
+
adapter: sqlite3
|
6
|
+
<% end %>
|
7
|
+
database: ":memory:"
|
8
|
+
pool: 5
|
9
|
+
timeout: 5000
|
10
|
+
|
11
|
+
development:
|
12
|
+
<<: *sqlite3
|
13
|
+
|
14
|
+
test:
|
15
|
+
<<: *sqlite3
|
16
|
+
|
17
|
+
production:
|
18
|
+
<<: *sqlite3
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
6
|
+
|
7
|
+
GC.enable_stats if GC.respond_to?(:enable_stats)
|
8
|
+
|
9
|
+
Rails::Initializer.run do |config|
|
10
|
+
config.action_controller.session = {
|
11
|
+
:key => '_rails22blog_session',
|
12
|
+
:secret => '603603ece6f4792a7a1284a903788646998ad4646ed19d5f06e2af7578660b7b39e54c685f3efa245084eaa5447684a0d8afc96742b63f0e133e8587272c71d1'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'application'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
config.cache_classes = false
|
6
|
+
config.whiny_nils = true
|
7
|
+
config.action_controller.consider_all_requests_local = true
|
8
|
+
config.action_view.debug_rjs = true
|
9
|
+
config.action_controller.perform_caching = false
|
10
|
+
config.action_mailer.raise_delivery_errors = false
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
require 'newrelic_rpm'
|
6
|
+
|
7
|
+
# Needs to be after we've loaded the agent so we're located within our
|
8
|
+
# transaction starting middlewares
|
9
|
+
Rails.configuration.middleware.use ErrorMiddleware
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler'
|
8
|
+
rescue LoadError
|
9
|
+
raise "Could not load the bundler gem. Install it, thanks."
|
10
|
+
end
|
11
|
+
|
12
|
+
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
|
13
|
+
raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
|
14
|
+
"Run `gem install bundler` to upgrade."
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
# Set up load paths for all bundled gems
|
19
|
+
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
|
20
|
+
Bundler.setup
|
21
|
+
rescue Bundler::GemNotFound
|
22
|
+
raise RuntimeError, "Bundler couldn't find some gems." +
|
23
|
+
"Did you run `bundle install`?"
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
# File required to exist by Rails
|
6
|
+
|
7
|
+
ActionController::Routing::Routes.draw do |map|
|
8
|
+
map.connect 'bad_instrumentation/:action', :controller => 'bad_instrumentation'
|
9
|
+
map.connect 'error/:action', :controller => 'error'
|
10
|
+
map.connect 'transaction_ignorer/:action', :controller => 'transaction_ignorer'
|
11
|
+
map.connect 'request_stats/:action', :controller => 'request_stats'
|
12
|
+
map.connect 'queue/:action', :controller => 'queue'
|
13
|
+
map.connect 'views/:action', :controller => 'views'
|
14
|
+
map.connect 'ignored/:action', :controller => 'ignored'
|
15
|
+
map.connect 'parameter_capture/:action', :controller => 'parameter_capture'
|
16
|
+
|
17
|
+
map.connect ':controller/:action'
|
18
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
require 'action_controller/railtie'
|
6
|
+
require 'active_model'
|
7
|
+
require 'rails/test_help'
|
8
|
+
|
9
|
+
# We define our single Rails application here, one time, upon the first inclusion
|
10
|
+
# Tests should feel free to define their own Controllers locally, but if they
|
11
|
+
# need anything special at the Application level, put it here
|
12
|
+
if !defined?(MyApp)
|
13
|
+
|
14
|
+
ENV['NEW_RELIC_DISPATCHER'] = 'test'
|
15
|
+
|
16
|
+
class NamedMiddleware
|
17
|
+
def initialize(app, options={})
|
18
|
+
@app = app
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(env)
|
22
|
+
status, headers, body = @app.call(env)
|
23
|
+
headers['NamedMiddleware'] = '1'
|
24
|
+
[status, headers, body]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class InstanceMiddleware
|
29
|
+
attr_reader :name
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@app = nil
|
33
|
+
@name = 'InstanceMiddleware'
|
34
|
+
end
|
35
|
+
|
36
|
+
# Yes, this is nuts. See the comment above initialize_with_new_relic_trace.
|
37
|
+
def new(app)
|
38
|
+
@app = app
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
def call(env)
|
43
|
+
status, headers, body = @app.call(env)
|
44
|
+
headers['InstanceMiddleware'] = '1'
|
45
|
+
[status, headers, body]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class MyApp < Rails::Application
|
50
|
+
# We need a secret token for session, cookies, etc.
|
51
|
+
config.active_support.deprecation = :log
|
52
|
+
config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
|
53
|
+
config.eager_load = false
|
54
|
+
config.filter_parameters += [:secret]
|
55
|
+
initializer "install_error_middleware" do
|
56
|
+
config.middleware.use ErrorMiddleware
|
57
|
+
end
|
58
|
+
initializer "install_middleware_by_name" do
|
59
|
+
config.middleware.use "NamedMiddleware"
|
60
|
+
end
|
61
|
+
initializer "install_middleware_instance" do
|
62
|
+
config.middleware.use InstanceMiddleware.new
|
63
|
+
end
|
64
|
+
end
|
65
|
+
MyApp.initialize!
|
66
|
+
|
67
|
+
MyApp.routes.draw do
|
68
|
+
get('/bad_route' => 'test#controller_error',
|
69
|
+
:constraints => lambda do |_|
|
70
|
+
raise ActionController::RoutingError.new('this is an uncaught routing error')
|
71
|
+
end)
|
72
|
+
get '/:controller(/:action(/:id))'
|
73
|
+
end
|
74
|
+
|
75
|
+
class ApplicationController < ActionController::Base; end
|
76
|
+
end
|
@@ -7,15 +7,13 @@
|
|
7
7
|
require './app'
|
8
8
|
|
9
9
|
class RequestStatsController < ApplicationController
|
10
|
-
include Rails.application.routes.url_helpers
|
11
|
-
|
12
10
|
def stats_action
|
13
11
|
sleep 0.01
|
14
12
|
render :text => 'some stuff'
|
15
13
|
end
|
16
14
|
|
17
15
|
def cross_app_action
|
18
|
-
NewRelic::Agent::TransactionState.
|
16
|
+
NewRelic::Agent::TransactionState.tl_get.is_cross_app_caller = true
|
19
17
|
render :text => 'some stuff'
|
20
18
|
end
|
21
19
|
|
@@ -25,7 +23,7 @@ class RequestStatsController < ApplicationController
|
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
|
-
class RequestStatsTest <
|
26
|
+
class RequestStatsTest < RailsMultiverseTest
|
29
27
|
extend Multiverse::Color
|
30
28
|
|
31
29
|
include MultiverseHelpers
|
@@ -2,28 +2,26 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
-
require 'rails/test_help'
|
6
5
|
require './app'
|
7
6
|
require 'multiverse_helpers'
|
8
7
|
require File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper')
|
9
8
|
require 'transaction_ignoring_test_cases'
|
10
9
|
|
11
10
|
class TransactionIgnorerController < ApplicationController
|
12
|
-
include Rails.application.routes.url_helpers
|
13
|
-
|
14
11
|
def run_transaction
|
12
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
15
13
|
NewRelic::Agent.set_transaction_name(params[:txn_name])
|
16
14
|
NewRelic::Agent.notice_error(params[:error_msg]) if params[:error_msg]
|
17
15
|
NewRelic::Agent.instance.sql_sampler.notice_sql("select * from test",
|
18
16
|
"Database/test/select",
|
19
|
-
nil, 1.5) if params[:slow_sql]
|
17
|
+
nil, 1.5, state) if params[:slow_sql]
|
20
18
|
render :text => 'some stuff'
|
21
19
|
end
|
22
20
|
|
23
21
|
|
24
22
|
end
|
25
23
|
|
26
|
-
class TransactionIgnoringTest <
|
24
|
+
class TransactionIgnoringTest < RailsMultiverseTest
|
27
25
|
|
28
26
|
include MultiverseHelpers
|
29
27
|
include TransactionIgnoringTestCases
|
@@ -8,8 +8,6 @@ require 'haml'
|
|
8
8
|
ActionController::Base.view_paths = ['app/views']
|
9
9
|
|
10
10
|
class ViewsController < ApplicationController
|
11
|
-
include Rails.application.routes.url_helpers
|
12
|
-
|
13
11
|
def template_render_with_3_partial_renders
|
14
12
|
render 'index'
|
15
13
|
end
|
@@ -41,8 +39,9 @@ class ViewsController < ApplicationController
|
|
41
39
|
end
|
42
40
|
|
43
41
|
def file_render
|
44
|
-
#
|
45
|
-
|
42
|
+
# The choice of filename is significant here: we want a dot in the filename
|
43
|
+
# in order to expose an issue on Rails 2.
|
44
|
+
file = File.expand_path(File.join(File.dirname(__FILE__), "dummy.txt"))
|
46
45
|
render :file => file, :content_type => 'text/plain', :layout => false
|
47
46
|
end
|
48
47
|
|
@@ -84,7 +83,7 @@ class ViewsController < ApplicationController
|
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
87
|
-
class ViewInstrumentationTest <
|
86
|
+
class ViewInstrumentationTest < RailsMultiverseTest
|
88
87
|
include MultiverseHelpers
|
89
88
|
|
90
89
|
setup_and_teardown_agent do
|
@@ -99,6 +98,10 @@ class ViewInstrumentationTest < ActionDispatch::IntegrationTest
|
|
99
98
|
end
|
100
99
|
|
101
100
|
(ViewsController.action_methods - ['raise_render']).each do |method|
|
101
|
+
|
102
|
+
# proc rendering doesn't work on Rails 2
|
103
|
+
next if method == 'proc_render' && Rails::VERSION::MAJOR <= 2
|
104
|
+
|
102
105
|
define_method("test_sanity_#{method}") do
|
103
106
|
get "views/#{method}"
|
104
107
|
assert_equal 200, status
|
@@ -112,85 +115,108 @@ class ViewInstrumentationTest < ActionDispatch::IntegrationTest
|
|
112
115
|
def test_should_count_all_the_template_and_partial_segments
|
113
116
|
get 'views/template_render_with_3_partial_renders'
|
114
117
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
115
|
-
|
118
|
+
segments = find_all_segments_with_name_matching(sample, ['^Nested/Controller/views', '^View'])
|
119
|
+
segments_list = "Found these nodes:\n #{segments.map(&:metric_name).join("\n ")}"
|
120
|
+
|
121
|
+
if Rails::VERSION::MAJOR <= 2
|
122
|
+
assert_equal 8, segments.length, "Should be a node for the controller action, the template, and 3 partials with two nodes each (8). #{segments_list}"
|
123
|
+
else
|
124
|
+
assert_equal 5, segments.length, "Should be a node for the controller action, the template, and 3 partials (5). #{segments_list}"
|
125
|
+
end
|
116
126
|
end
|
117
127
|
|
118
128
|
def test_should_have_3_segments_with_the_correct_metric_name
|
119
129
|
get 'views/template_render_with_3_partial_renders'
|
130
|
+
|
120
131
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
132
|
+
partial_segments = find_all_segments_with_name_matching(sample, 'View/views/_a_partial.html.erb/Partial')
|
121
133
|
|
122
|
-
partial_segments = sample.root_segment.called_segments.first.called_segments.first.called_segments
|
123
134
|
assert_equal 3, partial_segments.size, "sanity check"
|
124
|
-
|
125
135
|
assert_equal ['View/views/_a_partial.html.erb/Partial'], partial_segments.map(&:metric_name).uniq
|
126
136
|
end
|
127
137
|
|
128
|
-
#
|
129
|
-
if Rails::VERSION::MAJOR
|
130
|
-
def
|
131
|
-
get 'views/
|
132
|
-
|
133
|
-
assert_equal [], sample.root_segment.called_segments.first.called_segments
|
134
|
-
end
|
135
|
-
else
|
136
|
-
def test_should_create_a_metric_for_the_rendered_text
|
137
|
-
get 'views/text_render'
|
138
|
+
# We don't capture text or inline template rendering on Rails 2
|
139
|
+
if Rails::VERSION::MAJOR >= 3
|
140
|
+
def test_should_create_a_metric_for_the_rendered_inline_template
|
141
|
+
get 'views/inline_render'
|
142
|
+
|
138
143
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
139
|
-
text_segment = sample
|
140
|
-
|
144
|
+
text_segment = find_segment_with_name(sample, 'View/inline template/Rendering')
|
145
|
+
|
146
|
+
assert text_segment, "Failed to find a node named View/inline template/Rendering"
|
147
|
+
assert_metrics_recorded('View/inline template/Rendering')
|
141
148
|
end
|
142
|
-
end
|
143
149
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
150
|
+
# It doesn't seem worth it to get consistent behavior here.
|
151
|
+
if Rails::VERSION::MAJOR.to_i == 3 && Rails::VERSION::MINOR.to_i == 0
|
152
|
+
def test_should_not_instrument_rendering_of_text
|
153
|
+
get 'views/text_render'
|
154
|
+
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
155
|
+
refute find_segment_with_name(sample, 'View/text template/Rendering')
|
156
|
+
end
|
157
|
+
else
|
158
|
+
def test_should_create_a_metric_for_the_rendered_text
|
159
|
+
get 'views/text_render'
|
160
|
+
|
161
|
+
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
162
|
+
text_segment = find_segment_with_name(sample, 'View/text template/Rendering')
|
163
|
+
|
164
|
+
assert text_segment, "Failed to find a node named View/text template/Rendering"
|
165
|
+
assert_metrics_recorded('View/text template/Rendering')
|
166
|
+
end
|
167
|
+
end
|
149
168
|
end
|
150
169
|
|
151
170
|
def test_should_create_a_metric_for_the_rendered_haml_template
|
152
171
|
get 'views/haml_render'
|
172
|
+
|
153
173
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
154
|
-
text_segment = sample.
|
155
|
-
|
174
|
+
text_segment = find_segment_with_name(sample, 'View/views/haml_view.html.haml/Rendering')
|
175
|
+
|
176
|
+
assert text_segment, "Failed to find a node named View/views/haml_view.html.haml/Rendering"
|
177
|
+
assert_metrics_recorded('View/views/haml_view.html.haml/Rendering')
|
156
178
|
end
|
157
179
|
|
158
180
|
def test_should_create_a_proper_metric_when_the_template_is_unknown
|
159
181
|
get 'views/no_template'
|
160
182
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
161
|
-
text_segment = sample.root_segment.called_segments.first.called_segments.first
|
162
183
|
|
163
184
|
# Different versions have significant difference in handling, but we're
|
164
185
|
# happy enough with what each of them does in the unknown case
|
165
|
-
if Rails::VERSION::MAJOR.to_i == 3 && Rails::VERSION::MINOR.to_i == 0
|
166
|
-
|
186
|
+
if Rails::VERSION::MAJOR.to_i < 3 || (Rails::VERSION::MAJOR.to_i == 3 && Rails::VERSION::MINOR.to_i == 0)
|
187
|
+
refute find_segment_with_name_matching(sample, /^View/)
|
167
188
|
elsif Rails::VERSION::MAJOR.to_i == 3
|
168
|
-
|
189
|
+
assert find_segment_with_name(sample, 'View/collection/Partial')
|
169
190
|
else
|
170
|
-
|
191
|
+
assert find_segment_with_name(sample, 'View/(unknown)/Partial')
|
171
192
|
end
|
172
193
|
end
|
173
194
|
|
174
195
|
def test_should_create_a_proper_metric_when_we_render_a_collection
|
175
196
|
get 'views/collection_render'
|
176
197
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
177
|
-
|
178
|
-
assert_equal "View/foos/_foo.html.haml/Partial", text_segment.metric_name
|
198
|
+
assert find_segment_with_name(sample, "View/foos/_foo.html.haml/Partial")
|
179
199
|
end
|
180
200
|
|
181
201
|
[:js_render, :xml_render, :proc_render, :json_render ].each do |action|
|
202
|
+
next if action == :proc_render && Rails::VERSION::MAJOR <= 2
|
182
203
|
define_method("test_should_not_instrument_rendering_of_#{action}") do
|
183
204
|
get "views/#{action}"
|
184
205
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
185
|
-
|
206
|
+
view_segment = find_segment_with_name_matching(sample, /^View\//)
|
207
|
+
refute view_segment, "Should not instrument rendering of #{action}, found #{view_segment}."
|
186
208
|
end
|
187
209
|
end
|
188
210
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
211
|
+
# The Rails 2.3 view instrumentation doesn't actually pass this test, but it
|
212
|
+
# hasn't been a problem thus far, so we're letting it slide.
|
213
|
+
if Rails::VERSION::MAJOR >= 3
|
214
|
+
def test_should_create_a_metric_for_rendered_file_that_does_not_include_the_filename_so_it_doesnt_metric_explode
|
215
|
+
get 'views/file_render'
|
216
|
+
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
217
|
+
assert find_segment_with_name(sample, 'View/file/Rendering')
|
218
|
+
refute find_segment_with_name_matching(sample, 'dummy')
|
219
|
+
end
|
194
220
|
end
|
195
221
|
|
196
222
|
def test_exclusive_time_for_template_render_metrics_should_not_include_partial_rendering_time
|
@@ -209,9 +235,14 @@ class ViewInstrumentationTest < ActionDispatch::IntegrationTest
|
|
209
235
|
}
|
210
236
|
|
211
237
|
scope = 'Controller/views/render_with_delays'
|
212
|
-
partial_metric = 'View/views/_a_partial.html.erb/Partial'
|
213
238
|
template_metric = 'View/views/index.html.erb/Rendering'
|
214
239
|
|
240
|
+
if Rails::VERSION::MAJOR <= 2
|
241
|
+
partial_metric = 'View/views/_a_partial.html.erb/Rendering'
|
242
|
+
else
|
243
|
+
partial_metric = 'View/views/_a_partial.html.erb/Partial'
|
244
|
+
end
|
245
|
+
|
215
246
|
assert_metrics_recorded(
|
216
247
|
partial_metric => expected_stats_partial,
|
217
248
|
template_metric => expected_stats_template,
|