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
@@ -9,17 +9,24 @@
|
|
9
9
|
require 'logger'
|
10
10
|
require 'newrelic_rpm'
|
11
11
|
require 'fake_collector'
|
12
|
+
require 'multiverse_helpers'
|
12
13
|
|
13
|
-
class LoggingTest <
|
14
|
+
class LoggingTest < MiniTest::Unit::TestCase
|
15
|
+
|
16
|
+
include MultiverseHelpers
|
17
|
+
|
18
|
+
def setup
|
19
|
+
NewRelic::Agent.stubs(:logger).returns(NewRelic::Agent::MemoryLogger.new)
|
20
|
+
end
|
14
21
|
|
15
22
|
def test_logs_app_name
|
16
|
-
running_agent_writes_to_log(
|
23
|
+
running_agent_writes_to_log(
|
17
24
|
{:app_name => "My App"},
|
18
25
|
"Application: My App")
|
19
26
|
end
|
20
27
|
|
21
28
|
def test_logs_error_with_bad_app_name
|
22
|
-
running_agent_writes_to_log(
|
29
|
+
running_agent_writes_to_log(
|
23
30
|
{:app_name => false},
|
24
31
|
"No application name configured.")
|
25
32
|
end
|
@@ -50,23 +57,13 @@ class LoggingTest < Test::Unit::TestCase
|
|
50
57
|
|
51
58
|
def test_logs_ssl_warning
|
52
59
|
running_agent_writes_to_log(
|
53
|
-
{:ssl =>
|
60
|
+
{:ssl => true},
|
54
61
|
"Agent is configured not to use SSL when communicating with New Relic's servers") do
|
55
62
|
|
56
63
|
NewRelic::Agent.config.apply_config(:ssl => false)
|
57
64
|
end
|
58
65
|
end
|
59
66
|
|
60
|
-
def test_logs_ssl_verify_cert_warning
|
61
|
-
running_agent_writes_to_log(
|
62
|
-
{:ssl => false, :verify_certificate => false},
|
63
|
-
"Agent is configured to use SSL but to skip certificate validation when communicating with New Relic's servers") do
|
64
|
-
|
65
|
-
NewRelic::Agent.config.apply_config(:ssl => true, :verify_certificate => false)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
67
|
def test_logs_if_sending_errors_on_change
|
71
68
|
running_agent_writes_to_log(
|
72
69
|
{:'error_collector.enabled' => false},
|
@@ -92,9 +89,13 @@ class LoggingTest < Test::Unit::TestCase
|
|
92
89
|
end
|
93
90
|
|
94
91
|
def test_invalid_license_key
|
95
|
-
|
96
|
-
|
97
|
-
|
92
|
+
setup_agent({}) do |collector|
|
93
|
+
collector.stub('connect', {}, 401)
|
94
|
+
end
|
95
|
+
|
96
|
+
saw?("Visit NewRelic.com to obtain a valid license key")
|
97
|
+
|
98
|
+
teardown_agent
|
98
99
|
end
|
99
100
|
|
100
101
|
def test_logs_monitor_mode_disabled
|
@@ -121,45 +122,20 @@ class LoggingTest < Test::Unit::TestCase
|
|
121
122
|
"Connecting workers after forking.")
|
122
123
|
end
|
123
124
|
|
124
|
-
# Initialization
|
125
|
-
def setup
|
126
|
-
$collector ||= NewRelic::FakeCollector.new
|
127
|
-
$collector.reset
|
128
|
-
$collector.mock['connect'] = [200, {'return_value' => {"agent_run_id" => 666 }}]
|
129
|
-
$collector.run
|
130
|
-
|
131
|
-
NewRelic::Agent.reset_config
|
132
|
-
NewRelic::Agent::Agent.instance_variable_set(:@instance, nil)
|
133
|
-
|
134
|
-
@logger = NewRelic::Agent::MemoryLogger.new
|
135
|
-
NewRelic::Agent.logger = @logger
|
136
|
-
NewRelic::Agent::AgentLogger.stubs(:new).with(any_parameters).returns(@logger)
|
137
|
-
end
|
138
|
-
|
139
|
-
def teardown
|
140
|
-
$collector.reset
|
141
|
-
|
142
|
-
# Really clear out our agent instance since we set bad license keys
|
143
|
-
NewRelic::Agent::Agent.instance_variable_set(:@instance, nil)
|
144
|
-
end
|
145
|
-
|
146
125
|
# Helpers
|
147
|
-
def running_agent_writes_to_log(options, msg)
|
148
|
-
|
149
|
-
yield if block_given?
|
150
|
-
NewRelic::Agent.shutdown
|
126
|
+
def running_agent_writes_to_log(options, msg, &block)
|
127
|
+
run_agent(options, &block)
|
151
128
|
saw?(msg)
|
152
129
|
end
|
153
130
|
|
154
|
-
def with_connect_response(status=200, response={})
|
155
|
-
$collector.mock['connect'] = [status, response]
|
156
|
-
end
|
157
|
-
|
158
131
|
def saw?(*expected_messages)
|
159
|
-
|
132
|
+
# This is actually our MemoryLogger, so it has messages to check. Woot!
|
133
|
+
logger = NewRelic::Agent.logger
|
134
|
+
|
135
|
+
flattened = logger.messages.flatten
|
160
136
|
expected_messages.each do |expected|
|
161
137
|
found = flattened.any? {|msg| msg.to_s.include?(expected)}
|
162
|
-
|
138
|
+
logger.messages.each {|msg| puts msg.inspect} if !found
|
163
139
|
assert(found, "Didn't see message '#{expected}'")
|
164
140
|
end
|
165
141
|
end
|
@@ -5,41 +5,33 @@
|
|
5
5
|
# https://newrelic.atlassian.net/wiki/display/eng/The+Terror+and+Glory+of+Transaction+Traces
|
6
6
|
# https://newrelic.atlassian.net/browse/RUBY-914
|
7
7
|
require 'ostruct'
|
8
|
+
require 'multiverse_helpers'
|
8
9
|
|
9
|
-
class MarshalingTest <
|
10
|
-
|
11
|
-
NewRelic::Agent.manual_start(:'transaction_tracer.transaction_threshold' => 0.0)
|
12
|
-
@agent = NewRelic::Agent.instance
|
13
|
-
@sampler = @agent.transaction_sampler
|
10
|
+
class MarshalingTest < MiniTest::Unit::TestCase
|
11
|
+
include MultiverseHelpers
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
$collector.mock['connect'] = [200, {'return_value' => { 'agent_run_id' => 666 }}]
|
18
|
-
$collector.run
|
19
|
-
end
|
20
|
-
|
21
|
-
def teardown
|
22
|
-
Thread.current[:transaction_sample_builder] = nil
|
23
|
-
$collector.reset
|
13
|
+
setup_and_teardown_agent(:'transaction_tracer.transaction_threshold' => 0.0) do |collector|
|
14
|
+
collector.stub('connect', { 'agent_run_id' => 666 })
|
24
15
|
end
|
25
16
|
|
26
17
|
def test_transaction_trace_marshaling
|
27
18
|
# create fake transaction trace
|
28
|
-
time =
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
19
|
+
time = freeze_time
|
20
|
+
sampler = agent.transaction_sampler
|
21
|
+
sampler.notice_first_scope_push time
|
22
|
+
sampler.notice_transaction nil, {}
|
23
|
+
sampler.notice_push_scope "a"
|
24
|
+
sampler.notice_push_scope "ab"
|
25
|
+
advance_time 1
|
26
|
+
sampler.notice_pop_scope "ab"
|
27
|
+
sampler.notice_pop_scope "a"
|
28
|
+
sampler.notice_scope_empty(OpenStruct.new(:name => 'path',
|
37
29
|
:custom_parameters => {}))
|
38
30
|
|
39
|
-
expected_sample =
|
31
|
+
expected_sample = sampler.instance_variable_get(:@slowest_sample)
|
40
32
|
|
41
|
-
|
42
|
-
|
33
|
+
agent.service.connect
|
34
|
+
agent.send(:harvest_and_send_slowest_sample)
|
43
35
|
|
44
36
|
if NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported?
|
45
37
|
marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
|
@@ -58,8 +50,8 @@ class MarshalingTest < Test::Unit::TestCase
|
|
58
50
|
stats.record_data_point(2.0, 1.0)
|
59
51
|
expected = [ 2, 3.0, 2.0, 1.0, 2.0, 5.0 ]
|
60
52
|
|
61
|
-
|
62
|
-
|
53
|
+
agent.service.connect
|
54
|
+
agent.send(:harvest_and_send_timeslice_data)
|
63
55
|
|
64
56
|
assert_equal('666', $collector.calls_for('metric_data')[0].run_id)
|
65
57
|
|
@@ -68,9 +60,9 @@ class MarshalingTest < Test::Unit::TestCase
|
|
68
60
|
end
|
69
61
|
|
70
62
|
def test_error_data_marshalling
|
71
|
-
|
72
|
-
|
73
|
-
|
63
|
+
agent.error_collector.notice_error(Exception.new('test error'))
|
64
|
+
agent.service.connect
|
65
|
+
agent.send(:harvest_and_send_errors)
|
74
66
|
|
75
67
|
assert_equal('666', $collector.calls_for('error_data')[0].run_id)
|
76
68
|
|
@@ -79,24 +71,24 @@ class MarshalingTest < Test::Unit::TestCase
|
|
79
71
|
end
|
80
72
|
|
81
73
|
def test_sql_trace_data_marshalling
|
82
|
-
|
83
|
-
|
74
|
+
agent.sql_sampler.notice_first_scope_push(nil)
|
75
|
+
agent.sql_sampler.notice_sql("select * from test",
|
84
76
|
"Database/test/select",
|
85
77
|
nil, 1.5)
|
86
|
-
|
78
|
+
agent.sql_sampler.notice_scope_empty('txn')
|
87
79
|
|
88
|
-
|
89
|
-
|
80
|
+
agent.service.connect
|
81
|
+
agent.send(:harvest_and_send_slowest_sql)
|
90
82
|
|
91
83
|
sql_data = $collector.calls_for('sql_trace_data')[0][0]
|
92
84
|
assert_equal('select * from test', sql_data[0][3])
|
93
85
|
end
|
94
86
|
|
95
87
|
def test_connect_marshalling
|
96
|
-
|
88
|
+
agent.service.connect('pid' => 1, 'agent_version' => '9000',
|
97
89
|
'app_name' => 'test')
|
98
90
|
|
99
|
-
connect_data = $collector.calls_for('connect')
|
91
|
+
connect_data = $collector.calls_for('connect').last
|
100
92
|
assert_equal '9000', connect_data['agent_version']
|
101
93
|
end
|
102
94
|
end
|
@@ -4,15 +4,21 @@
|
|
4
4
|
|
5
5
|
# https://newrelic.atlassian.net/browse/RUBY-669
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
require 'multiverse_helpers'
|
8
|
+
|
9
|
+
class PipeManagerTest < MiniTest::Unit::TestCase
|
10
|
+
include MultiverseHelpers
|
11
|
+
|
12
|
+
setup_and_teardown_agent
|
13
|
+
|
14
|
+
def after_setup
|
9
15
|
@listener = NewRelic::Agent::PipeChannelManager.listener
|
10
16
|
end
|
11
17
|
|
12
|
-
def
|
18
|
+
def after_teardown
|
13
19
|
@listener.stop
|
14
20
|
end
|
15
|
-
|
21
|
+
|
16
22
|
def test_old_pipes_are_cleaned_up_after_timeout
|
17
23
|
@listener.timeout = 1
|
18
24
|
NewRelic::Agent::PipeChannelManager.register_report_channel(:timeout_test)
|
@@ -26,11 +32,11 @@ class PipeManagerTest < Test::Unit::TestCase
|
|
26
32
|
@listener.select_timeout = 1
|
27
33
|
@listener.timeout = 2
|
28
34
|
NewRelic::Agent::PipeChannelManager.register_report_channel(:select_test)
|
29
|
-
|
35
|
+
|
30
36
|
sleep 1.5
|
31
37
|
@listener.start
|
32
38
|
assert NewRelic::Agent::PipeChannelManager.channels[:select_test]
|
33
|
-
|
39
|
+
|
34
40
|
sleep 1.5
|
35
41
|
assert_nil NewRelic::Agent::PipeChannelManager.channels[:select_test]
|
36
42
|
end
|
@@ -2,9 +2,23 @@
|
|
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
|
-
|
5
|
+
require 'multiverse_helpers'
|
6
|
+
|
7
|
+
class RenameRuleTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
include MultiverseHelpers
|
10
|
+
|
11
|
+
setup_and_teardown_agent do |collector|
|
12
|
+
rules = [ { 'match_expression' => 'RenameRuleTest', 'replacement' => 'Class' } ]
|
13
|
+
collector.stub('connect', {
|
14
|
+
'agent_run_id' => 666,
|
15
|
+
'transaction_name_rules' => rules,
|
16
|
+
'metric_name_rules' => rules
|
17
|
+
})
|
18
|
+
end
|
19
|
+
|
6
20
|
class TestWidget
|
7
|
-
include
|
21
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
8
22
|
|
9
23
|
def txn
|
10
24
|
mthd
|
@@ -17,48 +31,26 @@ class RenameRuleTest < Test::Unit::TestCase
|
|
17
31
|
add_method_tracer :mthd
|
18
32
|
end
|
19
33
|
|
20
|
-
def
|
21
|
-
$collector ||= NewRelic::FakeCollector.new
|
22
|
-
$collector.reset
|
23
|
-
txn_rule_specs = [ { 'match_expression' => 'RenameRuleTest',
|
24
|
-
'replacement' => 'Class' } ]
|
25
|
-
metric_rule_specs = [ { 'match_expression' => 'RenameRuleTest',
|
26
|
-
'replacement' => 'Class' } ]
|
27
|
-
$collector.mock['connect'] = [200, {'return_value' => {
|
28
|
-
"agent_run_id" => 666,
|
29
|
-
'transaction_name_rules' => txn_rule_specs,
|
30
|
-
'metric_name_rules' => metric_rule_specs
|
31
|
-
}}]
|
32
|
-
$collector.run
|
33
|
-
|
34
|
-
NewRelic::Agent.manual_start(:sync_startup => true,
|
35
|
-
:force_reconnect => true,
|
36
|
-
:port => $collector.port)
|
34
|
+
def test_transaction_names_rules
|
37
35
|
TestWidget.new.txn
|
38
|
-
end
|
39
36
|
|
40
|
-
|
41
|
-
NewRelic::Agent.instance.instance_variable_set(:@transaction_rules,
|
42
|
-
NewRelic::Agent::RulesEngine.new)
|
43
|
-
NewRelic::Agent.shutdown
|
44
|
-
end
|
37
|
+
metric_names = NewRelic::Agent.instance.stats_engine.metrics
|
45
38
|
|
46
|
-
|
47
|
-
metric_names
|
48
|
-
|
49
|
-
|
50
|
-
assert(metric_names.include?('Apdex/Class::TestWidget/txn'),
|
51
|
-
"'Apdex/Class::TestWidget/txn' not found in #{metric_names}")
|
52
|
-
assert(!metric_names.include?('Controller/RenameRuleTest::TestWidget/txn'),
|
53
|
-
"'Controller/RenameRuleTest::TestWidget/txn' should not be in #{metric_names}")
|
39
|
+
assert_includes(metric_names, 'Controller/Class::TestWidget/txn')
|
40
|
+
assert_includes(metric_names, 'Apdex/Class::TestWidget/txn')
|
41
|
+
|
42
|
+
assert_not_includes(metric_names, 'Controller/RenameRuleTest::TestWidget/txn')
|
54
43
|
end
|
55
44
|
|
56
45
|
def test_metric_name_rules
|
46
|
+
TestWidget.new.txn
|
47
|
+
|
57
48
|
NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)
|
58
|
-
metric_names = $collector.calls_for('metric_data')
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
49
|
+
metric_names = $collector.calls_for('metric_data').first.metric_names
|
50
|
+
|
51
|
+
assert_includes(metric_names, 'Custom/Class::TestWidget/mthd')
|
52
|
+
|
53
|
+
assert_not_includes(metric_names, 'Custom/RenameRuleTest::TestWidget/mthd')
|
63
54
|
end
|
55
|
+
|
64
56
|
end
|
@@ -5,46 +5,45 @@
|
|
5
5
|
require 'rack/test'
|
6
6
|
require 'new_relic/rack/browser_monitoring'
|
7
7
|
require './testing_app'
|
8
|
+
require 'multiverse_helpers'
|
8
9
|
|
9
|
-
class RumAutoTest <
|
10
|
+
class RumAutoTest < MiniTest::Unit::TestCase
|
10
11
|
|
11
12
|
attr_reader :app
|
13
|
+
|
12
14
|
include Rack::Test::Methods
|
15
|
+
include MultiverseHelpers
|
16
|
+
|
17
|
+
setup_and_teardown_agent(:browser_key => 'browserKey', :application_id => 'appId',
|
18
|
+
:beacon => 'beacon', :episodes_file => 'this_is_my_file')
|
13
19
|
|
14
|
-
def
|
20
|
+
def after_setup
|
15
21
|
@inner_app = TestingApp.new
|
16
22
|
@app = NewRelic::Rack::BrowserMonitoring.new(@inner_app)
|
17
|
-
|
18
|
-
NewRelic::Agent.manual_start(:browser_key => 'browserKey', :application_id => 'appId',
|
19
|
-
:beacon => 'beacon', :episodes_file => 'this_is_my_file')
|
20
|
-
NewRelic::Agent.instance.instance_variable_set(
|
21
|
-
:@beacon_configuration, NewRelic::Agent::BeaconConfiguration.new)
|
22
23
|
end
|
23
24
|
|
24
|
-
def
|
25
|
-
NewRelic::Agent.shutdown
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_autoinstrumenation_is_active
|
25
|
+
def test_autoinstrumentation_is_active
|
29
26
|
@inner_app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
|
30
27
|
get '/'
|
31
28
|
assert(last_response.body =~ %r|<script|, "response body should include RUM auto instrumentation js:\n #{last_response.body}")
|
32
29
|
assert(last_response.body =~ %r|NREUMQ|, "response body should include RUM auto instrumentation js:\n #{last_response.body}")
|
33
30
|
end
|
34
31
|
|
35
|
-
def
|
32
|
+
def test_autoinstrumentation_with_basic_page_puts_header_at_beginning_of_head
|
36
33
|
@inner_app.response = "<html><head><title>foo</title></head><body><p>Hello World</p></body></html>"
|
34
|
+
NewRelic::Agent.logger.debug("================================")
|
37
35
|
get '/'
|
36
|
+
NewRelic::Agent.logger.debug("================================")
|
38
37
|
assert(last_response.body.include?('<html><head><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script><title>foo</title></head><body>'))
|
39
38
|
end
|
40
39
|
|
41
|
-
def
|
40
|
+
def test_autoinstrumentation_with_body_only_puts_header_before_body
|
42
41
|
@inner_app.response = "<html><body><p>Hello World</p></body></html>"
|
43
42
|
get '/'
|
44
43
|
assert(last_response.body.include?('<html><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script><body>'))
|
45
44
|
end
|
46
45
|
|
47
|
-
def
|
46
|
+
def test_autoinstrumentation_with_X_UA_Compatible_puts_header_at_end_of_head
|
48
47
|
@inner_app.response = '<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /></head><body><p>Hello World</p></body></html>'
|
49
48
|
get '/'
|
50
49
|
assert(last_response.body.include?(
|
@@ -53,13 +52,13 @@ class RumAutoTest < Test::Unit::TestCase
|
|
53
52
|
end
|
54
53
|
|
55
54
|
# regression
|
56
|
-
def
|
55
|
+
def test_autoinstrumentation_fails_gracefully_with_X_UA_Compatible_and_no_close_head_tag_puts_header_before_body_tag
|
57
56
|
@inner_app.response = '<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /><body><p>Hello World</p></body></html>'
|
58
57
|
get '/'
|
59
58
|
assert(!last_response.body.include?(%'NREUMQ'))
|
60
59
|
end
|
61
60
|
|
62
|
-
def
|
61
|
+
def test_autoinstrumentation_doesnt_run_for_crazy_shit_like_this
|
63
62
|
@inner_app.response = '<html><head <body </body>'
|
64
63
|
get '/'
|
65
64
|
assert_equal('<html><head <body </body>', last_response.body)
|
@@ -82,4 +81,3 @@ class RumAutoTest < Test::Unit::TestCase
|
|
82
81
|
assert_equal(last_response.body, body)
|
83
82
|
end
|
84
83
|
end
|
85
|
-
|
@@ -4,12 +4,11 @@
|
|
4
4
|
|
5
5
|
require 'socket'
|
6
6
|
|
7
|
-
class ServiceTimeoutTest <
|
8
|
-
|
9
|
-
PORT = 10_000 + ($$ % 10_000)
|
7
|
+
class ServiceTimeoutTest < MiniTest::Unit::TestCase
|
10
8
|
|
11
9
|
def setup
|
12
|
-
hk = TCPServer.new('127.0.0.1',
|
10
|
+
hk = TCPServer.new('127.0.0.1',0)
|
11
|
+
@port = hk.addr[1]
|
13
12
|
|
14
13
|
Thread.new {
|
15
14
|
client = hk.accept
|
@@ -21,12 +20,12 @@ class ServiceTimeoutTest < Test::Unit::TestCase
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def test_service_timeout
|
24
|
-
server = NewRelic::Control::Server.new('localhost',
|
23
|
+
server = NewRelic::Control::Server.new('localhost',@port,'127.0.0.1')
|
25
24
|
NewRelic::Agent.config.apply_config(:timeout => 0.1)
|
26
25
|
|
27
|
-
service = NewRelic::Agent::NewRelicService.new('deadbeef', server)
|
26
|
+
service = NewRelic::Agent::NewRelicService.new('deadbeef', server)
|
28
27
|
|
29
|
-
|
28
|
+
assert_raises Timeout::Error do
|
30
29
|
service.send('send_request',
|
31
30
|
:uri => '/agent_listener/8/bd0e1d52adade840f7ca727d29a86249e89a6f1c/get_redirect_host',
|
32
31
|
:encoding => 'UTF-8', :collector => server, :data => 'blah')
|