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
@@ -2,7 +2,6 @@
|
|
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
|
-
ENV['SKIP_RAILS'] = 'true'
|
6
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', '..', 'test_helper'))
|
7
6
|
|
8
7
|
class NewRelic::Agent::StatsTest < Test::Unit::TestCase
|
@@ -439,7 +439,7 @@ class ThreadProfileTest < ThreadedTest
|
|
439
439
|
10.times { @profile.aggregate(trace, @profile.traces[:other]) }
|
440
440
|
|
441
441
|
trace = [
|
442
|
-
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:489:in `__bootstrap'",
|
442
|
+
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:489:in `__bootstrap'",
|
443
443
|
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:512:in `__bootstrap_inner'",
|
444
444
|
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:480:in `run'",
|
445
445
|
"thread_profiler.py:76:in `_profiler_loop'",
|
@@ -457,14 +457,14 @@ class ThreadProfileTest < ThreadedTest
|
|
457
457
|
@profile.instance_variable_set(:@sample_count, 2)
|
458
458
|
|
459
459
|
build_well_known_trace
|
460
|
-
|
460
|
+
|
461
461
|
expected = [[
|
462
|
-
-1,
|
463
|
-
1350403938892.524,
|
464
|
-
1350403939904.375,
|
465
|
-
10,
|
462
|
+
-1,
|
463
|
+
1350403938892.524,
|
464
|
+
1350403939904.375,
|
465
|
+
10,
|
466
466
|
WELL_KNOWN_TRACE_ENCODED,
|
467
|
-
2,
|
467
|
+
2,
|
468
468
|
0
|
469
469
|
]]
|
470
470
|
|
@@ -2,12 +2,10 @@
|
|
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
|
-
|
6
5
|
require 'test/unit'
|
7
6
|
require 'newrelic_rpm'
|
8
7
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
9
8
|
|
10
|
-
|
11
9
|
class TransactionInterrobangTest < Test::Unit::TestCase
|
12
10
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
13
11
|
|
@@ -23,13 +21,13 @@ class TransactionInterrobangTest < Test::Unit::TestCase
|
|
23
21
|
add_transaction_tracer :mutate!
|
24
22
|
|
25
23
|
def test_alias_method_ending_in_question_mark
|
26
|
-
assert_respond_to self
|
24
|
+
assert_respond_to self, :interrogate?
|
27
25
|
assert_respond_to self, :interrogate_with_newrelic_transaction_trace?
|
28
26
|
assert_equal "say what?", interrogate?
|
29
27
|
end
|
30
28
|
|
31
29
|
def test_aliase_method_ending_in_exclamation_makr
|
32
|
-
assert_respond_to self
|
30
|
+
assert_respond_to self, :mutate!
|
33
31
|
assert_respond_to self, :mutate_with_newrelic_transaction_trace!
|
34
32
|
assert_equal "oh yeah!",mutate!
|
35
33
|
end
|
@@ -206,6 +206,19 @@ class NewRelic::Agent::TransationSampleBuilderTest < Test::Unit::TestCase
|
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
209
|
+
def test_attaching_params_doesnt_raise_when_segments_are_limited
|
210
|
+
with_config(:'transaction_tracer.limit_segments' => 5) do
|
211
|
+
6.times { |i| build_segment "s#{i}" }
|
212
|
+
# now we should have a placeholder segment
|
213
|
+
build_segment "this-should-be-truncated" do
|
214
|
+
assert_nothing_raised do
|
215
|
+
@builder.current_segment['eggs'] = 'ham'
|
216
|
+
@builder.current_segment.params.merge!('foo' => 'bar')
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
209
222
|
def test_finish_trace_records_threshold
|
210
223
|
NewRelic::Agent::TransactionInfo.get.stubs(:transaction_trace_threshold) \
|
211
224
|
.returns(2.0)
|
@@ -183,24 +183,26 @@ class NewRelic::Agent::TransactionTest < Test::Unit::TestCase
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def test_end_fires_a_transaction_finished_event
|
186
|
-
name, duration = nil
|
186
|
+
name, timestamp, duration = nil
|
187
187
|
NewRelic::Agent.subscribe(:transaction_finished) do |*args|
|
188
|
-
name
|
189
|
-
duration = args.shift
|
188
|
+
name, timestamp, duration = *args
|
190
189
|
end
|
191
190
|
|
191
|
+
start_time = freeze_time
|
192
192
|
NewRelic::Agent::Transaction.start(:controller)
|
193
|
+
advance_time(5)
|
193
194
|
NewRelic::Agent.set_transaction_name('foo/1/bar/22')
|
194
195
|
NewRelic::Agent::Transaction.freeze_name
|
195
196
|
NewRelic::Agent::Transaction.stop('txn')
|
196
197
|
|
197
198
|
assert_equal 'Controller/foo/1/bar/22', name
|
198
|
-
|
199
|
+
assert_equal start_time.to_f, timestamp
|
200
|
+
assert_equal 5.0, duration
|
199
201
|
end
|
200
202
|
|
201
203
|
def test_end_fires_a_transaction_finished_event_with_overview_metrics
|
202
204
|
options = nil
|
203
|
-
NewRelic::Agent.subscribe(:transaction_finished) do |_, _, opts|
|
205
|
+
NewRelic::Agent.subscribe(:transaction_finished) do |_, _, _, opts|
|
204
206
|
options = opts
|
205
207
|
end
|
206
208
|
|
@@ -2,7 +2,6 @@
|
|
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
|
-
ENV['SKIP_RAILS'] = 'true'
|
6
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
7
6
|
|
8
7
|
class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
|
@@ -64,33 +64,6 @@ module NewRelic
|
|
64
64
|
NewRelic::Agent.after_fork
|
65
65
|
end
|
66
66
|
|
67
|
-
if NewRelic::LanguageSupport.can_fork? &&
|
68
|
-
!NewRelic::LanguageSupport.using_version?('1.9.1')
|
69
|
-
def test_timeslice_harvest_with_after_fork_report_to_channel
|
70
|
-
with_config(:agent_enabled => true, :monitor_mode => true) do
|
71
|
-
NewRelic::Agent.shutdown # make sure the agent is not already started
|
72
|
-
NewRelic::Agent.manual_start(:license_key => ('1234567890' * 4),
|
73
|
-
:start_channel_listener => true)
|
74
|
-
|
75
|
-
metric = 'Custom/test/method'
|
76
|
-
NewRelic::Agent.record_metric(metric, 1.0)
|
77
|
-
|
78
|
-
NewRelic::Agent::PipeChannelManager.listener.close_all_pipes
|
79
|
-
NewRelic::Agent.register_report_channel(:agent_test) # before fork
|
80
|
-
pid = Process.fork do
|
81
|
-
NewRelic::Agent.after_fork(:report_to_channel => :agent_test)
|
82
|
-
NewRelic::Agent.record_metric(metric, 2.0)
|
83
|
-
end
|
84
|
-
Process.wait(pid)
|
85
|
-
NewRelic::Agent::PipeChannelManager.listener.stop
|
86
|
-
|
87
|
-
assert_metrics_recorded({
|
88
|
-
metric => { :call_count => 2, :total_call_time => 3.0 }
|
89
|
-
})
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
67
|
def test_reset_stats
|
95
68
|
mock_agent = mocked_agent
|
96
69
|
mock_agent.expects(:reset_stats)
|
@@ -101,12 +101,12 @@ class NewRelic::CollectionHelperTest < Test::Unit::TestCase
|
|
101
101
|
end
|
102
102
|
class MyEnumerable
|
103
103
|
include Enumerable
|
104
|
-
|
104
|
+
|
105
105
|
def each
|
106
106
|
yield "1"
|
107
107
|
end
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
def test_object
|
111
111
|
assert_equal ["foo", '#<OpenStruct>'], normalize_params(['foo', OpenStruct.new('z'=>'q')])
|
112
112
|
end
|
@@ -115,7 +115,7 @@ class NewRelic::CollectionHelperTest < Test::Unit::TestCase
|
|
115
115
|
clean_trace = strip_nr_from_backtrace(mock_backtrace)
|
116
116
|
assert_equal(0, clean_trace.grep(/newrelic_rpm/).size,
|
117
117
|
"should remove all instances of new relic from backtrace but got: #{clean_trace.join("\n")}")
|
118
|
-
assert_equal(0, clean_trace.grep(/trace/).size,
|
118
|
+
assert_equal(0, clean_trace.grep(/trace/).size,
|
119
119
|
"should remove trace method tags from method names but got: #{clean_trace.join("\n")}")
|
120
120
|
assert((clean_trace.grep(/find/).size >= 3),
|
121
121
|
"should see at least three frames with 'find' in them: \n#{clean_trace.join("\n")}")
|
@@ -130,22 +130,22 @@ class NewRelic::CollectionHelperTest < Test::Unit::TestCase
|
|
130
130
|
"should not remove trace method tags from method names but got: #{clean_trace.join("\n")}")
|
131
131
|
end
|
132
132
|
end
|
133
|
-
|
134
|
-
private
|
133
|
+
|
134
|
+
private
|
135
135
|
def mock_backtrace
|
136
136
|
[
|
137
|
-
%q{/home/app/gems/activerecord-2.3.12/lib/active_record/base.rb:1620:in `find_one_without_trace'},
|
138
|
-
%q{/home/app/gems/activerecord-2.3.12/lib/active_record/base.rb:1620:in `find_one'},
|
139
|
-
%q{/home/app/gems/activerecord-2.3.12/lib/active_record/base.rb:1603:in `find_from_ids'},
|
140
|
-
%q{./test/new_relic/collection_helper_test.rb:112:in `test_strip_stackdump'},
|
141
|
-
%q{/home/app/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `__send__'},
|
142
|
-
%q{/home/app/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `run'},
|
143
|
-
%q{/home/app/test/unit/testsuite.rb:34:in `run'},
|
144
|
-
%q{/home/app/test/unit/testsuite.rb:33:in `each'},
|
145
|
-
%q{/home/app/test/unit/testsuite.rb:33:in `run'},
|
146
|
-
%q{/home/app/test/unit/testsuite.rb:34:in `run'},
|
147
|
-
%q{/home/app/test/unit/testsuite.rb:33:in `each'},
|
148
|
-
%q{/home/app/test/unit/testsuite.rb:33:in `run'},
|
137
|
+
%q{/home/app/gems/activerecord-2.3.12/lib/active_record/base.rb:1620:in `find_one_without_trace'},
|
138
|
+
%q{/home/app/gems/activerecord-2.3.12/lib/active_record/base.rb:1620:in `find_one'},
|
139
|
+
%q{/home/app/gems/activerecord-2.3.12/lib/active_record/base.rb:1603:in `find_from_ids'},
|
140
|
+
%q{./test/new_relic/collection_helper_test.rb:112:in `test_strip_stackdump'},
|
141
|
+
%q{/home/app/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `__send__'},
|
142
|
+
%q{/home/app/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `run'},
|
143
|
+
%q{/home/app/test/unit/testsuite.rb:34:in `run'},
|
144
|
+
%q{/home/app/test/unit/testsuite.rb:33:in `each'},
|
145
|
+
%q{/home/app/test/unit/testsuite.rb:33:in `run'},
|
146
|
+
%q{/home/app/test/unit/testsuite.rb:34:in `run'},
|
147
|
+
%q{/home/app/test/unit/testsuite.rb:33:in `each'},
|
148
|
+
%q{/home/app/test/unit/testsuite.rb:33:in `run'},
|
149
149
|
%q{/home/app/test/unit/ui/testrunnermediator.rb:46:in `run_suite'}
|
150
150
|
]
|
151
151
|
end
|
@@ -36,7 +36,7 @@ class NewRelic::Control::ClassMethodsTest < Test::Unit::TestCase
|
|
36
36
|
@base.load_framework_class(type)
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def test_load_framework_class_missing
|
41
41
|
# this is used to allow other people to insert frameworks without
|
42
42
|
# having the file in our agent, i.e. define your own
|
@@ -54,13 +54,13 @@ class NewRelic::ControlTest < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_resolve_ip_for_localhost
|
57
|
-
with_config(:ssl => false
|
57
|
+
with_config(:ssl => false) do
|
58
58
|
assert_equal nil, control.send(:convert_to_ip_address, 'localhost')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_resolve_ip_for_non_existent_domain
|
63
|
-
with_config(:ssl => false
|
63
|
+
with_config(:ssl => false) do
|
64
64
|
Resolv.stubs(:getaddress).raises(Resolv::ResolvError)
|
65
65
|
IPSocket.stubs(:getaddress).raises(SocketError)
|
66
66
|
assert_equal nil, control.send(:convert_to_ip_address, 'q1239988737.us')
|
@@ -68,17 +68,17 @@ class NewRelic::ControlTest < Test::Unit::TestCase
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_resolves_valid_ip
|
71
|
-
with_config(:ssl => false
|
71
|
+
with_config(:ssl => false) do
|
72
72
|
Resolv.stubs(:getaddress).with('collector.newrelic.com').returns('204.93.223.153')
|
73
73
|
assert_equal '204.93.223.153', control.send(:convert_to_ip_address, 'collector.newrelic.com')
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
def test_do_not_resolve_if_we_need_to_verify_a_cert
|
78
|
-
with_config(:ssl => false
|
78
|
+
with_config(:ssl => false) do
|
79
79
|
assert_equal nil, control.send(:convert_to_ip_address, 'localhost')
|
80
80
|
end
|
81
|
-
with_config(:ssl => true
|
81
|
+
with_config(:ssl => true) do
|
82
82
|
assert_equal 'localhost', control.send(:convert_to_ip_address, 'localhost')
|
83
83
|
end
|
84
84
|
end
|
@@ -120,7 +120,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
|
|
120
120
|
Object.instance_eval { remove_const :Resolv}
|
121
121
|
Object.instance_eval {remove_const:'IPSocket' }
|
122
122
|
|
123
|
-
with_config(:ssl => false
|
123
|
+
with_config(:ssl => false) do
|
124
124
|
assert_equal(nil, control.send(:convert_to_ip_address, 'collector.newrelic.com'), "DNS is down, should be no IP for server")
|
125
125
|
end
|
126
126
|
|
@@ -96,4 +96,32 @@ class DependencyDetectionTest < Test::Unit::TestCase
|
|
96
96
|
assert !executed
|
97
97
|
end
|
98
98
|
|
99
|
+
|
100
|
+
def test_exception_during_depends_on_check_doesnt_propagate
|
101
|
+
DependencyDetection.defer do
|
102
|
+
named :something_exceptional
|
103
|
+
depends_on { raise "Oops" }
|
104
|
+
end
|
105
|
+
|
106
|
+
DependencyDetection.detect!
|
107
|
+
|
108
|
+
assert_falsy( DependencyDetection.items.first.executed )
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
def test_exception_during_execution_doesnt_propagate
|
113
|
+
ran_second_block = false
|
114
|
+
|
115
|
+
DependencyDetection.defer do
|
116
|
+
named :something_exceptional
|
117
|
+
executes { raise "Ack!" }
|
118
|
+
executes { ran_second_block = true }
|
119
|
+
end
|
120
|
+
|
121
|
+
DependencyDetection.detect!
|
122
|
+
|
123
|
+
assert_truthy( DependencyDetection.items.first.executed )
|
124
|
+
assert_falsy( ran_second_block )
|
125
|
+
end
|
126
|
+
|
99
127
|
end
|
@@ -43,6 +43,10 @@ module NewRelic
|
|
43
43
|
@agent_data = []
|
44
44
|
end
|
45
45
|
|
46
|
+
def stub(method, return_value, status=200)
|
47
|
+
self.mock[method] = [status, {'return_value' => return_value}]
|
48
|
+
end
|
49
|
+
|
46
50
|
def call(env)
|
47
51
|
req = ::Rack::Request.new(env)
|
48
52
|
res = ::Rack::Response.new
|
@@ -121,7 +125,7 @@ module NewRelic
|
|
121
125
|
when 'connect'
|
122
126
|
ConnectPost.new(opts)
|
123
127
|
when 'metric_data'
|
124
|
-
|
128
|
+
MetricDataPost.new(opts)
|
125
129
|
when 'profile_data'
|
126
130
|
ProfileDataPost.new(opts)
|
127
131
|
when 'sql_trace_data'
|
@@ -145,6 +149,21 @@ module NewRelic
|
|
145
149
|
end
|
146
150
|
end
|
147
151
|
|
152
|
+
|
153
|
+
class MetricDataPost < AgentPost
|
154
|
+
def initialize(opts={})
|
155
|
+
super
|
156
|
+
end
|
157
|
+
|
158
|
+
def metrics
|
159
|
+
@body[3]
|
160
|
+
end
|
161
|
+
|
162
|
+
def metric_names
|
163
|
+
metrics.map {|m| m[0]["name"] }
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
148
167
|
class ConnectPost < AgentPost
|
149
168
|
def initialize(opts={})
|
150
169
|
super
|
@@ -347,4 +366,3 @@ if $0 == __FILE__
|
|
347
366
|
end
|
348
367
|
end
|
349
368
|
end
|
350
|
-
|
@@ -51,7 +51,6 @@ module NewRelic
|
|
51
51
|
def run( port=nil )
|
52
52
|
return if @thread && @thread.alive?
|
53
53
|
@server.listen( @options[:BindAddress], port ) if port
|
54
|
-
@server.listen( @options[:BindAddress], fallback_port ) if fallback_port
|
55
54
|
@thread = Thread.new( &self.method(:run_server) )
|
56
55
|
return @thread
|
57
56
|
end
|
@@ -82,16 +81,5 @@ module NewRelic
|
|
82
81
|
end
|
83
82
|
alias_method :determine_port, :port
|
84
83
|
|
85
|
-
|
86
|
-
#######
|
87
|
-
private
|
88
|
-
#######
|
89
|
-
|
90
|
-
# Return the port that will be the default if the collector hasn't been
|
91
|
-
# created.
|
92
|
-
def fallback_port
|
93
|
-
30_000 + ($$ % 10_000)
|
94
|
-
end
|
95
|
-
|
96
84
|
end
|
97
85
|
end
|
@@ -6,32 +6,32 @@ require "newrelic_rpm"
|
|
6
6
|
require "fake_external_server"
|
7
7
|
require "evil_server"
|
8
8
|
require 'mocha'
|
9
|
+
require 'multiverse_helpers'
|
9
10
|
|
10
11
|
module HttpClientTestCases
|
11
12
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation,
|
12
13
|
NewRelic::Agent::CrossAppMonitor::EncodingFunctions,
|
13
|
-
NewRelic::Agent::CrossAppTracing
|
14
|
+
NewRelic::Agent::CrossAppTracing,
|
15
|
+
MultiverseHelpers
|
14
16
|
|
15
17
|
TRANSACTION_GUID = 'BEC1BC64675138B9'
|
16
18
|
|
17
19
|
$fake_server = NewRelic::FakeExternalServer.new
|
18
20
|
$fake_secure_server = NewRelic::FakeSecureExternalServer.new
|
19
21
|
|
20
|
-
|
21
|
-
$fake_server.reset
|
22
|
-
$fake_server.run
|
23
|
-
|
24
|
-
$fake_secure_server.reset
|
25
|
-
$fake_secure_server.run
|
26
|
-
|
27
|
-
NewRelic::Agent.manual_start(
|
22
|
+
setup_and_teardown_agent(
|
28
23
|
:"cross_application_tracer.enabled" => false,
|
29
24
|
:cross_process_id => "269975#22824",
|
30
25
|
:encoding_key => "gringletoes",
|
31
26
|
:trusted_account_ids => [269975]
|
32
27
|
)
|
33
28
|
|
34
|
-
|
29
|
+
def after_setup
|
30
|
+
$fake_server.reset
|
31
|
+
$fake_server.run
|
32
|
+
|
33
|
+
$fake_secure_server.reset
|
34
|
+
$fake_secure_server.run
|
35
35
|
|
36
36
|
NewRelic::Agent.instance.events.clear
|
37
37
|
NewRelic::Agent.instance.cross_app_monitor.register_event_listeners
|
@@ -46,12 +46,6 @@ module HttpClientTestCases
|
|
46
46
|
NewRelic::Agent::TransactionInfo.get.guid = TRANSACTION_GUID
|
47
47
|
end
|
48
48
|
|
49
|
-
def teardown
|
50
|
-
NewRelic::Agent.instance.transaction_sampler.reset!
|
51
|
-
Thread::current[:newrelic_scope_stack] = nil
|
52
|
-
NewRelic::Agent.instance.stats_engine.end_transaction
|
53
|
-
end
|
54
|
-
|
55
49
|
# Helpers to support shared tests
|
56
50
|
|
57
51
|
def use_ssl
|
@@ -111,6 +105,11 @@ module HttpClientTestCases
|
|
111
105
|
assert_nil response_instance["boo"]
|
112
106
|
end
|
113
107
|
|
108
|
+
def test_response_wrapper_ignores_case_in_header_keys
|
109
|
+
res = response_instance('NAMCO' => 'digdug')
|
110
|
+
assert_equal 'digdug', res['namco']
|
111
|
+
end
|
112
|
+
|
114
113
|
def test_get
|
115
114
|
res = get_response
|
116
115
|
|
@@ -358,9 +357,7 @@ module HttpClientTestCases
|
|
358
357
|
raises( NoMethodError, "undefined method `push_scope'" )
|
359
358
|
|
360
359
|
with_config(:"cross_application_tracer.enabled" => true) do
|
361
|
-
|
362
|
-
res = get_response
|
363
|
-
end
|
360
|
+
res = get_response
|
364
361
|
end
|
365
362
|
|
366
363
|
assert_equal NewRelic::FakeExternalServer::STATUS_MESSAGE, body(res)
|
@@ -372,9 +369,7 @@ module HttpClientTestCases
|
|
372
369
|
raises( NoMethodError, "undefined method `pop_scope'" )
|
373
370
|
|
374
371
|
with_config(:"cross_application_tracer.enabled" => true) do
|
375
|
-
|
376
|
-
res = get_response
|
377
|
-
end
|
372
|
+
res = get_response
|
378
373
|
end
|
379
374
|
|
380
375
|
assert_equal NewRelic::FakeExternalServer::STATUS_MESSAGE, body(res)
|
@@ -392,7 +387,7 @@ module HttpClientTestCases
|
|
392
387
|
get_response
|
393
388
|
end
|
394
389
|
|
395
|
-
|
390
|
+
refute_match( /undefined method `rename_scope_segment" for nil:NilClass/i,
|
396
391
|
logger.messages.flatten.map {|log| log.to_s }.join(" ") )
|
397
392
|
|
398
393
|
ensure
|
@@ -416,7 +411,8 @@ module HttpClientTestCases
|
|
416
411
|
# transaction in which the error occurs. That, coupled with the fact that
|
417
412
|
# fixing it for old versions of Typhoeus would require large changes to
|
418
413
|
# the instrumentation, makes us say 'meh'.
|
419
|
-
|
414
|
+
is_typhoeus = (client_name == 'Typhoeus')
|
415
|
+
if !is_typhoeus || (is_typhoeus && Typhoeus::VERSION >= "0.5.4")
|
420
416
|
evil_server = NewRelic::EvilServer.new
|
421
417
|
evil_server.start
|
422
418
|
|