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
@@ -6,12 +6,14 @@ gemfile <<-RB
|
|
6
6
|
gem 'json'
|
7
7
|
gem 'sidekiq', '~> 3.0.0'
|
8
8
|
gem 'rack'
|
9
|
+
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
|
9
10
|
RB
|
10
11
|
|
11
12
|
gemfile <<-RB
|
12
13
|
gem 'json'
|
13
14
|
gem 'sidekiq', '~> 2.17.7'
|
14
15
|
gem 'rack'
|
16
|
+
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
|
15
17
|
RB
|
16
18
|
|
17
19
|
gemfile <<-RB
|
@@ -19,5 +21,7 @@ gemfile <<-RB
|
|
19
21
|
# Having rbx issues on 2.8.0, 2.9.0 seems fine.
|
20
22
|
gem 'json'
|
21
23
|
gem 'sidekiq', '~> 2.9.0'
|
24
|
+
gem 'timers', '~> 1.1.0'
|
22
25
|
gem 'rack'
|
26
|
+
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
|
23
27
|
RB
|
@@ -4,63 +4,82 @@
|
|
4
4
|
|
5
5
|
# https://newrelic.atlassian.net/browse/RUBY-775
|
6
6
|
|
7
|
-
require
|
8
|
-
|
7
|
+
require File.join(File.dirname(__FILE__), "sidekiq_server")
|
8
|
+
SidekiqServer.instance.run
|
9
|
+
|
10
|
+
# Important to require after Sidekiq server starts for middleware to install
|
9
11
|
require 'newrelic_rpm'
|
12
|
+
|
13
|
+
require 'logger'
|
14
|
+
require 'stringio'
|
15
|
+
|
10
16
|
require 'fake_collector'
|
11
17
|
require 'multiverse_helpers'
|
18
|
+
require File.join(File.dirname(__FILE__), "test_worker")
|
12
19
|
require File.join(File.dirname(__FILE__), "..", "..", "..", "agent_helper")
|
13
20
|
|
14
21
|
class SidekiqTest < Minitest::Test
|
15
22
|
JOB_COUNT = 5
|
16
|
-
TRANSACTION_NAME = 'OtherTransaction/SidekiqJob/SidekiqTest::TestWorker/perform'
|
17
|
-
|
18
|
-
include MultiverseHelpers
|
19
23
|
|
20
|
-
|
24
|
+
ROLLUP_METRIC = 'OtherTransaction/SidekiqJob/all'
|
25
|
+
TRANSACTION_NAME = 'OtherTransaction/SidekiqJob/TestWorker/perform'
|
26
|
+
DELAYED_TRANSACTION_NAME = 'OtherTransaction/SidekiqJob/TestWorker/record'
|
27
|
+
DELAYED_FAILED_TXN_NAME = 'OtherTransaction/SidekiqJob/Sidekiq::Extensions::DelayedClass/perform'
|
21
28
|
|
22
|
-
|
23
|
-
include Sidekiq::Worker
|
24
|
-
|
25
|
-
@jobs = {}
|
29
|
+
include MultiverseHelpers
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
setup_and_teardown_agent do
|
32
|
+
TestWorker.register_signal('jobs_completed')
|
33
|
+
@sidekiq_log = ::StringIO.new
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
string_logger = ::Logger.new(@sidekiq_log)
|
36
|
+
string_logger.formatter = Sidekiq.logger.formatter
|
37
|
+
Sidekiq.logger = string_logger
|
38
|
+
end
|
35
39
|
|
36
|
-
|
37
|
-
|
40
|
+
def teardown
|
41
|
+
teardown_agent
|
42
|
+
if !passed? || ENV["VERBOSE"]
|
43
|
+
@sidekiq_log.rewind
|
44
|
+
puts @sidekiq_log.read
|
38
45
|
end
|
46
|
+
end
|
39
47
|
|
40
|
-
|
41
|
-
|
48
|
+
def run_jobs
|
49
|
+
run_and_transmit do |i|
|
50
|
+
TestWorker.perform_async('jobs_completed', i + 1)
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
config.client_middleware do |chain|
|
49
|
-
chain.add NewRelic::SidekiqInstrumentation
|
54
|
+
def run_delayed
|
55
|
+
run_and_transmit do |i|
|
56
|
+
TestWorker.delay(:queue => SidekiqServer.instance.queue_name).record('jobs_completed', i + 1)
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
53
|
-
def
|
60
|
+
def run_and_transmit
|
54
61
|
with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
|
55
|
-
TestWorker.
|
56
|
-
|
57
|
-
TestWorker.perform_async('jobs_completed', i + 1)
|
62
|
+
TestWorker.run_jobs(JOB_COUNT) do |i|
|
63
|
+
yield i
|
58
64
|
end
|
59
65
|
end
|
60
66
|
|
61
67
|
NewRelic::Agent.instance.send(:transmit_data)
|
62
68
|
end
|
63
69
|
|
70
|
+
def test_delayed
|
71
|
+
run_delayed
|
72
|
+
assert_metric_and_call_count(ROLLUP_METRIC, JOB_COUNT)
|
73
|
+
assert_metric_and_call_count(DELAYED_TRANSACTION_NAME, JOB_COUNT)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_delayed_with_malformed_yaml
|
77
|
+
YAML.stubs(:load).raises(RuntimeError.new("Ouch"))
|
78
|
+
run_delayed
|
79
|
+
assert_metric_and_call_count(ROLLUP_METRIC, JOB_COUNT)
|
80
|
+
assert_metric_and_call_count(DELAYED_FAILED_TXN_NAME, JOB_COUNT)
|
81
|
+
end
|
82
|
+
|
64
83
|
def test_all_jobs_ran
|
65
84
|
run_jobs
|
66
85
|
completed_jobs = Set.new(TestWorker.records_for('jobs_completed').map(&:to_i))
|
@@ -70,7 +89,8 @@ class SidekiqTest < Minitest::Test
|
|
70
89
|
|
71
90
|
def test_agent_posts_correct_metric_data
|
72
91
|
run_jobs
|
73
|
-
assert_metric_and_call_count(
|
92
|
+
assert_metric_and_call_count(ROLLUP_METRIC, JOB_COUNT)
|
93
|
+
assert_metric_and_call_count(TRANSACTION_NAME, JOB_COUNT)
|
74
94
|
end
|
75
95
|
|
76
96
|
def test_doesnt_capture_args_by_default
|
@@ -91,7 +111,7 @@ class SidekiqTest < Minitest::Test
|
|
91
111
|
end
|
92
112
|
|
93
113
|
transaction_samples = $collector.calls_for('transaction_sample_data')
|
94
|
-
|
114
|
+
refute transaction_samples.empty?, "Expected a transaction trace"
|
95
115
|
|
96
116
|
transaction_samples.each do |post|
|
97
117
|
post.samples.each do |sample|
|
@@ -109,7 +129,8 @@ class SidekiqTest < Minitest::Test
|
|
109
129
|
assert_equal(1, metric_data.size, "expected exactly one metric_data post from agent")
|
110
130
|
|
111
131
|
metric = metric_data.first.metrics.find { |m| m[0]['name'] == name }
|
112
|
-
assert(metric, "
|
132
|
+
assert(metric, "Could not find metric named #{name}. Did have metrics:\n"+
|
133
|
+
metric_data.first.metrics.map{|m| m[0]['name']}.join("\t\n"))
|
113
134
|
|
114
135
|
call_count = metric[1][0]
|
115
136
|
assert_equal(expected_call_count, call_count)
|
@@ -117,7 +138,7 @@ class SidekiqTest < Minitest::Test
|
|
117
138
|
|
118
139
|
def assert_no_params_on_jobs
|
119
140
|
transaction_samples = $collector.calls_for('transaction_sample_data')
|
120
|
-
|
141
|
+
refute transaction_samples.empty?, "Didn't find any transaction samples!"
|
121
142
|
|
122
143
|
transaction_samples.each do |post|
|
123
144
|
post.samples.each do |sample|
|
@@ -0,0 +1,30 @@
|
|
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 'sidekiq'
|
6
|
+
require 'sidekiq/cli'
|
7
|
+
|
8
|
+
class SidekiqServer
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
attr_reader :queue_name
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@queue_name = "sidekiq#{Process.pid}"
|
15
|
+
@sidekiq = Sidekiq::CLI.instance
|
16
|
+
end
|
17
|
+
|
18
|
+
def run(file="test_worker.rb")
|
19
|
+
@sidekiq.parse(["--require", File.join(File.dirname(__FILE__), file),
|
20
|
+
"--queue", "#{queue_name},1"])
|
21
|
+
Thread.new { @sidekiq.run }
|
22
|
+
end
|
23
|
+
|
24
|
+
# If we just let the process go away, occasional timing issues cause the
|
25
|
+
# Launcher actor in Sidekiq to throw a fuss and exit with a failed code.
|
26
|
+
def stop
|
27
|
+
puts "Trying to stop Sidekiq gracefully"
|
28
|
+
@sidekiq.launcher.stop
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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 TestWorker
|
6
|
+
include Sidekiq::Worker
|
7
|
+
|
8
|
+
sidekiq_options :queue => SidekiqServer.instance.queue_name
|
9
|
+
|
10
|
+
@jobs = {}
|
11
|
+
@jobs_mutex = Mutex.new
|
12
|
+
|
13
|
+
@done = Queue.new
|
14
|
+
|
15
|
+
def self.register_signal(key)
|
16
|
+
return if @registered_signal
|
17
|
+
|
18
|
+
NewRelic::Agent.subscribe(:transaction_finished) do |payload|
|
19
|
+
@done.push(true)
|
20
|
+
end
|
21
|
+
@registered_signal = true
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.run_jobs(count)
|
25
|
+
reset(count)
|
26
|
+
count.times do |i|
|
27
|
+
yield i
|
28
|
+
end
|
29
|
+
wait
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.reset(done_at)
|
33
|
+
@jobs = {}
|
34
|
+
@done_at = done_at
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.record(key, val)
|
38
|
+
@jobs_mutex.synchronize do
|
39
|
+
@jobs[key] ||= []
|
40
|
+
@jobs[key] << val
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.records_for(key)
|
45
|
+
@jobs[key]
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.wait
|
49
|
+
# Don't hang out forever, but shouldn't count on the timeout functionally
|
50
|
+
Timeout.timeout(60) do
|
51
|
+
@done_at.times do
|
52
|
+
@done.pop
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def perform(key, val)
|
58
|
+
TestWorker.record(key, val)
|
59
|
+
end
|
60
|
+
end
|
@@ -32,8 +32,14 @@ class SinatraIgnoreTestApp < Sinatra::Base
|
|
32
32
|
get '/no_apdex' do request.path_info end
|
33
33
|
|
34
34
|
newrelic_ignore_enduser '/no_enduser'
|
35
|
-
get '/no_enduser' do request.path_info end
|
36
35
|
|
36
|
+
get '/enduser' do
|
37
|
+
"<html><head></head><body>#{request.path_info}</body></html>"
|
38
|
+
end
|
39
|
+
|
40
|
+
get '/no_enduser' do
|
41
|
+
"<html><head></head><body>#{request.path_info}</body></html>"
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
45
|
class SinatraTestCase < Minitest::Test
|
@@ -41,12 +47,25 @@ class SinatraTestCase < Minitest::Test
|
|
41
47
|
include ::NewRelic::Agent::Instrumentation::Sinatra
|
42
48
|
include MultiverseHelpers
|
43
49
|
|
44
|
-
|
50
|
+
JS_AGENT_LOADER = "JS_AGENT_LOADER"
|
51
|
+
|
52
|
+
setup_and_teardown_agent(:application_id => 'appId',
|
53
|
+
:beacon => 'beacon',
|
54
|
+
:browser_key => 'browserKey',
|
55
|
+
:js_agent_loader => JS_AGENT_LOADER)
|
45
56
|
|
46
57
|
def get_and_assert_ok(path)
|
47
58
|
get(path)
|
48
59
|
assert_equal 200, last_response.status
|
49
|
-
|
60
|
+
assert_match(/#{Regexp.escape(path)}/, last_response.body)
|
61
|
+
end
|
62
|
+
|
63
|
+
def assert_enduser_ignored(response)
|
64
|
+
refute_match(/#{JS_AGENT_LOADER}/, response.body)
|
65
|
+
end
|
66
|
+
|
67
|
+
def refute_enduser_ignored(response)
|
68
|
+
assert_match(/#{JS_AGENT_LOADER}/, response.body)
|
50
69
|
end
|
51
70
|
|
52
71
|
# Keep Test::Unit happy by specifying at least one test method here
|
@@ -63,12 +82,6 @@ class SinatraIgnoreTest < SinatraTestCase
|
|
63
82
|
app.to_s
|
64
83
|
end
|
65
84
|
|
66
|
-
def get_and_assert_ok(path)
|
67
|
-
get(path)
|
68
|
-
assert_equal 200, last_response.status
|
69
|
-
assert_equal path, last_response.body
|
70
|
-
end
|
71
|
-
|
72
85
|
def test_seen_route
|
73
86
|
get_and_assert_ok '/record'
|
74
87
|
assert_metrics_recorded([
|
@@ -126,10 +139,19 @@ class SinatraIgnoreTest < SinatraTestCase
|
|
126
139
|
assert_metrics_not_recorded(["Apdex/Sinatra/#{app_name}/GET no_apdex"])
|
127
140
|
end
|
128
141
|
|
142
|
+
def test_ignore_enduser_should_only_apply_to_specified_route
|
143
|
+
get_and_assert_ok '/enduser'
|
144
|
+
|
145
|
+
refute_enduser_ignored(last_response)
|
146
|
+
assert_metrics_recorded([
|
147
|
+
"Controller/Sinatra/#{app_name}/GET enduser",
|
148
|
+
"Apdex/Sinatra/#{app_name}/GET enduser"])
|
149
|
+
end
|
150
|
+
|
129
151
|
def test_ignore_enduser
|
130
152
|
get_and_assert_ok '/no_enduser'
|
131
153
|
|
132
|
-
|
154
|
+
assert_enduser_ignored(last_response)
|
133
155
|
assert_metrics_recorded([
|
134
156
|
"Controller/Sinatra/#{app_name}/GET no_enduser",
|
135
157
|
"Apdex/Sinatra/#{app_name}/GET no_enduser"])
|
@@ -183,6 +205,6 @@ class SinatraIgnoreApdexAndEndUserTest < SinatraTestCase
|
|
183
205
|
|
184
206
|
def test_ignores_enduser
|
185
207
|
get_and_assert_ok '/'
|
186
|
-
|
208
|
+
assert_enduser_ignored(last_response)
|
187
209
|
end
|
188
210
|
end
|
@@ -73,7 +73,9 @@ class SinatraMetricExplosionTest < Minitest::Test
|
|
73
73
|
|
74
74
|
name_beginnings_to_ignore = [
|
75
75
|
"Supportability",
|
76
|
-
"GC/Transaction"
|
76
|
+
"GC/Transaction",
|
77
|
+
"Nested/Controller",
|
78
|
+
"Middleware"
|
77
79
|
]
|
78
80
|
metric_names.delete_if do|metric|
|
79
81
|
name_beginnings_to_ignore.any? {|name| metric.start_with?(name)}
|
@@ -9,6 +9,15 @@ suite_condition("Typhoeus not supported in 1.8.6 and excluded on 1.8.7 non-REE")
|
|
9
9
|
(RUBY_VERSION != '1.8.7' || RUBY_DESCRIPTION =~ /Enterprise/)
|
10
10
|
end
|
11
11
|
|
12
|
+
gemfile <<-RB
|
13
|
+
gem 'typhoeus', '~> 0.6.5'
|
14
|
+
gem 'rack'
|
15
|
+
gem 'json', :platforms => [:rbx, :mri_18]
|
16
|
+
|
17
|
+
# We try translating URIs through Addressable if it's there, so test with it.
|
18
|
+
gem 'addressable', :require => 'addressable/uri'
|
19
|
+
RB
|
20
|
+
|
12
21
|
gemfile <<-RB
|
13
22
|
gem 'typhoeus', '~> 0.6.5'
|
14
23
|
gem 'rack'
|
@@ -103,6 +103,16 @@ if NewRelic::Agent::Instrumentation::TyphoeusTracing.is_supported_version?
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
+
def test_request_succeeds_even_if_tracing_doesnt
|
107
|
+
in_transaction("test") do
|
108
|
+
::NewRelic::Agent::CrossAppTracing.stubs(:start_trace).raises("Booom")
|
109
|
+
res = get_response
|
110
|
+
|
111
|
+
assert_match %r/<head>/i, body(res)
|
112
|
+
assert_metrics_not_recorded(["External/all"])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
106
116
|
def test_hydra
|
107
117
|
in_transaction("test") do
|
108
118
|
hydra = Typhoeus::Hydra.new
|