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
@@ -32,3 +32,13 @@ gemfile <<-RB
|
|
32
32
|
gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
|
33
33
|
gem 'minitest_tu_shim', :require => false
|
34
34
|
RB
|
35
|
+
|
36
|
+
if RUBY_VERSION <= '1.9.3' && (!defined?(RUBY_ENGINE) || RUBY_ENGINE != 'jruby')
|
37
|
+
gemfile <<-RB
|
38
|
+
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
|
39
|
+
gem 'rails', '~> 2.3.18'
|
40
|
+
gem 'haml', '~> 3.1.0' # last haml version that supports Rails 2
|
41
|
+
gem 'minitest_tu_shim', :require => false
|
42
|
+
gem 'sqlite3'
|
43
|
+
RB
|
44
|
+
end
|
@@ -2,79 +2,44 @@
|
|
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 'action_controller/railtie'
|
6
|
-
require 'active_model'
|
7
|
-
|
8
5
|
require 'multiverse_helpers'
|
9
|
-
require '
|
10
|
-
|
11
|
-
# We define our single Rails application here, one time, upon the first inclusion
|
12
|
-
# Tests should feel free to define their own Controllers locally, but if they
|
13
|
-
# need anything special at the Application level, put it here
|
14
|
-
if !defined?(MyApp)
|
6
|
+
require File.join(File.dirname(__FILE__), 'middlewares')
|
15
7
|
|
16
|
-
|
8
|
+
suite_dir = File.expand_path(File.dirname(__FILE__))
|
17
9
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR > 2
|
11
|
+
require File.join(suite_dir, 'rails3_app', 'app_rails3_plus')
|
12
|
+
class RailsMultiverseTest < ActionDispatch::IntegrationTest; end
|
13
|
+
elsif !defined?(RAILS_ROOT)
|
14
|
+
RAILS_ROOT = File.join(suite_dir, 'rails2_app')
|
15
|
+
require File.join(RAILS_ROOT, 'config', 'environment')
|
16
|
+
class RailsMultiverseTest < ActionController::IntegrationTest; end
|
17
|
+
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
result = @app.call(env)
|
27
|
-
raise "middleware error" if path.match(/\/middleware_error\/after/)
|
28
|
-
result
|
29
|
-
end
|
30
|
-
end
|
19
|
+
# a basic active model compliant model we can render
|
20
|
+
class Foo
|
21
|
+
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
|
31
22
|
|
32
|
-
|
33
|
-
|
34
|
-
config.active_support.deprecation = :log
|
35
|
-
config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
|
36
|
-
config.eager_load = false
|
37
|
-
config.filter_parameters += [:secret]
|
38
|
-
initializer "install_error_middleware" do
|
39
|
-
config.middleware.use ErrorMiddleware
|
40
|
-
end
|
23
|
+
def to_model
|
24
|
+
self
|
41
25
|
end
|
42
|
-
MyApp.initialize!
|
43
26
|
|
44
|
-
|
45
|
-
|
46
|
-
:constraints => lambda do |_|
|
47
|
-
raise ActionController::RoutingError.new('this is an uncaught routing error')
|
48
|
-
end)
|
49
|
-
get '/:controller(/:action(/:id))'
|
27
|
+
def to_partial_path
|
28
|
+
'foos/foo'
|
50
29
|
end
|
51
30
|
|
52
|
-
|
31
|
+
def valid?() true end
|
32
|
+
def new_record?() true end
|
33
|
+
def destroyed?() true end
|
53
34
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
def to_model
|
58
|
-
self
|
59
|
-
end
|
60
|
-
|
61
|
-
def to_partial_path
|
62
|
-
'foos/foo'
|
63
|
-
end
|
64
|
-
|
65
|
-
def valid?() true end
|
66
|
-
def new_record?() true end
|
67
|
-
def destroyed?() true end
|
68
|
-
|
69
|
-
def raise_error
|
70
|
-
raise 'this is an uncaught model error'
|
71
|
-
end
|
35
|
+
def raise_error
|
36
|
+
raise 'this is an uncaught model error'
|
37
|
+
end
|
72
38
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
39
|
+
def errors
|
40
|
+
obj = Object.new
|
41
|
+
def obj.[](key) [] end
|
42
|
+
def obj.full_messages() [] end
|
43
|
+
obj
|
79
44
|
end
|
80
45
|
end
|
@@ -5,20 +5,18 @@
|
|
5
5
|
require './app'
|
6
6
|
|
7
7
|
class BadInstrumentationController < ApplicationController
|
8
|
-
include Rails.application.routes.url_helpers
|
9
|
-
|
10
8
|
# This action is intended to simulate a chunk of instrumentation that pushes
|
11
9
|
# a traced method frame, but then never pops it. Such a situation will break
|
12
10
|
# instrumentation of that request, but should not actually cause the request
|
13
11
|
# to fail.
|
14
12
|
# https://newrelic.atlassian.net/browse/RUBY-1158
|
15
13
|
def failwhale
|
16
|
-
NewRelic::Agent::TracedMethodStack.
|
14
|
+
NewRelic::Agent::TracedMethodStack.tl_push_frame('failwhale', Time.now)
|
17
15
|
render :text => 'everything went great'
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
|
-
class BadInstrumentationTest <
|
19
|
+
class BadInstrumentationTest < RailsMultiverseTest
|
22
20
|
include MultiverseHelpers
|
23
21
|
setup_and_teardown_agent
|
24
22
|
|
@@ -2,7 +2,7 @@ common: &default_settings
|
|
2
2
|
license_key: 'bd0e1d52adade840f7ca727d29a86249e89a6f1c'
|
3
3
|
host: 127.0.0.1
|
4
4
|
port: <%= $collector && $collector.port %>
|
5
|
-
app_name: Rails
|
5
|
+
app_name: Rails multiverse test app
|
6
6
|
enabled: true
|
7
7
|
ssl: false
|
8
8
|
apdex_t: 1.0
|
@@ -14,7 +14,6 @@ common: &default_settings
|
|
14
14
|
stack_trace_threshold: 0.500
|
15
15
|
error_collector:
|
16
16
|
enabled: true
|
17
|
-
capture_source: true
|
18
17
|
ignore_errors: NewRelic::TestHelpers::Exceptions::IgnoredError
|
19
18
|
|
20
19
|
development:
|
@@ -0,0 +1 @@
|
|
1
|
+
hello!
|
@@ -8,7 +8,6 @@ require 'fake_collector'
|
|
8
8
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'helpers', 'exceptions'))
|
9
9
|
|
10
10
|
class ErrorController < ApplicationController
|
11
|
-
include Rails.application.routes.url_helpers
|
12
11
|
include NewRelic::TestHelpers::Exceptions
|
13
12
|
|
14
13
|
newrelic_ignore :only => :ignored_action
|
@@ -65,9 +64,13 @@ class ErrorController < ApplicationController
|
|
65
64
|
NewRelic::Agent.add_custom_parameters(:texture => 'chunky')
|
66
65
|
raise 'bad things'
|
67
66
|
end
|
67
|
+
|
68
|
+
if Rails::VERSION::MAJOR == 2
|
69
|
+
filter_parameter_logging(:secret)
|
70
|
+
end
|
68
71
|
end
|
69
72
|
|
70
|
-
class ErrorsWithoutSSCTest <
|
73
|
+
class ErrorsWithoutSSCTest < RailsMultiverseTest
|
71
74
|
extend Multiverse::Color
|
72
75
|
|
73
76
|
include MultiverseHelpers
|
@@ -86,11 +89,34 @@ class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
|
86
89
|
@error_collector.errors.last
|
87
90
|
end
|
88
91
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
92
|
+
if Rails::VERSION::MAJOR >= 3
|
93
|
+
def test_error_collector_should_be_enabled
|
94
|
+
assert NewRelic::Agent.config[:agent_enabled]
|
95
|
+
assert NewRelic::Agent.config[:'error_collector.enabled']
|
96
|
+
assert @error_collector.enabled?
|
97
|
+
assert Rails.application.config.middleware.include?(NewRelic::Rack::ErrorCollector)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_should_capture_routing_error
|
101
|
+
get '/bad_route'
|
102
|
+
assert_error_reported_once('this is an uncaught routing error', nil, nil)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_should_capture_errors_raised_in_middleware_before_call
|
106
|
+
get '/error/middleware_error/before'
|
107
|
+
assert_error_reported_once('middleware error', nil, nil)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_should_capture_errors_raised_in_middleware_after_call
|
111
|
+
get '/error/middleware_error/after'
|
112
|
+
assert_error_reported_once('middleware error', nil, nil)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_should_capture_request_uri_and_params
|
116
|
+
get '/bad_route?eat=static'
|
117
|
+
assert_equal('/bad_route', last_error.params[:request_uri])
|
118
|
+
assert_equal({'eat' => 'static'}, last_error.params[:request_params])
|
119
|
+
end
|
94
120
|
end
|
95
121
|
|
96
122
|
def test_should_capture_error_raised_in_view
|
@@ -146,11 +172,6 @@ class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
|
146
172
|
assert_error_reported_once('this is a noticed error', nil, nil)
|
147
173
|
end
|
148
174
|
|
149
|
-
def test_should_capture_routing_error
|
150
|
-
get '/bad_route'
|
151
|
-
assert_error_reported_once('this is an uncaught routing error', nil, nil)
|
152
|
-
end
|
153
|
-
|
154
175
|
def test_should_apply_parameter_filtering
|
155
176
|
get '/error/controller_error?secret=shouldnotbecaptured&other=whatever'
|
156
177
|
params = last_error.params[:request_params]
|
@@ -165,12 +186,6 @@ class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
|
165
186
|
assert_equal('whatever', params['other'])
|
166
187
|
end
|
167
188
|
|
168
|
-
def test_should_capture_request_uri_and_params
|
169
|
-
get '/bad_route?eat=static'
|
170
|
-
assert_equal('/bad_route', last_error.params[:request_uri])
|
171
|
-
assert_equal({'eat' => 'static'}, last_error.params[:request_params])
|
172
|
-
end
|
173
|
-
|
174
189
|
def test_should_not_notice_errors_from_ignored_action
|
175
190
|
get '/error/ignored_action'
|
176
191
|
assert(@error_collector.errors.empty?,
|
@@ -183,12 +198,23 @@ class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
|
183
198
|
'Noticed an error that should have been ignored')
|
184
199
|
end
|
185
200
|
|
201
|
+
def test_should_treat_apdex_as_success_when_ignored_error_class_noticed
|
202
|
+
get '/error/ignored_error'
|
203
|
+
assert_metrics_recorded({
|
204
|
+
'Apdex' => { :apdex_s => 1, :apdex_t => 0, :apdex_f => 0 },
|
205
|
+
'Apdex/error/ignored_error' => { :apdex_s => 1, :apdex_t => 0, :apdex_f => 0 }
|
206
|
+
})
|
207
|
+
end
|
208
|
+
|
186
209
|
def test_should_not_notice_filtered_errors
|
187
|
-
|
210
|
+
filter = Proc.new do |error|
|
188
211
|
!error.kind_of?(RuntimeError)
|
189
212
|
end
|
190
213
|
|
191
|
-
|
214
|
+
with_ignore_error_filter(filter) do
|
215
|
+
get '/error/controller_error'
|
216
|
+
end
|
217
|
+
|
192
218
|
assert(NewRelic::Agent.instance.error_collector.errors.empty?,
|
193
219
|
'Noticed an error that should have been ignored')
|
194
220
|
end
|
@@ -198,16 +224,6 @@ class ErrorsWithoutSSCTest < ActionDispatch::IntegrationTest
|
|
198
224
|
assert_error_reported_once('this is a server ignored error')
|
199
225
|
end
|
200
226
|
|
201
|
-
def test_should_capture_errors_raised_in_middleware_before_call
|
202
|
-
get '/error/middleware_error/before'
|
203
|
-
assert_error_reported_once('middleware error', nil, nil)
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_should_capture_errors_raised_in_middleware_after_call
|
207
|
-
get '/error/middleware_error/after'
|
208
|
-
assert_error_reported_once('middleware error', nil, nil)
|
209
|
-
end
|
210
|
-
|
211
227
|
# These really shouldn't be skipped for Rails 4, see RUBY-1242
|
212
228
|
if ::Rails::VERSION::MAJOR.to_i < 4
|
213
229
|
def test_captured_errors_should_include_custom_params
|
@@ -261,7 +277,6 @@ class ErrorsWithSSCTest < ErrorsWithoutSSCTest
|
|
261
277
|
"agent_run_id" => 1,
|
262
278
|
"error_collector.ignore_errors" => 'NewRelic::TestHelpers::Exceptions::IgnoredError,NewRelic::TestHelpers::Exceptions::ServerIgnoredError',
|
263
279
|
"error_collector.enabled" => true,
|
264
|
-
"error_collector.capture_source" => true,
|
265
280
|
"collect_errors" => true
|
266
281
|
}, 200)
|
267
282
|
end
|
@@ -9,7 +9,6 @@ if NewRelic::LanguageSupport.ree? ||
|
|
9
9
|
(RUBY_VERSION >= '1.9.2' && !NewRelic::LanguageSupport.jruby?)
|
10
10
|
|
11
11
|
class GcController < ApplicationController
|
12
|
-
include Rails.application.routes.url_helpers
|
13
12
|
def gc_action
|
14
13
|
begin
|
15
14
|
profiler = NewRelic::Agent::StatsEngine::GCProfiler.init
|
@@ -7,8 +7,6 @@
|
|
7
7
|
require './app'
|
8
8
|
|
9
9
|
class IgnoredController < ApplicationController
|
10
|
-
include Rails.application.routes.url_helpers
|
11
|
-
|
12
10
|
newrelic_ignore :only => :action_to_ignore
|
13
11
|
newrelic_ignore_apdex :only => :action_to_ignore_apdex
|
14
12
|
|
@@ -21,7 +19,7 @@ class IgnoredController < ApplicationController
|
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
|
-
class IgnoredActionsTest <
|
22
|
+
class IgnoredActionsTest < RailsMultiverseTest
|
25
23
|
include MultiverseHelpers
|
26
24
|
|
27
25
|
setup_and_teardown_agent(:cross_process_id => "boo",
|
@@ -44,6 +42,14 @@ class IgnoredActionsTest < ActionDispatch::IntegrationTest
|
|
44
42
|
assert_metrics_not_recorded(["Apdex"])
|
45
43
|
end
|
46
44
|
|
45
|
+
def test_ignored_transaction_traces_dont_leak
|
46
|
+
get 'ignored/action_to_ignore'
|
47
|
+
get 'request_stats/stats_action'
|
48
|
+
|
49
|
+
trace = NewRelic::Agent.instance.transaction_sampler.last_sample
|
50
|
+
assert_equal 1, trace.root_segment.called_segments.count
|
51
|
+
end
|
52
|
+
|
47
53
|
def test_should_not_write_cat_response_headers_for_ignored_transactions
|
48
54
|
get 'ignored/action_to_ignore', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
|
49
55
|
assert_nil @response.headers["X-NewRelic-App-Data"]
|
@@ -0,0 +1,41 @@
|
|
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
|
+
# https://newrelic.atlassian.net/browse/RUBY-927
|
6
|
+
|
7
|
+
require './app'
|
8
|
+
|
9
|
+
if Rails::VERSION::MAJOR.to_i >= 3
|
10
|
+
|
11
|
+
class MiddlewareInstrumentationTest < RailsMultiverseTest
|
12
|
+
def test_rails_middleware_records_metrics
|
13
|
+
get('/')
|
14
|
+
assert_metrics_recorded(
|
15
|
+
['Middleware/all', 'Middleware/Rack/Rails::Rack::Logger/call']
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_rails_routeset_is_instrumented
|
20
|
+
get('/')
|
21
|
+
assert_metrics_recorded(
|
22
|
+
'Middleware/Rack/ActionDispatch::Routing::RouteSet/call'
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
if Rails::VERSION::MAJOR >= 4
|
27
|
+
def test_rails_middlewares_constructed_by_name
|
28
|
+
get('/')
|
29
|
+
assert response.headers['NamedMiddleware'], "NamedMiddleware should have been called, but wasn't"
|
30
|
+
assert_metrics_recorded('Middleware/Rack/NamedMiddleware/call')
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_rails_middlewares_passed_as_instances
|
34
|
+
get('/')
|
35
|
+
assert response.headers['InstanceMiddleware'], "InstanceMiddleware should have been called, but wasn't"
|
36
|
+
assert_metrics_recorded('Middleware/Rack/InstanceMiddleware/call')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
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
|
+
# Middlewares (potentially) for use from both Rails 2 and Rails 3+ tests
|
6
|
+
|
7
|
+
class ErrorMiddleware
|
8
|
+
def initialize(app, options={})
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
path = ::Rack::Request.new(env).path_info
|
14
|
+
raise "middleware error" if path.match(/\/middleware_error\/before/)
|
15
|
+
result = @app.call(env)
|
16
|
+
raise "middleware error" if path.match(/\/middleware_error\/after/)
|
17
|
+
result
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,169 @@
|
|
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 './app'
|
6
|
+
|
7
|
+
class ParameterCaptureController < ApplicationController
|
8
|
+
def transaction
|
9
|
+
render :text => 'hi!'
|
10
|
+
end
|
11
|
+
|
12
|
+
def sql
|
13
|
+
NewRelic::Agent.agent.sql_sampler.notice_sql(
|
14
|
+
'SELECT * FROM table',
|
15
|
+
'ActiveRecord/foos/find',
|
16
|
+
{},
|
17
|
+
100.0
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def error
|
22
|
+
raise 'wut'
|
23
|
+
end
|
24
|
+
|
25
|
+
# For Rails 3+, this is configured globally in the config block for the app
|
26
|
+
if Rails::VERSION::MAJOR == 2
|
27
|
+
filter_parameter_logging(:secret)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class ParameterCaptureTest < RailsMultiverseTest
|
32
|
+
def setup
|
33
|
+
NewRelic::Agent.drop_buffered_data
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_no_params_captured_on_errors_when_disabled
|
37
|
+
with_config(:capture_params => false) do
|
38
|
+
get '/parameter_capture/error?other=1234&secret=4567'
|
39
|
+
end
|
40
|
+
assert_nil last_traced_error_request_params
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_no_params_captured_on_tts_when_disabled
|
44
|
+
with_config(:capture_params => false) do
|
45
|
+
get '/parameter_capture/transaction?other=1234&secret=4567'
|
46
|
+
end
|
47
|
+
assert_equal({}, last_transaction_trace_request_params)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_filters_parameters_on_traced_errors
|
51
|
+
with_config(:capture_params => true) do
|
52
|
+
get '/parameter_capture/error?other=1234&secret=4567'
|
53
|
+
end
|
54
|
+
|
55
|
+
captured_params = last_traced_error_request_params
|
56
|
+
assert_equal('[FILTERED]', captured_params['secret'])
|
57
|
+
assert_equal('1234', captured_params['other'])
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_filters_parameters_on_transaction_traces
|
61
|
+
with_config(:capture_params => true) do
|
62
|
+
get '/parameter_capture/transaction?other=1234&secret=4567'
|
63
|
+
end
|
64
|
+
|
65
|
+
captured_params = last_transaction_trace_request_params
|
66
|
+
assert_equal('[FILTERED]', captured_params['secret'])
|
67
|
+
assert_equal('1234', captured_params['other'])
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def test_no_params_captured_when_bails_before_rails
|
72
|
+
with_config(:capture_params => false) do
|
73
|
+
get '/middleware_error/before?other=1234&secret=4567'
|
74
|
+
end
|
75
|
+
assert_nil last_traced_error_request_params
|
76
|
+
assert_equal({}, last_transaction_trace_request_params)
|
77
|
+
end
|
78
|
+
|
79
|
+
if Rails::VERSION::MAJOR.to_i >= 3
|
80
|
+
# NewRelic::Rack::ErrorCollector grabs things out of the request so
|
81
|
+
# we get the actual params even if we never got to a controller
|
82
|
+
def test_sees_error_params_even_when_bailing_before_rails_if_enabled
|
83
|
+
with_config(:capture_params => true) do
|
84
|
+
get '/middleware_error/before?other=1234&secret=4567'
|
85
|
+
end
|
86
|
+
|
87
|
+
captured_params = last_traced_error_request_params
|
88
|
+
assert_equal('[FILTERED]', captured_params['secret'])
|
89
|
+
assert_equal('1234', captured_params['other'])
|
90
|
+
end
|
91
|
+
else
|
92
|
+
def test_sees_error_params_even_when_bailing_before_rails_if_enabled
|
93
|
+
with_config(:capture_params => true) do
|
94
|
+
get '/middleware_error/before?other=1234&secret=4567'
|
95
|
+
end
|
96
|
+
assert_nil last_traced_error_request_params
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_no_params_captured_on_tt_when_bails_before_rails_even_when_enabled
|
101
|
+
with_config(:capture_params => true) do
|
102
|
+
get '/middleware_error/before?other=1234&secret=4567'
|
103
|
+
end
|
104
|
+
|
105
|
+
assert_equal({}, last_transaction_trace_request_params)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_uri_on_tt_should_not_contain_query_string_with_capture_params_off
|
109
|
+
with_config(:capture_params => false) do
|
110
|
+
get '/parameter_capture/transaction?param1=value1¶m2=value2'
|
111
|
+
end
|
112
|
+
assert_equal('/parameter_capture/transaction', last_transaction_trace.params[:uri])
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_uri_on_tt_should_not_contain_query_string_with_capture_params_on
|
116
|
+
with_config(:capture_params => true) do
|
117
|
+
get '/parameter_capture/transaction?param1=value1¶m2=value2'
|
118
|
+
end
|
119
|
+
assert_equal('/parameter_capture/transaction', last_transaction_trace.params[:uri])
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_uri_on_traced_error_should_not_contain_query_string_with_capture_params_off
|
123
|
+
with_config(:capture_params => false) do
|
124
|
+
get '/parameter_capture/error?param1=value1¶m2=value2'
|
125
|
+
end
|
126
|
+
assert_equal('/parameter_capture/error', last_traced_error.params[:request_uri])
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_uri_on_traced_error_should_not_contain_query_string_with_capture_params_on
|
130
|
+
with_config(:capture_params => true) do
|
131
|
+
get '/parameter_capture/error?param1=value1¶m2=value2'
|
132
|
+
end
|
133
|
+
assert_equal('/parameter_capture/error', last_traced_error.params[:request_uri])
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_uri_on_sql_trace_should_not_contain_query_string_with_capture_params_off
|
137
|
+
with_config(:capture_params => false) do
|
138
|
+
get '/parameter_capture/sql?param1=value1¶m2=value2'
|
139
|
+
end
|
140
|
+
assert_equal('/parameter_capture/sql', last_sql_trace.url)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_uri_on_sql_trace_should_not_contain_query_string_with_capture_params_on
|
144
|
+
with_config(:capture_params => true) do
|
145
|
+
get '/parameter_capture/sql?param1=value1¶m2=value2'
|
146
|
+
end
|
147
|
+
assert_equal('/parameter_capture/sql', last_sql_trace.url)
|
148
|
+
end
|
149
|
+
|
150
|
+
def last_traced_error
|
151
|
+
NewRelic::Agent.agent.error_collector.errors.last
|
152
|
+
end
|
153
|
+
|
154
|
+
def last_traced_error_request_params
|
155
|
+
last_traced_error.params[:request_params]
|
156
|
+
end
|
157
|
+
|
158
|
+
def last_transaction_trace
|
159
|
+
NewRelic::Agent.agent.transaction_sampler.last_sample
|
160
|
+
end
|
161
|
+
|
162
|
+
def last_transaction_trace_request_params
|
163
|
+
last_transaction_trace.params[:request_params]
|
164
|
+
end
|
165
|
+
|
166
|
+
def last_sql_trace
|
167
|
+
NewRelic::Agent.agent.sql_sampler.sql_traces.values.last
|
168
|
+
end
|
169
|
+
end
|