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
@@ -0,0 +1,25 @@
|
|
1
|
+
gemfile <<-RB
|
2
|
+
gem 'rack', '~>1.5.0'
|
3
|
+
gem 'rack-test'
|
4
|
+
RB
|
5
|
+
|
6
|
+
gemfile <<-RB
|
7
|
+
gem 'rack', '1.4.5'
|
8
|
+
gem 'rack-test'
|
9
|
+
RB
|
10
|
+
|
11
|
+
gemfile <<-RB
|
12
|
+
gem 'rack', '1.2.8'
|
13
|
+
gem 'rack-test'
|
14
|
+
RB
|
15
|
+
|
16
|
+
gemfile <<-RB
|
17
|
+
gem 'rack', '1.1.0'
|
18
|
+
gem 'rack-test'
|
19
|
+
RB
|
20
|
+
|
21
|
+
# unsupported version
|
22
|
+
gemfile <<-RB
|
23
|
+
gem 'rack', '1.0.1'
|
24
|
+
gem 'rack-test'
|
25
|
+
RB
|
@@ -0,0 +1,50 @@
|
|
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 ExampleApp
|
6
|
+
def call(env)
|
7
|
+
['200', {'Content-Type' => 'text/html', 'ExampleApp' => '0'}, ['A barebones rack app.']]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class MiddlewareOne
|
12
|
+
def initialize(app)
|
13
|
+
@app = app
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
advance_time(1)
|
18
|
+
status, headers, body = @app.call(env)
|
19
|
+
headers['MiddlewareOne'] = '1'
|
20
|
+
|
21
|
+
advance_time(1)
|
22
|
+
[status, headers, body]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class MiddlewareTwo
|
27
|
+
def initialize(app, tag, &blk)
|
28
|
+
@app = app
|
29
|
+
@tag = tag
|
30
|
+
@block = blk
|
31
|
+
end
|
32
|
+
|
33
|
+
def call(env)
|
34
|
+
advance_time(1)
|
35
|
+
request = Rack::Request.new(env)
|
36
|
+
|
37
|
+
if request.params['return-early']
|
38
|
+
status, headers, body = '200', {}, ['Hi']
|
39
|
+
else
|
40
|
+
status, headers, body = @app.call(env)
|
41
|
+
end
|
42
|
+
|
43
|
+
headers['MiddlewareTwo'] = '2'
|
44
|
+
headers['MiddlewareTwoTag'] = @tag
|
45
|
+
|
46
|
+
@block.call(headers)
|
47
|
+
|
48
|
+
[status, headers, body]
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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 'multiverse_helpers'
|
6
|
+
require File.join(File.dirname(__FILE__), 'example_app')
|
7
|
+
|
8
|
+
if NewRelic::Agent::Instrumentation::RackHelpers.rack_version_supported?
|
9
|
+
|
10
|
+
class NestedNonRackAppTest < Minitest::Test
|
11
|
+
include MultiverseHelpers
|
12
|
+
|
13
|
+
setup_and_teardown_agent
|
14
|
+
|
15
|
+
include Rack::Test::Methods
|
16
|
+
|
17
|
+
class ExampleMiddleware
|
18
|
+
def initialize(app)
|
19
|
+
@app = app
|
20
|
+
end
|
21
|
+
|
22
|
+
def call(env)
|
23
|
+
@app.call(env)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class RailsishApp
|
28
|
+
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
29
|
+
|
30
|
+
def call(env)
|
31
|
+
perform_action_with_newrelic_trace(:category => :controller, :name => 'inner') do
|
32
|
+
[200, {}, ['hey']]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def app
|
38
|
+
Rack::Builder.app do
|
39
|
+
use ExampleMiddleware
|
40
|
+
run RailsishApp.new
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_outermost_middleware_contributes_to_middleware_all_if_txn_name_is_non_rack
|
45
|
+
get '/'
|
46
|
+
|
47
|
+
assert_metrics_recorded_exclusive(
|
48
|
+
[
|
49
|
+
"Apdex",
|
50
|
+
"Apdex/NestedNonRackAppTest::RailsishApp/inner",
|
51
|
+
"Controller/NestedNonRackAppTest::RailsishApp/inner",
|
52
|
+
"HttpDispatcher",
|
53
|
+
"Middleware/all",
|
54
|
+
"Middleware/Rack/NestedNonRackAppTest::ExampleMiddleware/call",
|
55
|
+
["Middleware/Rack/NestedNonRackAppTest::ExampleMiddleware/call", "Controller/NestedNonRackAppTest::RailsishApp/inner"],
|
56
|
+
"Nested/Controller/NestedNonRackAppTest::RailsishApp/inner",
|
57
|
+
["Nested/Controller/NestedNonRackAppTest::RailsishApp/inner", "Controller/NestedNonRackAppTest::RailsishApp/inner"],
|
58
|
+
"Nested/Controller/Rack/NestedNonRackAppTest::RailsishApp/call",
|
59
|
+
["Nested/Controller/Rack/NestedNonRackAppTest::RailsishApp/call", "Controller/NestedNonRackAppTest::RailsishApp/inner"]
|
60
|
+
],
|
61
|
+
:ignore_filter => /^Supportability\/EnvironmentReport/
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,143 @@
|
|
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 'multiverse_helpers'
|
6
|
+
require File.join(File.dirname(__FILE__), 'example_app')
|
7
|
+
require 'new_relic/rack/browser_monitoring'
|
8
|
+
require 'new_relic/rack/agent_hooks'
|
9
|
+
require 'new_relic/rack/error_collector'
|
10
|
+
|
11
|
+
if NewRelic::Agent::Instrumentation::RackHelpers.rack_version_supported?
|
12
|
+
|
13
|
+
class RackAutoInstrumentationTest < Minitest::Test
|
14
|
+
include MultiverseHelpers
|
15
|
+
|
16
|
+
setup_and_teardown_agent
|
17
|
+
|
18
|
+
include Rack::Test::Methods
|
19
|
+
|
20
|
+
def app
|
21
|
+
Rack::Builder.app do
|
22
|
+
use MiddlewareOne
|
23
|
+
use MiddlewareTwo, 'the correct tag' do |headers|
|
24
|
+
headers['MiddlewareTwoBlockTag'] = 'the block tag'
|
25
|
+
end
|
26
|
+
use NewRelic::Rack::BrowserMonitoring
|
27
|
+
use NewRelic::Rack::AgentHooks
|
28
|
+
use NewRelic::Rack::ErrorCollector
|
29
|
+
run ExampleApp.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_middleware_gets_used
|
34
|
+
get '/'
|
35
|
+
assert last_response.headers['MiddlewareOne']
|
36
|
+
assert last_response.headers['MiddlewareTwo']
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_status_code_is_preserved
|
40
|
+
get '/'
|
41
|
+
assert_equal 200, last_response.status
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_header_is_preserved
|
45
|
+
get '/'
|
46
|
+
assert last_response.headers['ExampleApp']
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_body_is_preserved
|
50
|
+
get '/'
|
51
|
+
assert_equal 'A barebones rack app.', last_response.body
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_non_agent_middlewares_do_not_record_metrics_if_disabled_by_config
|
55
|
+
with_config(:disable_middleware_instrumentation => true) do
|
56
|
+
get '/'
|
57
|
+
end
|
58
|
+
assert_metrics_recorded_exclusive(
|
59
|
+
[
|
60
|
+
"Apdex",
|
61
|
+
"HttpDispatcher",
|
62
|
+
"Middleware/all",
|
63
|
+
"Apdex/Middleware/Rack/NewRelic::Rack::ErrorCollector/call",
|
64
|
+
"Controller/Middleware/Rack/NewRelic::Rack::ErrorCollector/call",
|
65
|
+
"Middleware/Rack/NewRelic::Rack::ErrorCollector/call",
|
66
|
+
"Middleware/Rack/NewRelic::Rack::BrowserMonitoring/call",
|
67
|
+
"Middleware/Rack/NewRelic::Rack::AgentHooks/call",
|
68
|
+
["Middleware/Rack/NewRelic::Rack::ErrorCollector/call", "Controller/Middleware/Rack/NewRelic::Rack::ErrorCollector/call"],
|
69
|
+
["Middleware/Rack/NewRelic::Rack::BrowserMonitoring/call", "Controller/Middleware/Rack/NewRelic::Rack::ErrorCollector/call"],
|
70
|
+
["Middleware/Rack/NewRelic::Rack::AgentHooks/call", "Controller/Middleware/Rack/NewRelic::Rack::ErrorCollector/call"],
|
71
|
+
],
|
72
|
+
:ignore_filter => /^Supportability\/EnvironmentReport/
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_middlewares_record_metrics
|
77
|
+
NewRelic::Agent.drop_buffered_data
|
78
|
+
get '/'
|
79
|
+
assert_metrics_recorded_exclusive(
|
80
|
+
[
|
81
|
+
"Apdex",
|
82
|
+
"HttpDispatcher",
|
83
|
+
"Middleware/all",
|
84
|
+
"Apdex/Rack/ExampleApp/call",
|
85
|
+
"Controller/Rack/ExampleApp/call",
|
86
|
+
"Middleware/Rack/MiddlewareOne/call",
|
87
|
+
"Middleware/Rack/MiddlewareTwo/call",
|
88
|
+
"Middleware/Rack/NewRelic::Rack::ErrorCollector/call",
|
89
|
+
"Middleware/Rack/NewRelic::Rack::BrowserMonitoring/call",
|
90
|
+
"Middleware/Rack/NewRelic::Rack::AgentHooks/call",
|
91
|
+
"Nested/Controller/Rack/ExampleApp/call",
|
92
|
+
["Middleware/Rack/NewRelic::Rack::ErrorCollector/call", "Controller/Rack/ExampleApp/call"],
|
93
|
+
["Middleware/Rack/NewRelic::Rack::BrowserMonitoring/call", "Controller/Rack/ExampleApp/call"],
|
94
|
+
["Middleware/Rack/NewRelic::Rack::AgentHooks/call", "Controller/Rack/ExampleApp/call"],
|
95
|
+
["Middleware/Rack/MiddlewareOne/call", "Controller/Rack/ExampleApp/call"],
|
96
|
+
["Middleware/Rack/MiddlewareTwo/call", "Controller/Rack/ExampleApp/call"],
|
97
|
+
["Nested/Controller/Rack/ExampleApp/call", "Controller/Rack/ExampleApp/call"]
|
98
|
+
],
|
99
|
+
:ignore_filter => /^Supportability\/EnvironmentReport/
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_middlewares_record_queue_time
|
104
|
+
t0 = freeze_time
|
105
|
+
advance_time(5.0)
|
106
|
+
get '/', {}, { 'HTTP_X_REQUEST_START' => "t=#{t0.to_f}" }
|
107
|
+
|
108
|
+
assert_metrics_recorded(
|
109
|
+
'WebFrontend/QueueTime' => { :total_call_time => 5.0 }
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_middleware_that_returns_early_records_middleware_rollup_metric
|
114
|
+
get '/?return-early=true'
|
115
|
+
assert_metrics_recorded_exclusive([
|
116
|
+
"Apdex",
|
117
|
+
"HttpDispatcher",
|
118
|
+
"Middleware/all",
|
119
|
+
"Apdex/Middleware/Rack/MiddlewareTwo/call",
|
120
|
+
"Controller/Middleware/Rack/MiddlewareTwo/call",
|
121
|
+
"Middleware/Rack/MiddlewareOne/call",
|
122
|
+
"Middleware/Rack/MiddlewareTwo/call",
|
123
|
+
["Middleware/Rack/MiddlewareOne/call", "Controller/Middleware/Rack/MiddlewareTwo/call"],
|
124
|
+
["Middleware/Rack/MiddlewareTwo/call", "Controller/Middleware/Rack/MiddlewareTwo/call"]
|
125
|
+
])
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_middleware_that_returns_early_middleware_all_has_correct_call_times
|
129
|
+
t0 = freeze_time
|
130
|
+
|
131
|
+
get '/?return-early=true'
|
132
|
+
assert_metrics_recorded('Middleware/all' => { :total_exclusive_time => 3.0, :call_count => 2 })
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_middleware_created_with_args_works
|
136
|
+
get '/'
|
137
|
+
|
138
|
+
assert_equal('the correct tag', last_response.headers['MiddlewareTwoTag'])
|
139
|
+
assert_equal('the block tag', last_response.headers['MiddlewareTwoBlockTag'])
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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 'multiverse_helpers'
|
6
|
+
|
7
|
+
if !NewRelic::Agent::Instrumentation::RackHelpers.rack_version_supported?
|
8
|
+
|
9
|
+
class RackUnsupportedVersionTest < Minitest::Test
|
10
|
+
include MultiverseHelpers
|
11
|
+
|
12
|
+
setup_and_teardown_agent
|
13
|
+
|
14
|
+
include Rack::Test::Methods
|
15
|
+
|
16
|
+
class SimpleMiddleware
|
17
|
+
def initialize(app)
|
18
|
+
@app = app
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(env)
|
22
|
+
@app.call(env)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class ExampleApp
|
27
|
+
def call(env)
|
28
|
+
[200, {}, [self.class.name]]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def app
|
33
|
+
Rack::Builder.app do
|
34
|
+
use SimpleMiddleware
|
35
|
+
run ExampleApp.new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_no_instrumentation_when_not_supported
|
40
|
+
get '/'
|
41
|
+
assert_metrics_recorded_exclusive([])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,120 @@
|
|
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 'multiverse_helpers'
|
6
|
+
|
7
|
+
if NewRelic::Agent::Instrumentation::RackHelpers.rack_version_supported?
|
8
|
+
|
9
|
+
class UrlMapTest < Minitest::Test
|
10
|
+
include MultiverseHelpers
|
11
|
+
|
12
|
+
setup_and_teardown_agent
|
13
|
+
|
14
|
+
include Rack::Test::Methods
|
15
|
+
|
16
|
+
class SimpleMiddleware
|
17
|
+
def initialize(app)
|
18
|
+
@app = app
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(env)
|
22
|
+
@app.call(env)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class MiddlewareOne < SimpleMiddleware; end
|
27
|
+
class MiddlewareTwo < SimpleMiddleware; end
|
28
|
+
class MiddlewareThree < SimpleMiddleware; end
|
29
|
+
|
30
|
+
class ExampleApp
|
31
|
+
def call(env)
|
32
|
+
[200, {}, [self.class.name]]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class PrefixAppOne < ExampleApp; end
|
37
|
+
class PrefixAppTwo < ExampleApp; end
|
38
|
+
|
39
|
+
def app
|
40
|
+
Rack::Builder.app do
|
41
|
+
use MiddlewareOne
|
42
|
+
use MiddlewareTwo
|
43
|
+
|
44
|
+
map '/prefix1' do
|
45
|
+
run PrefixAppOne.new
|
46
|
+
end
|
47
|
+
|
48
|
+
map '/prefix2' do
|
49
|
+
use MiddlewareThree
|
50
|
+
run PrefixAppTwo.new
|
51
|
+
end
|
52
|
+
|
53
|
+
# Rack versions prior to 1.4 did not support combining map and run at the
|
54
|
+
# top-level in the same Rack::Builder.
|
55
|
+
if Rack::VERSION[1] >= 4
|
56
|
+
run ExampleApp.new
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if Rack::VERSION[1] >= 4
|
62
|
+
def test_metrics_for_default_prefix
|
63
|
+
get '/'
|
64
|
+
|
65
|
+
assert_metrics_recorded_exclusive([
|
66
|
+
'Apdex',
|
67
|
+
'HttpDispatcher',
|
68
|
+
'Middleware/all',
|
69
|
+
'Controller/Rack/UrlMapTest::ExampleApp/call',
|
70
|
+
'Apdex/Rack/UrlMapTest::ExampleApp/call',
|
71
|
+
'Middleware/Rack/UrlMapTest::MiddlewareOne/call',
|
72
|
+
'Middleware/Rack/UrlMapTest::MiddlewareTwo/call',
|
73
|
+
'Nested/Controller/Rack/UrlMapTest::ExampleApp/call',
|
74
|
+
['Middleware/Rack/UrlMapTest::MiddlewareOne/call', 'Controller/Rack/UrlMapTest::ExampleApp/call'],
|
75
|
+
['Middleware/Rack/UrlMapTest::MiddlewareTwo/call', 'Controller/Rack/UrlMapTest::ExampleApp/call'],
|
76
|
+
['Nested/Controller/Rack/UrlMapTest::ExampleApp/call', 'Controller/Rack/UrlMapTest::ExampleApp/call']
|
77
|
+
])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_metrics_for_mapped_prefix
|
82
|
+
get '/prefix1'
|
83
|
+
|
84
|
+
assert_metrics_recorded_exclusive([
|
85
|
+
'Apdex',
|
86
|
+
'HttpDispatcher',
|
87
|
+
'Middleware/all',
|
88
|
+
'Controller/Rack/UrlMapTest::PrefixAppOne/call',
|
89
|
+
'Apdex/Rack/UrlMapTest::PrefixAppOne/call',
|
90
|
+
'Middleware/Rack/UrlMapTest::MiddlewareOne/call',
|
91
|
+
'Middleware/Rack/UrlMapTest::MiddlewareTwo/call',
|
92
|
+
'Nested/Controller/Rack/UrlMapTest::PrefixAppOne/call',
|
93
|
+
['Middleware/Rack/UrlMapTest::MiddlewareOne/call', 'Controller/Rack/UrlMapTest::PrefixAppOne/call'],
|
94
|
+
['Middleware/Rack/UrlMapTest::MiddlewareTwo/call', 'Controller/Rack/UrlMapTest::PrefixAppOne/call'],
|
95
|
+
['Nested/Controller/Rack/UrlMapTest::PrefixAppOne/call', 'Controller/Rack/UrlMapTest::PrefixAppOne/call']
|
96
|
+
])
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_metrics_for_mapped_prefix_with_extra_middleware
|
100
|
+
get '/prefix2'
|
101
|
+
|
102
|
+
assert_metrics_recorded_exclusive([
|
103
|
+
'Apdex',
|
104
|
+
'HttpDispatcher',
|
105
|
+
'Middleware/all',
|
106
|
+
'Controller/Rack/UrlMapTest::PrefixAppTwo/call',
|
107
|
+
'Apdex/Rack/UrlMapTest::PrefixAppTwo/call',
|
108
|
+
'Middleware/Rack/UrlMapTest::MiddlewareOne/call',
|
109
|
+
'Middleware/Rack/UrlMapTest::MiddlewareTwo/call',
|
110
|
+
'Middleware/Rack/UrlMapTest::MiddlewareThree/call',
|
111
|
+
'Nested/Controller/Rack/UrlMapTest::PrefixAppTwo/call',
|
112
|
+
['Middleware/Rack/UrlMapTest::MiddlewareOne/call', 'Controller/Rack/UrlMapTest::PrefixAppTwo/call'],
|
113
|
+
['Middleware/Rack/UrlMapTest::MiddlewareTwo/call', 'Controller/Rack/UrlMapTest::PrefixAppTwo/call'],
|
114
|
+
['Middleware/Rack/UrlMapTest::MiddlewareThree/call', 'Controller/Rack/UrlMapTest::PrefixAppTwo/call'],
|
115
|
+
['Nested/Controller/Rack/UrlMapTest::PrefixAppTwo/call', 'Controller/Rack/UrlMapTest::PrefixAppTwo/call']
|
116
|
+
])
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|