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
@@ -159,7 +159,7 @@ module HttpClientTestCases
|
|
159
159
|
def test_background
|
160
160
|
res = nil
|
161
161
|
|
162
|
-
perform_action_with_newrelic_trace("task", :category => :task) do
|
162
|
+
perform_action_with_newrelic_trace(:name => "task", :category => :task) do
|
163
163
|
res = get_response
|
164
164
|
end
|
165
165
|
|
@@ -176,7 +176,7 @@ module HttpClientTestCases
|
|
176
176
|
def test_transactional_metrics
|
177
177
|
res = nil
|
178
178
|
|
179
|
-
perform_action_with_newrelic_trace("task") do
|
179
|
+
perform_action_with_newrelic_trace(:name => "task") do
|
180
180
|
res = get_response
|
181
181
|
end
|
182
182
|
|
@@ -193,7 +193,7 @@ module HttpClientTestCases
|
|
193
193
|
|
194
194
|
|
195
195
|
def test_transactional_traces_nodes
|
196
|
-
perform_action_with_newrelic_trace("task") do
|
196
|
+
perform_action_with_newrelic_trace(:name => "task") do
|
197
197
|
res = get_response
|
198
198
|
|
199
199
|
last_segment = find_last_transaction_segment()
|
@@ -231,6 +231,15 @@ module HttpClientTestCases
|
|
231
231
|
assert_externals_recorded_for("localhost", "DELETE")
|
232
232
|
end
|
233
233
|
|
234
|
+
if defined?(::Addressable)
|
235
|
+
def test_url_not_supported_by_stdlib_uri
|
236
|
+
res = get_response("#{protocol}://foo:^password*12@localhost:#{server.port}/status")
|
237
|
+
|
238
|
+
assert_match %r/<head>/i, body(res)
|
239
|
+
assert_externals_recorded_for("localhost", "GET")
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
234
243
|
# When an http call is made, the agent should add a request header named
|
235
244
|
# X-NewRelic-ID with a value equal to the encoded cross_app_id.
|
236
245
|
|
@@ -72,5 +72,10 @@ class JSONWrapperTest < Minitest::Test
|
|
72
72
|
expected = [string.dup.force_encoding('ISO-8859-1').encode('UTF-8')]
|
73
73
|
assert_equal(expected, decoded)
|
74
74
|
end
|
75
|
+
|
76
|
+
def test_normalize_converts_symbols_to_strings
|
77
|
+
result = NewRelic::JSONWrapper.normalize([:foo, :bar])
|
78
|
+
assert_equal(['foo', 'bar'], result)
|
79
|
+
end
|
75
80
|
end
|
76
81
|
end
|
@@ -56,6 +56,13 @@ class NewRelic::LanguageSupportTest < Minitest::Test
|
|
56
56
|
::GC::Profiler.stubs(:enabled?).returns(0)
|
57
57
|
assert_equal true, NewRelic::LanguageSupport.gc_profiler_enabled?
|
58
58
|
end
|
59
|
+
|
60
|
+
def test_gc_profiler_enabled_when_config_is_disabled
|
61
|
+
::GC::Profiler.stubs(:enabled?).returns(true)
|
62
|
+
with_config(:disable_gc_profiler => true) do
|
63
|
+
refute NewRelic::LanguageSupport.gc_profiler_enabled?
|
64
|
+
end
|
65
|
+
end
|
59
66
|
end
|
60
67
|
|
61
68
|
def test_gc_profiler_disabled_on_jruby
|
@@ -73,7 +73,9 @@ class LicenseTest < Minitest::Test
|
|
73
73
|
# skip tags file
|
74
74
|
path =~ %r{/tags$}i ||
|
75
75
|
# skip multiverse auto-generated gemfiles
|
76
|
-
path =~ %r{/test/multiverse/suites/.*/Gemfile\.\d+(\.lock)?$}
|
76
|
+
path =~ %r{/test/multiverse/suites/.*/Gemfile\.\d+(\.lock)?$} ||
|
77
|
+
# skip the artifacts directory
|
78
|
+
path =~ %r{/artifacts/}
|
77
79
|
)
|
78
80
|
end
|
79
81
|
|
@@ -105,10 +107,14 @@ class LicenseTest < Minitest::Test
|
|
105
107
|
files_to_check = all_files.reject { |f| should_skip?(f) }
|
106
108
|
files_to_check.each do |filename|
|
107
109
|
LICENSE_TERMS.each do |key, pattern|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
110
|
+
begin
|
111
|
+
# we're checking this one. We'll update the count of checked files below.
|
112
|
+
occurrences = File.readlines(filename).grep(pattern).size
|
113
|
+
expected = (EXPECTED_LICENSE_OCCURRENCES[[filename.sub(gem_root, ''), key]] || 0)
|
114
|
+
assert_equal expected, occurrences, "#{filename} contains #{key} #{occurrences} times. Should be #{expected}"
|
115
|
+
rescue => e
|
116
|
+
raise "Error when checking file #{filename}: #{e}"
|
117
|
+
end
|
112
118
|
end
|
113
119
|
end
|
114
120
|
# sanity check that we are not skipping all the files.
|
@@ -22,22 +22,4 @@ class NewRelic::LocalEnvironmentTest < Minitest::Test
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
# LocalEnvironment won't talk to ObjectSpace on JRuby, and these tests are
|
27
|
-
# around that interaction, so we don't run them on JRuby.
|
28
|
-
unless defined?(JRuby)
|
29
|
-
def test_mongrel_only_checks_once
|
30
|
-
return unless NewRelic::LanguageSupport.object_space_usable?
|
31
|
-
|
32
|
-
with_constant_defined(:'Mongrel', Module.new) do
|
33
|
-
with_constant_defined(:'Mongrel::HttpServer', Class.new) do
|
34
|
-
ObjectSpace.expects(:each_object).with(::Mongrel::HttpServer).once
|
35
|
-
|
36
|
-
e = NewRelic::LocalEnvironment.new
|
37
|
-
5.times { e.mongrel }
|
38
|
-
assert_nil e.mongrel
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
25
|
end
|
@@ -122,12 +122,12 @@ class NewRelic::MetricDataTest < Minitest::Test
|
|
122
122
|
|
123
123
|
def test_to_s_with_metric_spec
|
124
124
|
md = NewRelic::MetricData.new(NewRelic::MetricSpec.new('Custom/test/method', ''), NewRelic::Agent::Stats.new, 12345)
|
125
|
-
assert_equal('Custom/test/method(): [ 0 calls 0.0000s]', md.to_s, "should not include the metric id and should include the metric spec")
|
125
|
+
assert_equal('Custom/test/method(): [ 0 calls 0.0000s / 0.0000s ex]', md.to_s, "should not include the metric id and should include the metric spec")
|
126
126
|
end
|
127
127
|
|
128
128
|
def test_to_s_without_metric_spec
|
129
129
|
md = NewRelic::MetricData.new(nil, NewRelic::Agent::Stats.new, 12345)
|
130
|
-
assert_equal('12345: [ 0 calls 0.0000s]', md.to_s, "should include the metric id and not have a metric spec")
|
130
|
+
assert_equal('12345: [ 0 calls 0.0000s / 0.0000s ex]', md.to_s, "should include the metric id and not have a metric spec")
|
131
131
|
end
|
132
132
|
|
133
133
|
def test_to_collector_array_with_spec
|
@@ -67,33 +67,14 @@ class NewRelic::MetricSpecTest < Minitest::Test
|
|
67
67
|
puts "Skipping tests in #{__FILE__} because ActiveSupport is unavailable"
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
spec
|
74
|
-
spec.truncate!
|
70
|
+
def test_initialize_truncates_name_and_scope
|
71
|
+
long_name = "a" * 300
|
72
|
+
long_scope = "b" * 300
|
73
|
+
spec = NewRelic::MetricSpec.new(long_name, long_scope)
|
75
74
|
assert_equal("a" * 255, spec.name, "should have shortened the name")
|
76
75
|
assert_equal("b" * 255, spec.scope, "should have shortened the scope")
|
77
76
|
end
|
78
77
|
|
79
|
-
def test_invalid_name_setting_nil
|
80
|
-
NewRelic::Agent.instance.error_collector.errors.clear
|
81
|
-
|
82
|
-
spec = NewRelic::MetricSpec.new
|
83
|
-
spec.scope = nil
|
84
|
-
|
85
|
-
assert_has_error(NewRelic::MetricSpec::InvalidScopeSettingError)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_invalid_name_setting_false
|
89
|
-
NewRelic::Agent.instance.error_collector.errors.clear
|
90
|
-
|
91
|
-
spec = NewRelic::MetricSpec.new
|
92
|
-
spec.scope = false
|
93
|
-
|
94
|
-
assert_has_error(NewRelic::MetricSpec::InvalidScopeSettingError)
|
95
|
-
end
|
96
|
-
|
97
78
|
private
|
98
79
|
|
99
80
|
def compare_spec(spec, import)
|
@@ -60,9 +60,7 @@ module MultiverseHelpers
|
|
60
60
|
NewRelic::Agent.instance.error_collector.instance_variable_set(:@ignore_filter, nil)
|
61
61
|
|
62
62
|
# Clean up any thread-local variables starting with 'newrelic'
|
63
|
-
|
64
|
-
Thread.current[key] = nil
|
65
|
-
end
|
63
|
+
NewRelic::Agent::TransactionState.tl_clear_for_testing
|
66
64
|
|
67
65
|
NewRelic::Agent.instance.transaction_sampler.reset!
|
68
66
|
|
@@ -56,50 +56,34 @@ class NewRelic::Agent::NoticedErrorTest < Minitest::Test
|
|
56
56
|
|
57
57
|
def test_whitelisted_returns_nil_with_an_empty_whitelist
|
58
58
|
with_config(:'strip_exception_messages.whitelist' => '') do
|
59
|
-
|
60
|
-
error = NewRelic::NoticedError.new(@path, @params, e, @time)
|
61
|
-
|
62
|
-
assert_falsy error.whitelisted?
|
59
|
+
assert_falsy NewRelic::NoticedError.passes_message_whitelist(TestError)
|
63
60
|
end
|
64
61
|
end
|
65
62
|
|
66
63
|
def test_whitelisted_returns_nil_when_error_is_not_in_whitelist
|
67
64
|
with_config(:'strip_exception_messages.whitelist' => 'YourErrorIsInAnotherCastle') do
|
68
|
-
|
69
|
-
error = NewRelic::NoticedError.new(@path, @params, e, @time)
|
70
|
-
|
71
|
-
assert_falsy error.whitelisted?
|
65
|
+
assert_falsy NewRelic::NoticedError.passes_message_whitelist(TestError)
|
72
66
|
end
|
73
67
|
end
|
74
68
|
|
75
69
|
def test_whitelisted_is_true_when_error_is_in_whitelist
|
76
70
|
with_config(:'strip_exception_messages.whitelist' => 'OtherException,NewRelic::TestHelpers::Exceptions::TestError') do
|
77
|
-
|
78
|
-
e = test_exception_class.new('whitelisted test exception')
|
79
|
-
error = NewRelic::NoticedError.new(@path, @params, e, @time)
|
80
|
-
|
81
|
-
assert_truthy error.whitelisted?
|
71
|
+
assert_truthy NewRelic::NoticedError.passes_message_whitelist(TestError)
|
82
72
|
end
|
83
73
|
end
|
84
74
|
|
85
75
|
def test_whitelisted_ignores_nonexistent_exception_types_in_whitelist
|
86
76
|
with_config(:'strip_exception_messages.whitelist' => 'NonExistent::Exception,NewRelic::TestHelpers::Exceptions::TestError') do
|
87
|
-
|
88
|
-
e = test_exception_class.new('whitelisted test exception')
|
89
|
-
error = NewRelic::NoticedError.new(@path, @params, e, @time)
|
90
|
-
|
91
|
-
assert_truthy error.whitelisted?
|
77
|
+
assert_truthy NewRelic::NoticedError.passes_message_whitelist(TestError)
|
92
78
|
end
|
93
79
|
end
|
94
80
|
|
95
81
|
def test_whitelisted_is_true_when_an_exceptions_ancestor_is_whitelisted
|
96
82
|
with_config(:'strip_exception_messages.whitelist' => 'NewRelic::TestHelpers::Exceptions::ParentException') do
|
97
|
-
|
98
|
-
error = NewRelic::NoticedError.new(@path, @params, e, @time)
|
99
|
-
|
100
|
-
assert_truthy error.whitelisted?
|
83
|
+
assert_truthy NewRelic::NoticedError.passes_message_whitelist(ChildException)
|
101
84
|
end
|
102
85
|
end
|
86
|
+
|
103
87
|
def test_handles_exception_with_nil_original_exception
|
104
88
|
e = Exception.new('Buffy FOREVER')
|
105
89
|
e.stubs(:original_exception).returns(nil)
|
@@ -14,8 +14,10 @@ class AgentHooksTest < Minitest::Test
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_before_call
|
17
|
+
NewRelic::Agent.instance.events.expects(:notify).with(:start_transaction)
|
17
18
|
NewRelic::Agent.instance.events.expects(:notify).with(:before_call, @env)
|
18
19
|
NewRelic::Agent.instance.events.stubs(:notify).with(:after_call, anything, anything)
|
20
|
+
NewRelic::Agent.instance.events.expects(:notify).with(:transaction_finished, anything)
|
19
21
|
|
20
22
|
@hooks.call(@env)
|
21
23
|
end
|
@@ -24,8 +26,10 @@ class AgentHooksTest < Minitest::Test
|
|
24
26
|
result = stub
|
25
27
|
@app.stubs(:call).returns(result)
|
26
28
|
|
29
|
+
NewRelic::Agent.instance.events.expects(:notify).with(:start_transaction)
|
27
30
|
NewRelic::Agent.instance.events.stubs(:notify).with(:before_call, anything)
|
28
31
|
NewRelic::Agent.instance.events.expects(:notify).with(:after_call, @env, result)
|
32
|
+
NewRelic::Agent.instance.events.expects(:notify).with(:transaction_finished, anything)
|
29
33
|
|
30
34
|
@hooks.call(@env)
|
31
35
|
end
|
@@ -33,7 +37,7 @@ class AgentHooksTest < Minitest::Test
|
|
33
37
|
def test_nested_agent_hooks_still_fire_only_once
|
34
38
|
nested = NewRelic::Rack::AgentHooks.new(@hooks)
|
35
39
|
|
36
|
-
NewRelic::Agent.instance.events.expects(:notify).times(
|
40
|
+
NewRelic::Agent.instance.events.expects(:notify).times(4)
|
37
41
|
nested.call(@env)
|
38
42
|
end
|
39
43
|
|
@@ -0,0 +1,32 @@
|
|
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.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
|
+
require 'new_relic/rack/agent_middleware'
|
7
|
+
require 'new_relic/agent/transaction_state'
|
8
|
+
|
9
|
+
module NewRelic
|
10
|
+
module Rack
|
11
|
+
class AgentMiddlewareTest < Minitest::Test
|
12
|
+
class ExampleMiddleware < AgentMiddleware
|
13
|
+
def traced_call(env)
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :middleware, :env
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@app = lambda { |env| [200, {}, ['yeah!']]}
|
22
|
+
@middleware = ExampleMiddleware.new(@app)
|
23
|
+
@env = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_with_tracing_creates_a_transaction
|
27
|
+
middleware.call(env)
|
28
|
+
assert_metrics_recorded('Controller/Middleware/Rack/NewRelic::Rack::AgentMiddlewareTest::ExampleMiddleware/call')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -30,6 +30,7 @@ class BrowserMonitoringTest < Minitest::Test
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def call(env)
|
33
|
+
advance_time(0.1)
|
33
34
|
@@doc ||= <<-EOL
|
34
35
|
<html>
|
35
36
|
<head>
|
@@ -56,6 +57,8 @@ EOL
|
|
56
57
|
|
57
58
|
def setup
|
58
59
|
super
|
60
|
+
freeze_time
|
61
|
+
|
59
62
|
@config = {
|
60
63
|
:application_id => 5,
|
61
64
|
:beacon => 'beacon',
|
@@ -64,7 +67,7 @@ EOL
|
|
64
67
|
:license_key => 'a' * 40,
|
65
68
|
:js_agent_loader => 'loader',
|
66
69
|
}
|
67
|
-
NewRelic::Agent.config.
|
70
|
+
NewRelic::Agent.config.add_config_for_testing(@config)
|
68
71
|
end
|
69
72
|
|
70
73
|
def teardown
|
@@ -142,6 +145,16 @@ EOL
|
|
142
145
|
assert last_response.ok?
|
143
146
|
end
|
144
147
|
|
148
|
+
def test_with_invalid_us_ascii_encoding
|
149
|
+
response = "<html><body>Jürgen</body></html>"
|
150
|
+
response.force_encoding(Encoding.find("US-ASCII")) if RUBY_VERSION >= '1.9'
|
151
|
+
TestApp.next_response = Rack::Response.new(response)
|
152
|
+
|
153
|
+
get '/'
|
154
|
+
|
155
|
+
assert last_response.ok?
|
156
|
+
end
|
157
|
+
|
145
158
|
def test_should_not_close_if_not_responded_to
|
146
159
|
TestApp.next_response = Rack::Response.new("<html/>")
|
147
160
|
TestApp.next_response.stubs(:respond_to?).with(:close).returns(false)
|
@@ -22,14 +22,6 @@ class DeveloperModeTest < Minitest::Test
|
|
22
22
|
assert_equal 29, trace.size
|
23
23
|
trace = application_stack_trace(Fixtures::WINDOWS_TRACE)
|
24
24
|
assert_equal 14, trace.size
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_url_for_source
|
29
|
-
for line in Fixtures::NORMAL_TRACE + Fixtures::WINDOWS_TRACE do
|
30
|
-
line = url_for_source(line)
|
31
|
-
assert line =~ /^show_source\?file=.*&line=\d+&/, line
|
32
|
-
end
|
33
25
|
end
|
34
26
|
|
35
27
|
private
|
@@ -22,7 +22,7 @@ class DeveloperModeTest < Minitest::Test
|
|
22
22
|
|
23
23
|
def setup
|
24
24
|
@test_config = { :developer_mode => true }
|
25
|
-
NewRelic::Agent.config.
|
25
|
+
NewRelic::Agent.config.add_config_for_testing(@test_config)
|
26
26
|
run_sample_trace('/here')
|
27
27
|
run_sample_trace('/there')
|
28
28
|
run_sample_trace('/somewhere')
|
@@ -13,12 +13,6 @@ module NewRelic::Rack
|
|
13
13
|
|
14
14
|
class TestApp
|
15
15
|
def call(env)
|
16
|
-
if env['PATH_INFO'] == '/ignored'
|
17
|
-
env['action_dispatch.request.parameters'] = {
|
18
|
-
'controller' => 'test_ignore',
|
19
|
-
'action' => 'ignored'
|
20
|
-
}
|
21
|
-
end
|
22
16
|
raise 'unhandled error'
|
23
17
|
end
|
24
18
|
end
|
@@ -35,9 +29,6 @@ module NewRelic::Rack
|
|
35
29
|
|
36
30
|
# sanity checks
|
37
31
|
assert NewRelic::Agent.instance.error_collector.enabled?
|
38
|
-
NewRelic::Agent.instance.error_collector \
|
39
|
-
.instance_variable_set(:@ignore_filter, nil)
|
40
|
-
assert !NewRelic::Agent.instance.error_collector.ignore_error_filter
|
41
32
|
end
|
42
33
|
|
43
34
|
def test_notice_and_reraise_errors
|
@@ -49,37 +40,26 @@ module NewRelic::Rack
|
|
49
40
|
end
|
50
41
|
|
51
42
|
def test_ignore_filtered_errors
|
52
|
-
|
43
|
+
filter = Proc.new do |error|
|
53
44
|
!error.kind_of?(RuntimeError)
|
54
45
|
end
|
55
46
|
|
56
|
-
|
57
|
-
|
47
|
+
with_ignore_error_filter(filter) do
|
48
|
+
assert_raises RuntimeError do
|
49
|
+
get '/'
|
50
|
+
end
|
58
51
|
end
|
59
52
|
|
60
53
|
assert(NewRelic::Agent.instance.error_collector.errors.empty?,
|
61
54
|
'noticed an error that should have been ignored')
|
62
55
|
end
|
63
56
|
|
64
|
-
if defined?(::Rails)
|
65
|
-
def test_ignore_errors_from_ignored_actions
|
66
|
-
assert_raises RuntimeError do
|
67
|
-
get '/ignored'
|
68
|
-
end
|
69
|
-
|
70
|
-
assert(NewRelic::Agent.instance.error_collector.errors.empty?,
|
71
|
-
'noticed an error that should have been ignored')
|
72
|
-
end
|
73
|
-
else
|
74
|
-
puts "Skipping tests in #{__FILE__} because Rails is unavailable"
|
75
|
-
end
|
76
|
-
|
77
57
|
def test_handles_parameter_parsing_exceptions
|
78
58
|
if defined?(ActionDispatch::Request)
|
79
59
|
bad_request = stub.stubs(:filtered_params).raises(TypeError, "can't convert nil into Hash")
|
80
60
|
ActionDispatch::Request.stubs(:new).returns(bad_request)
|
81
61
|
else
|
82
|
-
bad_request = stub(:env => {}, :path => '/', :referer => '')
|
62
|
+
bad_request = stub(:env => {}, :path => '/', :referer => '', :cookies => {})
|
83
63
|
bad_request.stubs(:params).raises(TypeError, "whatever, man")
|
84
64
|
Rack::Request.stubs(:new).returns(bad_request)
|
85
65
|
end
|
@@ -136,7 +116,3 @@ module NewRelic::Rack
|
|
136
116
|
end
|
137
117
|
end
|
138
118
|
end
|
139
|
-
|
140
|
-
class TestIgnoreController
|
141
|
-
@do_not_trace = { :only => :ignored }
|
142
|
-
end
|