newrelic_rpm 3.6.5.130 → 3.6.6.147
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +27 -3
- data/Gemfile +1 -14
- data/Rakefile +15 -5
- data/config.dot +1 -1
- data/lib/new_relic/agent/agent.rb +15 -0
- data/lib/new_relic/agent/agent_logger.rb +19 -14
- data/lib/new_relic/agent/configuration/defaults.rb +4 -3
- data/lib/new_relic/agent/configuration/environment_source.rb +6 -4
- data/lib/new_relic/agent/configuration/manager.rb +7 -2
- data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -2
- data/lib/new_relic/agent/cross_app_monitor.rb +5 -4
- data/lib/new_relic/agent/cross_app_tracing.rb +0 -1
- data/lib/new_relic/agent/error_collector.rb +30 -1
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +67 -0
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +59 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +12 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +3 -3
- data/lib/new_relic/agent/instrumentation/authlogic.rb +3 -3
- data/lib/new_relic/agent/instrumentation/curb.rb +179 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +3 -3
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +35 -26
- data/lib/new_relic/agent/instrumentation/httpclient.rb +46 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +3 -3
- data/lib/new_relic/agent/instrumentation/puma.rb +23 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +40 -0
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sequel.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +18 -0
- data/lib/new_relic/agent/new_relic_service.rb +2 -8
- data/lib/new_relic/agent/request_sampler.rb +4 -6
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +0 -1
- data/lib/new_relic/agent/stats.rb +9 -0
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +44 -6
- data/lib/new_relic/agent/system_info.rb +1 -1
- data/lib/new_relic/agent/thread_profiler.rb +6 -6
- data/lib/new_relic/agent/transaction.rb +1 -1
- data/lib/new_relic/agent/transaction_info.rb +0 -1
- data/lib/new_relic/agent/transaction_sample_builder.rb +6 -5
- data/lib/new_relic/agent/transaction_sampler.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +6 -0
- data/lib/new_relic/commands/install.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +1 -2
- data/lib/new_relic/control/instrumentation.rb +2 -2
- data/lib/new_relic/control/server_methods.rb +1 -2
- data/lib/new_relic/delayed_job_injection.rb +0 -40
- data/lib/new_relic/helper.rb +0 -1
- data/lib/new_relic/latest_changes.rb +1 -1
- data/lib/new_relic/local_environment.rb +9 -4
- data/lib/new_relic/metric_spec.rb +19 -3
- data/lib/new_relic/noticed_error.rb +2 -1
- data/lib/new_relic/rack/agent_hooks.rb +0 -1
- data/lib/new_relic/rack/developer_mode.rb +1 -1
- data/lib/new_relic/rack/error_collector.rb +42 -21
- data/lib/new_relic/recipes.rb +0 -1
- data/lib/new_relic/transaction_analysis.rb +0 -1
- data/lib/new_relic/transaction_sample/segment.rb +4 -4
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +6 -7
- data/lib/sequel/plugins/newrelic_instrumentation.rb +0 -1
- data/lib/tasks/install.rake +2 -2
- data/newrelic_rpm.gemspec +11 -1
- data/test/active_record_fixtures.rb +2 -2
- data/test/agent_helper.rb +46 -3
- data/test/config/newrelic.yml +2 -2
- data/test/multiverse/.gitignore +2 -0
- data/test/multiverse/lib/multiverse/envfile.rb +6 -9
- data/test/multiverse/lib/multiverse/environment.rb +0 -1
- data/test/multiverse/lib/multiverse/output_collector.rb +43 -11
- data/test/multiverse/lib/multiverse/runner.rb +37 -5
- data/test/multiverse/lib/multiverse/suite.rb +149 -67
- data/test/multiverse/script/run_one +4 -2
- data/test/multiverse/script/runner +1 -5
- data/test/multiverse/suites/active_record/Envfile +3 -2
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +13 -12
- data/test/multiverse/suites/active_record/config/newrelic.yml +0 -3
- data/test/multiverse/suites/agent_only/audit_log_test.rb +30 -34
- data/test/multiverse/suites/agent_only/before_suite.rb +7 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +1 -7
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +12 -20
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +16 -34
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +18 -28
- data/test/multiverse/suites/agent_only/logging_test.rb +25 -49
- data/test/multiverse/suites/agent_only/marshaling_test.rb +30 -38
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +12 -6
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +30 -38
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +16 -18
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +6 -7
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +26 -32
- data/test/multiverse/suites/agent_only/ssl_test.rb +10 -14
- data/test/multiverse/suites/agent_only/start_up_test.rb +1 -1
- data/test/multiverse/suites/agent_only/testing_app.rb +2 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +23 -24
- data/test/multiverse/suites/config_file_loading/Envfile +6 -2
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +8 -4
- data/test/multiverse/suites/curb/Envfile +19 -0
- data/test/multiverse/suites/curb/config/newrelic.yml +19 -0
- data/test/multiverse/suites/curb/curb_test.rb +195 -0
- data/test/multiverse/suites/datamapper/Envfile +2 -0
- data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -2
- data/test/multiverse/suites/datamapper/datamapper_test.rb +6 -10
- data/test/multiverse/suites/deferred_instrumentation/Envfile +19 -0
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +22 -0
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +103 -0
- data/test/multiverse/suites/excon/config/newrelic.yml +0 -2
- data/test/multiverse/suites/excon/excon_test.rb +3 -3
- data/test/multiverse/suites/httpclient/Envfile +15 -0
- data/test/multiverse/suites/httpclient/config/newrelic.yml +19 -0
- data/test/multiverse/suites/httpclient/httpclient_test.rb +70 -0
- data/test/multiverse/suites/net_http/config/newrelic.yml +0 -2
- data/test/multiverse/suites/net_http/net_http_test.rb +9 -4
- data/test/multiverse/suites/padrino/Envfile +2 -0
- data/test/multiverse/suites/padrino/config/newrelic.yml +0 -3
- data/test/multiverse/suites/padrino/padrino_test.rb +5 -4
- data/test/multiverse/suites/rails/Envfile +3 -0
- data/test/multiverse/suites/rails/app.rb +1 -0
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +31 -0
- data/test/multiverse/suites/rails/config/newrelic.yml +2 -3
- data/test/multiverse/suites/rails/error_tracing_test.rb +32 -41
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +6 -16
- data/test/multiverse/suites/rails/queue_time_test.rb +4 -20
- data/test/multiverse/suites/rails/request_statistics_test.rb +7 -32
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +6 -10
- data/test/multiverse/suites/resque/config/newrelic.yml +1 -3
- data/test/multiverse/suites/resque/instrumentation_test.rb +10 -7
- data/test/multiverse/suites/sequel/Envfile +8 -0
- data/test/multiverse/suites/sequel/config/newrelic.yml +0 -3
- data/test/multiverse/suites/sequel/sequel_test.rb +1 -2
- data/test/multiverse/suites/sidekiq/Envfile +0 -12
- data/test/multiverse/suites/sidekiq/config/newrelic.yml +1 -3
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +44 -100
- data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -3
- data/test/multiverse/suites/sinatra/ignoring_test.rb +8 -5
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +8 -1
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +9 -12
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +9 -8
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +6 -5
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +10 -13
- data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +7 -4
- data/test/multiverse/test/suite_examples/one/a/a_test.rb +0 -1
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/b/b_test.rb +0 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
- data/test/new_relic/agent/agent/connect_test.rb +1 -1
- data/test/new_relic/agent/agent/start_test.rb +0 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +0 -1
- data/test/new_relic/agent/agent_logger_test.rb +37 -3
- data/test/new_relic/agent/agent_test.rb +23 -1
- data/test/new_relic/agent/browser_monitoring_test.rb +0 -1
- data/test/new_relic/agent/busy_calculator_test.rb +2 -2
- data/test/new_relic/agent/configuration/environment_source_test.rb +22 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
- data/test/new_relic/agent/error_collector_test.rb +95 -13
- data/test/new_relic/agent/event_listener_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +23 -0
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +4 -2
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +16 -11
- data/test/new_relic/agent/instrumentation/rack_test.rb +0 -1
- data/test/new_relic/agent/memcache_instrumentation_test.rb +7 -7
- data/test/{multiverse/suites/agent_only/test_trace_method_with_punctuation.rb → new_relic/agent/method_interrobang_test.rb} +3 -5
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -2
- data/test/{multiverse/suites/agent_only → new_relic/agent}/method_visibility_test.rb +17 -29
- data/test/new_relic/agent/new_relic_service_test.rb +1 -1
- data/test/new_relic/agent/pipe_service_test.rb +1 -1
- data/test/new_relic/agent/request_sampler_test.rb +10 -10
- data/test/new_relic/agent/rpm_agent_test.rb +1 -2
- data/test/new_relic/agent/stats_hash_test.rb +83 -5
- data/test/new_relic/agent/stats_test.rb +0 -1
- data/test/new_relic/agent/thread_profiler_test.rb +7 -7
- data/test/new_relic/agent/threaded_test.rb +1 -2
- data/test/new_relic/agent/transaction/pop_test.rb +0 -1
- data/test/{multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb → new_relic/agent/transaction_interrobang_test.rb} +2 -4
- data/test/new_relic/agent/transaction_sample_builder_test.rb +13 -0
- data/test/new_relic/agent/transaction_test.rb +7 -5
- data/test/new_relic/agent/worker_loop_test.rb +0 -1
- data/test/new_relic/agent_test.rb +0 -27
- data/test/new_relic/collection_helper_test.rb +17 -17
- data/test/new_relic/control/class_methods_test.rb +1 -1
- data/test/new_relic/control_test.rb +6 -6
- data/test/new_relic/dependency_detection_test.rb +28 -0
- data/test/new_relic/evil_server.rb +0 -1
- data/test/new_relic/fake_collector.rb +20 -2
- data/test/new_relic/fake_server.rb +0 -12
- data/test/new_relic/http_client_test_cases.rb +20 -24
- data/test/new_relic/metric_spec_test.rb +18 -0
- data/test/new_relic/multiverse_helpers.rb +164 -0
- data/test/new_relic/rack/agent_hooks_test.rb +0 -1
- data/test/new_relic/rack/all_test.rb +0 -1
- data/test/new_relic/rack/deferred_instrumentation_test.rb +35 -0
- data/test/new_relic/rack/developer_mode_helper_test.rb +8 -9
- data/test/new_relic/rack/developer_mode_test.rb +0 -2
- data/test/new_relic/rack/error_collector_test.rb +52 -8
- data/test/new_relic/transaction_sample/composite_segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/fake_segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/summary_segment_test.rb +0 -1
- data/test/performance/README.md +162 -0
- data/test/performance/lib/performance.rb +28 -0
- data/test/performance/lib/performance/console_reporter.rb +51 -0
- data/test/performance/lib/performance/hako_client.rb +31 -0
- data/test/performance/lib/performance/hako_reporter.rb +26 -0
- data/test/performance/lib/performance/instrumentation/cpu_usage.rb +26 -0
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +53 -0
- data/test/performance/lib/performance/instrumentation/perf_tools.rb +30 -0
- data/test/performance/lib/performance/instrumentor.rb +110 -0
- data/test/performance/lib/performance/json_reporter.rb +15 -0
- data/test/performance/lib/performance/result.rb +80 -0
- data/test/performance/lib/performance/runner.rb +207 -0
- data/test/performance/lib/performance/test_case.rb +65 -0
- data/test/performance/lib/performance/timer.rb +38 -0
- data/test/performance/script/mega-runner +37 -0
- data/test/performance/script/runner +81 -0
- data/test/performance/suites/startup.rb +12 -0
- data/test/performance/suites/transaction_tracing.rb +66 -0
- data/test/script/ci_agent-tests_runner.sh +4 -4
- data/test/script/ci_multiverse_runner.sh +3 -3
- data/test/test_helper.rb +0 -11
- data/ui/helpers/developer_mode_helper.rb +1 -1
- data/ui/views/layouts/newrelic_default.rhtml +1 -1
- data/ui/views/newrelic/_segment.rhtml +2 -2
- data/ui/views/newrelic/_segment_limit_message.rhtml +1 -1
- data/ui/views/newrelic/_show_sample_detail.rhtml +1 -1
- data/ui/views/newrelic/_show_sample_sql.rhtml +4 -4
- data/ui/views/newrelic/_stack_trace.rhtml +2 -2
- data/ui/views/newrelic/file/javascript/transaction_sample.js +3 -3
- data/ui/views/newrelic/file/stylesheets/style.css +13 -13
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +18 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +0 -1
- metadata +186 -17
- metadata.gz.sig +0 -0
- data/test/multiverse/suites/active_record/encoding_test.rb +0 -30
- data/test/multiverse/suites/agent_only/no_dns_resolv.rb +0 -21
- data/test/multiverse/suites/sidekiq/app.rb +0 -25
- data/test/new_relic/delayed_job_injection_test.rb +0 -25
@@ -32,3 +32,11 @@ gemfile <<-RB
|
|
32
32
|
RB
|
33
33
|
|
34
34
|
|
35
|
+
gemfile <<-RB
|
36
|
+
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
|
37
|
+
gem 'jdbc-sqlite3', '3.7.2', :platform => :jruby
|
38
|
+
gem 'sqlite3', '1.3.7', :platform => :ruby
|
39
|
+
gem 'sequel', '4.0.0'
|
40
|
+
RB
|
41
|
+
|
42
|
+
|
@@ -11,12 +11,9 @@ development:
|
|
11
11
|
app_name: test
|
12
12
|
host: 127.0.0.1
|
13
13
|
api_host: 127.0.0.1
|
14
|
-
port: <%= 30_000 + ($$ % 10_000) %>
|
15
14
|
transaction_tracer:
|
16
15
|
record_sql: obfuscated
|
17
16
|
enabled: true
|
18
17
|
stack_trace_threshold: 0.5
|
19
18
|
transaction_threshold: 1.0
|
20
19
|
capture_params: false
|
21
|
-
log_level: debug
|
22
|
-
log_file_path: agent.log
|
@@ -22,7 +22,7 @@ DB.create_table( :users ) do
|
|
22
22
|
end
|
23
23
|
class User < Sequel::Model; end
|
24
24
|
|
25
|
-
class SequelTest <
|
25
|
+
class SequelTest < MiniTest::Unit::TestCase
|
26
26
|
|
27
27
|
def test_it_doesnt_blow_up
|
28
28
|
require 'newrelic_rpm'
|
@@ -32,4 +32,3 @@ class SequelTest < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
35
|
-
|
@@ -7,15 +7,3 @@ gemfile <<-RB
|
|
7
7
|
gem 'sidekiq'
|
8
8
|
gem 'rack'
|
9
9
|
RB
|
10
|
-
|
11
|
-
before_suite do
|
12
|
-
ENV["NEWRELIC_MULTIVERSE_REDIS_PORT"] = (20_000 + ($$ % 10_000)).to_s
|
13
|
-
ENV["NEWRELIC_MULTIVERSE_FAKE_COLLECTOR_PORT"] = (30_000 + ($$ % 10_000)).to_s
|
14
|
-
system("echo 'port #{ENV["NEWRELIC_MULTIVERSE_REDIS_PORT"]}' | redis-server - > /dev/null &")
|
15
|
-
end
|
16
|
-
|
17
|
-
after_suite do
|
18
|
-
system("redis-cli -p #{ENV["NEWRELIC_MULTIVERSE_REDIS_PORT"]} shutdown")
|
19
|
-
end
|
20
|
-
|
21
|
-
execute_mode 'spawn'
|
@@ -11,13 +11,11 @@ development:
|
|
11
11
|
app_name: test
|
12
12
|
host: 127.0.0.1
|
13
13
|
api_host: 127.0.0.1
|
14
|
-
|
15
|
-
port: <%= ENV['NEWRELIC_MULTIVERSE_FAKE_COLLECTOR_PORT'] %>
|
14
|
+
port: <%= $collector && $collector.port %>
|
16
15
|
transaction_tracer:
|
17
16
|
record_sql: obfuscated
|
18
17
|
enabled: true
|
19
18
|
stack_trace_threshold: 0.5
|
20
19
|
transaction_threshold: 1.0
|
21
20
|
capture_params: false
|
22
|
-
log_level: debug
|
23
21
|
log_file_path: log
|
@@ -5,93 +5,69 @@
|
|
5
5
|
# https://newrelic.atlassian.net/browse/RUBY-775
|
6
6
|
|
7
7
|
require 'sidekiq'
|
8
|
+
require 'sidekiq/testing/inline'
|
8
9
|
require 'test/unit'
|
9
10
|
require 'newrelic_rpm'
|
10
11
|
require 'fake_collector'
|
12
|
+
require 'multiverse_helpers'
|
11
13
|
|
12
|
-
class SidekiqTest <
|
14
|
+
class SidekiqTest < MiniTest::Unit::TestCase
|
13
15
|
JOB_COUNT = 5
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
|
17
|
+
include MultiverseHelpers
|
18
|
+
|
19
|
+
setup_and_teardown_agent
|
20
|
+
|
21
|
+
class TestWorker
|
22
|
+
include Sidekiq::Worker
|
23
|
+
|
24
|
+
@jobs = {}
|
25
|
+
|
26
|
+
def self.reset
|
27
|
+
@jobs = {}
|
24
28
|
end
|
25
|
-
end
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
30
|
+
def self.record(key, val)
|
31
|
+
@jobs[key] ||= []
|
32
|
+
@jobs[key] << val
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
system(worker_cmd)
|
37
|
-
end
|
35
|
+
def self.records_for(key)
|
36
|
+
@jobs[key]
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
Process.kill("TERM", worker_pid)
|
42
|
-
begin
|
43
|
-
Timeout.timeout(5) { sleep(1) until !process_alive?(worker_pid) }
|
44
|
-
rescue Timeout::Error => e
|
45
|
-
raise e.exception("timed out waiting for sidekiq worker exit")
|
39
|
+
def perform(key, val)
|
40
|
+
TestWorker.record(key, val)
|
46
41
|
end
|
47
42
|
end
|
48
43
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
# Running inline doesn't set up server middlewares
|
45
|
+
# Using the client middleware to get there instead
|
46
|
+
Sidekiq.configure_client do |config|
|
47
|
+
config.client_middleware do |chain|
|
48
|
+
chain.add NewRelic::SidekiqInstrumentation
|
49
|
+
end
|
54
50
|
end
|
55
51
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
stats = Sidekiq::Stats.new
|
61
|
-
Timeout.timeout(time_for_jobs) { sleep(0.1) until stats.processed == JOB_COUNT }
|
62
|
-
rescue Timeout::Error => err
|
63
|
-
completed = stats.processed
|
64
|
-
msg = "waiting #{time_for_jobs}s for completion of #{JOB_COUNT} jobs - only #{completed} completed"
|
65
|
-
msg << "\nstarted waiting at #{t0}, now = #{Time.now}"
|
66
|
-
raise err.exception(msg)
|
52
|
+
def run_jobs
|
53
|
+
TestWorker.reset
|
54
|
+
JOB_COUNT.times do |i|
|
55
|
+
TestWorker.perform_async('jobs_completed', i + 1)
|
67
56
|
end
|
57
|
+
|
58
|
+
NewRelic::Agent.instance.send(:transmit_data)
|
68
59
|
end
|
69
60
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
stop_worker
|
76
|
-
end
|
61
|
+
def test_all_jobs_ran
|
62
|
+
run_jobs
|
63
|
+
completed_jobs = Set.new(TestWorker.records_for('jobs_completed').map(&:to_i))
|
64
|
+
expected_completed_jobs = Set.new((1..JOB_COUNT).to_a)
|
65
|
+
assert_equal(expected_completed_jobs, completed_jobs)
|
77
66
|
end
|
78
67
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
File.unlink(@sidekiq_log) if File.exist?(@sidekiq_log)
|
83
|
-
@sidekiq_log = "log/sidekiq.#{$$}.log"
|
84
|
-
begin
|
85
|
-
yield
|
86
|
-
rescue Exception => e
|
87
|
-
if File.exist?(@sidekiq_log)
|
88
|
-
log_contents = File.read(@sidekiq_log)
|
89
|
-
$stderr.puts "Sidekiq log contents (#{@sidekiq_log}):"
|
90
|
-
$stderr.puts log_contents
|
91
|
-
end
|
92
|
-
raise e
|
93
|
-
end
|
94
|
-
File.unlink(@sidekiq_log) if File.exist?(@sidekiq_log)
|
68
|
+
def test_agent_posts_correct_metric_data
|
69
|
+
run_jobs
|
70
|
+
assert_metric_and_call_count('OtherTransaction/SidekiqJob/all', JOB_COUNT)
|
95
71
|
end
|
96
72
|
|
97
73
|
METRIC_VALUES_POSITION = 3
|
@@ -106,36 +82,4 @@ class SidekiqTest < Test::Unit::TestCase
|
|
106
82
|
call_count = metric[1][0]
|
107
83
|
assert_equal(expected_call_count, call_count)
|
108
84
|
end
|
109
|
-
|
110
|
-
def test_all_jobs_ran
|
111
|
-
capture_sidekiq_log do
|
112
|
-
run_worker
|
113
|
-
completed_jobs = Set.new($redis.smembers('jobs_completed').map(&:to_i))
|
114
|
-
expected_completed_jobs = Set.new((1..JOB_COUNT).to_a)
|
115
|
-
assert_equal(expected_completed_jobs, completed_jobs)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_agent_posts_correct_metric_data
|
120
|
-
capture_sidekiq_log do
|
121
|
-
run_worker
|
122
|
-
assert_metric_and_call_count('OtherTransaction/SidekiqJob/all', JOB_COUNT)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_all_jobs_ran_background
|
127
|
-
capture_sidekiq_log do
|
128
|
-
run_worker(:daemonize => true)
|
129
|
-
completed_jobs = Set.new($redis.smembers('jobs_completed').map(&:to_i))
|
130
|
-
expected_completed_jobs = Set.new((1..JOB_COUNT).to_a)
|
131
|
-
assert_equal(expected_completed_jobs, completed_jobs)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_agent_posts_correct_metric_data_background
|
136
|
-
capture_sidekiq_log do
|
137
|
-
run_worker(:daemonize => true)
|
138
|
-
assert_metric_and_call_count('OtherTransaction/SidekiqJob/all', JOB_COUNT)
|
139
|
-
end
|
140
|
-
end
|
141
85
|
end
|
@@ -10,15 +10,12 @@ development:
|
|
10
10
|
license_key: bootstrap_newrelic_admin_license_key_000
|
11
11
|
developer_mode: false
|
12
12
|
app_name: test
|
13
|
-
sync_startup: true
|
14
13
|
host: 127.0.0.1
|
15
14
|
api_host: 127.0.0.1
|
16
|
-
port: <%= 30_000 + ($$ % 10_000) %>
|
17
15
|
transaction_tracer:
|
18
16
|
record_sql: obfuscated
|
19
17
|
enabled: true
|
20
18
|
stack_trace_threshold: 0.5
|
21
19
|
transaction_threshold: 1.0
|
22
20
|
capture_params: false
|
23
|
-
log_level: debug
|
24
21
|
disable_serialization: false
|
@@ -2,6 +2,8 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
require 'multiverse_helpers'
|
6
|
+
|
5
7
|
class SinatraIgnoreTestApp < Sinatra::Base
|
6
8
|
get '/record' do request.path_info end
|
7
9
|
|
@@ -34,14 +36,12 @@ class SinatraIgnoreTestApp < Sinatra::Base
|
|
34
36
|
|
35
37
|
end
|
36
38
|
|
37
|
-
class SinatraTestCase <
|
39
|
+
class SinatraTestCase < MiniTest::Unit::TestCase
|
38
40
|
include Rack::Test::Methods
|
39
41
|
include ::NewRelic::Agent::Instrumentation::Sinatra
|
42
|
+
include MultiverseHelpers
|
40
43
|
|
41
|
-
|
42
|
-
NewRelic::Agent.manual_start
|
43
|
-
NewRelic::Agent.instance.stats_engine.reset_stats
|
44
|
-
end
|
44
|
+
setup_and_teardown_agent
|
45
45
|
|
46
46
|
def get_and_assert_ok(path)
|
47
47
|
get(path)
|
@@ -154,6 +154,9 @@ class SinatraIgnoreItAllTest < SinatraTestCase
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def test_ignores_everything
|
157
|
+
# Avoid Supportability metrics from startup of agent for this check
|
158
|
+
NewRelic::Agent.instance.reset_stats
|
159
|
+
|
157
160
|
get_and_assert_ok '/'
|
158
161
|
assert_metrics_recorded_exclusive([])
|
159
162
|
end
|
@@ -82,7 +82,14 @@ get /\/regex.*/ do
|
|
82
82
|
"Yeah, regex's!"
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
module Sinatra
|
86
|
+
class Application < Base
|
87
|
+
# Override to not accidentally start the app in at_exit handler
|
88
|
+
set :run, Proc.new { false }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class SinatraClassicTest < MiniTest::Unit::TestCase
|
86
93
|
include SinatraTestCases
|
87
94
|
|
88
95
|
def app
|
@@ -2,6 +2,8 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
require 'multiverse_helpers'
|
6
|
+
|
5
7
|
class SinatraErrorTracingTestApp < Sinatra::Base
|
6
8
|
configure do
|
7
9
|
set :show_exceptions, false
|
@@ -16,21 +18,16 @@ class SinatraErrorTracingTestApp < Sinatra::Base
|
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
|
-
class SinatraErrorTracingTest <
|
21
|
+
class SinatraErrorTracingTest < MiniTest::Unit::TestCase
|
20
22
|
include Rack::Test::Methods
|
21
23
|
include ::NewRelic::Agent::Instrumentation::Sinatra
|
22
24
|
|
23
|
-
|
24
|
-
SinatraErrorTracingTestApp
|
25
|
-
end
|
25
|
+
include MultiverseHelpers
|
26
26
|
|
27
|
-
|
28
|
-
::NewRelic::Agent.manual_start
|
29
|
-
@error_collector = ::NewRelic::Agent.instance.error_collector
|
27
|
+
setup_and_teardown_agent
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
'error collector should be enabled')
|
29
|
+
def app
|
30
|
+
SinatraErrorTracingTestApp
|
34
31
|
end
|
35
32
|
|
36
33
|
def test_traps_errors
|
@@ -38,13 +35,13 @@ class SinatraErrorTracingTest < Test::Unit::TestCase
|
|
38
35
|
assert_equal 500, last_response.status
|
39
36
|
assert_equal 'We are sorry', last_response.body
|
40
37
|
|
41
|
-
assert_equal(1,
|
38
|
+
assert_equal(1, agent.error_collector.errors.size)
|
42
39
|
end
|
43
40
|
|
44
41
|
def test_ignores_notfound_errors_by_default
|
45
42
|
get '/ignored_boom'
|
46
43
|
assert_equal 404, last_response.status
|
47
44
|
assert_match %r{Sinatra doesn’t know this ditty\.}, last_response.body
|
48
|
-
assert_equal(0,
|
45
|
+
assert_equal(0, agent.error_collector.errors.size)
|
49
46
|
end
|
50
47
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
require 'multiverse_helpers'
|
5
6
|
|
6
7
|
class SinatraTestApp < Sinatra::Base
|
7
8
|
get '/hello/:name' do |name|
|
@@ -24,18 +25,18 @@ class SinatraTestApp < Sinatra::Base
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
class SinatraMetricExplosionTest <
|
28
|
+
class SinatraMetricExplosionTest < MiniTest::Unit::TestCase
|
28
29
|
include Rack::Test::Methods
|
29
30
|
include ::NewRelic::Agent::Instrumentation::Sinatra
|
30
31
|
|
32
|
+
include MultiverseHelpers
|
33
|
+
|
34
|
+
setup_and_teardown_agent
|
35
|
+
|
31
36
|
def app
|
32
37
|
SinatraTestApp
|
33
38
|
end
|
34
39
|
|
35
|
-
def setup
|
36
|
-
::NewRelic::Agent.agent.stats_engine.clear_stats
|
37
|
-
end
|
38
|
-
|
39
40
|
def test_sinatra_returns_properly
|
40
41
|
get '/hello/world'
|
41
42
|
assert_equal 'hello world', last_response.body
|
@@ -64,13 +65,13 @@ class SinatraMetricExplosionTest < Test::Unit::TestCase
|
|
64
65
|
|
65
66
|
metric_names = ::NewRelic::Agent.agent.stats_engine.metrics
|
66
67
|
metric_names -= ['CPU/User Time', "Middleware/all", "WebFrontend/QueueTime", "WebFrontend/WebServer/all"]
|
68
|
+
metric_names.delete_if {|metric| metric.start_with?("Supportability")}
|
67
69
|
assert_equal 6, metric_names.size, "Explosion detected in: #{metric_names.inspect}"
|
68
70
|
end
|
69
71
|
|
70
72
|
def test_does_not_break_when_no_verb_matches
|
71
|
-
|
72
|
-
|
73
|
-
end
|
73
|
+
post '/some/garbage'
|
74
|
+
|
74
75
|
metric_names = ::NewRelic::Agent.agent.stats_engine.metrics
|
75
76
|
assert metric_names.include?('Controller/Sinatra/SinatraTestApp/POST (unknown)')
|
76
77
|
assert metric_names.include?('Apdex/Sinatra/SinatraTestApp/POST (unknown)')
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
require 'multiverse_helpers'
|
5
6
|
|
6
7
|
class SinatraRouteTestApp < Sinatra::Base
|
7
8
|
configure do
|
@@ -24,18 +25,18 @@ class SinatraRouteTestApp < Sinatra::Base
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
class SinatraRoutesTest <
|
28
|
+
class SinatraRoutesTest < MiniTest::Unit::TestCase
|
28
29
|
include Rack::Test::Methods
|
29
30
|
include ::NewRelic::Agent::Instrumentation::Sinatra
|
30
31
|
|
32
|
+
include MultiverseHelpers
|
33
|
+
|
34
|
+
setup_and_teardown_agent
|
35
|
+
|
31
36
|
def app
|
32
37
|
SinatraRouteTestApp
|
33
38
|
end
|
34
39
|
|
35
|
-
def setup
|
36
|
-
::NewRelic::Agent.manual_start
|
37
|
-
end
|
38
|
-
|
39
40
|
# https://support.newrelic.com/tickets/24779
|
40
41
|
def test_lower_priority_route_conditions_arent_applied_to_higher_priority_routes
|
41
42
|
get '/user/login'
|