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
@@ -5,8 +5,13 @@
|
|
5
5
|
# This module brings the base test cases that should run against both classic and
|
6
6
|
# module Sinatra apps. The sinatra_class_test and sinatra_modular_test files
|
7
7
|
# both maintain the same app structure in both forms, and this exercises them.
|
8
|
+
|
9
|
+
require 'multiverse_helpers'
|
10
|
+
|
8
11
|
module SinatraTestCases
|
9
12
|
include Rack::Test::Methods
|
13
|
+
include MultiverseHelpers
|
14
|
+
|
10
15
|
|
11
16
|
def app
|
12
17
|
raise "Must implement app on your test case"
|
@@ -16,18 +21,10 @@ module SinatraTestCases
|
|
16
21
|
app.to_s
|
17
22
|
end
|
18
23
|
|
19
|
-
|
20
|
-
$precondition_already_checked = false
|
21
|
-
::NewRelic::Agent.manual_start
|
22
|
-
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
reset
|
26
|
-
end
|
24
|
+
setup_and_teardown_agent
|
27
25
|
|
28
|
-
def
|
29
|
-
|
30
|
-
::NewRelic::Agent.agent.error_collector.harvest_errors([])
|
26
|
+
def after_setup
|
27
|
+
$precondition_already_checked = false
|
31
28
|
end
|
32
29
|
|
33
30
|
# https://support.newrelic.com/tickets/24779
|
@@ -73,9 +70,9 @@ module SinatraTestCases
|
|
73
70
|
get '/route/match'
|
74
71
|
assert_equal 'first route', last_response.body
|
75
72
|
assert_metrics_recorded(["Controller/Sinatra/#{app_name}/GET route/([^/?#]+)"])
|
73
|
+
end
|
76
74
|
|
77
|
-
|
78
|
-
|
75
|
+
def test_finds_second_route
|
79
76
|
get '/route/no_match'
|
80
77
|
assert_equal 'second route', last_response.body
|
81
78
|
assert_metrics_recorded(["Controller/Sinatra/#{app_name}/GET route/no_match"])
|
@@ -11,11 +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
|
@@ -11,7 +11,7 @@ require File.join(File.dirname(__FILE__), "..", "..", "..", "agent_helper")
|
|
11
11
|
|
12
12
|
if NewRelic::Agent::Instrumentation::TyphoeusTracing.is_supported_version?
|
13
13
|
|
14
|
-
class TyphoeusTest <
|
14
|
+
class TyphoeusTest < MiniTest::Unit::TestCase
|
15
15
|
include HttpClientTestCases
|
16
16
|
|
17
17
|
USE_SSL_VERIFYPEER_VERSION = NewRelic::VersionNumber.new("0.5.0")
|
@@ -46,8 +46,11 @@ if NewRelic::Agent::Instrumentation::TyphoeusTracing.is_supported_version?
|
|
46
46
|
NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest.new(Typhoeus::Request.new("http://newrelic.com"))
|
47
47
|
end
|
48
48
|
|
49
|
-
def response_instance
|
50
|
-
headers =
|
49
|
+
def response_instance(headers = {})
|
50
|
+
headers = headers.map do |k,v|
|
51
|
+
"#{k}: #{v}"
|
52
|
+
end.join("\r\n")
|
53
|
+
|
51
54
|
NewRelic::Agent::HTTPClients::TyphoeusHTTPResponse.new(Typhoeus::Response.new(:response_headers => headers))
|
52
55
|
end
|
53
56
|
|
@@ -66,7 +69,7 @@ if NewRelic::Agent::Instrumentation::TyphoeusTracing.is_supported_version?
|
|
66
69
|
|
67
70
|
else
|
68
71
|
|
69
|
-
class TyphoeusNotInstrumented <
|
72
|
+
class TyphoeusNotInstrumented < MiniTest::Unit::TestCase
|
70
73
|
def test_works_without_instrumentation
|
71
74
|
# Typhoeus.get wasn't supported back before 0.5.x
|
72
75
|
Typhoeus::Request.get("http://localhost/not/there")
|
@@ -70,7 +70,7 @@ class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
|
|
70
70
|
def test_log_error
|
71
71
|
error = StandardError.new("message")
|
72
72
|
|
73
|
-
expects_logging(:error,
|
73
|
+
expects_logging(:error,
|
74
74
|
includes("Error establishing connection with New Relic Service"), \
|
75
75
|
instance_of(StandardError))
|
76
76
|
|
@@ -209,16 +209,50 @@ class AgentLoggerTest < Test::Unit::TestCase
|
|
209
209
|
end
|
210
210
|
|
211
211
|
def test_format_message_allows_nil_backtrace
|
212
|
+
config = @config.merge(:log_level => :debug)
|
213
|
+
|
212
214
|
logdev = ArrayLogDevice.new
|
213
215
|
override_logger = Logger.new( logdev )
|
214
|
-
logger = NewRelic::Agent::AgentLogger.new(
|
216
|
+
logger = NewRelic::Agent::AgentLogger.new(config, "", override_logger)
|
215
217
|
|
216
|
-
|
218
|
+
e = Exception.new("Look Ma, no backtrace!")
|
219
|
+
assert_nil(e.backtrace)
|
220
|
+
logger.error(e)
|
217
221
|
|
218
|
-
assert_equal
|
222
|
+
assert_equal 2, logdev.array.length
|
219
223
|
assert_match( /ERROR : Exception: Look Ma, no backtrace!/i, logdev.array[0] )
|
224
|
+
assert_match( /DEBUG : No backtrace available./, logdev.array[1])
|
220
225
|
end
|
221
226
|
|
227
|
+
def test_log_exception_logs_backtrace_at_same_level_as_message_by_default
|
228
|
+
logdev = ArrayLogDevice.new
|
229
|
+
override_logger = Logger.new(logdev)
|
230
|
+
logger = NewRelic::Agent::AgentLogger.new(@config, "", override_logger)
|
231
|
+
|
232
|
+
e = Exception.new("howdy")
|
233
|
+
e.set_backtrace(["wiggle", "wobble", "topple"])
|
234
|
+
|
235
|
+
logger.log_exception(:info, e)
|
236
|
+
|
237
|
+
assert_match(/INFO : Exception: howdy/i, logdev.array[0])
|
238
|
+
assert_match(/INFO : Debugging backtrace:\n.*wiggle\s+wobble\s+topple/,
|
239
|
+
logdev.array[1])
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_log_exception_logs_backtrace_at_explicitly_specified_level
|
243
|
+
logdev = ArrayLogDevice.new
|
244
|
+
override_logger = Logger.new(logdev)
|
245
|
+
logger = NewRelic::Agent::AgentLogger.new(@config, "", override_logger)
|
246
|
+
|
247
|
+
e = Exception.new("howdy")
|
248
|
+
e.set_backtrace(["wiggle", "wobble", "topple"])
|
249
|
+
|
250
|
+
logger.log_exception(:warn, e, :info)
|
251
|
+
|
252
|
+
assert_match(/WARN : Exception: howdy/i, logdev.array[0])
|
253
|
+
assert_match(/INFO : Debugging backtrace:\n.*wiggle\s+wobble\s+topple/,
|
254
|
+
logdev.array[1])
|
255
|
+
end
|
222
256
|
|
223
257
|
def test_logs_to_stdout_if_fails_on_file
|
224
258
|
Logger::LogDevice.any_instance.stubs(:open).raises(Errno::EACCES)
|
@@ -245,7 +245,7 @@ module NewRelic
|
|
245
245
|
|
246
246
|
def test_merge_data_from_abides_by_error_queue_limit
|
247
247
|
errors = []
|
248
|
-
40.times { |i| errors << Exception.new("boo #{i}") }
|
248
|
+
40.times { |i| errors << NewRelic::NoticedError.new("", {}, Exception.new("boo #{i}")) }
|
249
249
|
|
250
250
|
@agent.merge_data_from([{}, [], errors])
|
251
251
|
|
@@ -335,5 +335,27 @@ module NewRelic
|
|
335
335
|
end
|
336
336
|
|
337
337
|
end
|
338
|
+
|
339
|
+
|
340
|
+
class AgentStartingTest < Test::Unit::TestCase
|
341
|
+
def test_no_service_if_not_monitoring
|
342
|
+
with_config(:monitor_mode => false) do
|
343
|
+
agent = NewRelic::Agent::Agent.new
|
344
|
+
assert_nil agent.service
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_abides_by_disabling_harvest_thread
|
349
|
+
with_config(:disable_harvest_thread => true) do
|
350
|
+
threads_before = Thread.list.length
|
351
|
+
|
352
|
+
agent = NewRelic::Agent::Agent.new
|
353
|
+
agent.send(:start_worker_thread)
|
354
|
+
|
355
|
+
assert_equal threads_before, Thread.list.length
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
end
|
338
360
|
end
|
339
361
|
end
|
@@ -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
|
require "new_relic/agent/browser_monitoring"
|
8
7
|
require "new_relic/rack/browser_monitoring"
|
@@ -2,8 +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
|
-
# Run faster standalone
|
6
|
-
ENV['SKIP_RAILS'] = 'true'
|
7
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
8
6
|
class NewRelic::Agent::BusyCalculatorTest < Test::Unit::TestCase
|
9
7
|
attr_reader :now
|
@@ -68,6 +66,8 @@ class NewRelic::Agent::BusyCalculatorTest < Test::Unit::TestCase
|
|
68
66
|
# Get busy for 8 - 2 seconds
|
69
67
|
NewRelic::Agent::BusyCalculator.dispatcher_finish(now - 2.0)
|
70
68
|
worker.join
|
69
|
+
|
70
|
+
NewRelic::Agent::BusyCalculator.stubs(:time_now).returns(now - 1.0)
|
71
71
|
NewRelic::Agent::BusyCalculator.harvest_busy
|
72
72
|
|
73
73
|
assert_equal 1, @instance_busy.call_count
|
@@ -56,6 +56,28 @@ module NewRelic::Agent::Configuration
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
%w| NEWRELIC_DISABLE_HARVEST_THREAD NEW_RELIC_DISABLE_HARVEST_THREAD |.each do |var|
|
60
|
+
define_method("test_environment_booleans_truths_are_applied_to_#{var}") do
|
61
|
+
ENV[var] = 'true'
|
62
|
+
assert EnvironmentSource.new[:disable_harvest_thread]
|
63
|
+
ENV[var] = 'on'
|
64
|
+
assert EnvironmentSource.new[:disable_harvest_thread]
|
65
|
+
ENV[var] = 'yes'
|
66
|
+
assert EnvironmentSource.new[:disable_harvest_thread]
|
67
|
+
ENV.delete(var)
|
68
|
+
end
|
69
|
+
|
70
|
+
define_method("test_environment_booleans_falsehoods_are_applied_to_#{var}") do
|
71
|
+
ENV[var] = 'false'
|
72
|
+
assert !EnvironmentSource.new[:disable_harvest_thread]
|
73
|
+
ENV[var] = 'off'
|
74
|
+
assert !EnvironmentSource.new[:disable_harvest_thread]
|
75
|
+
ENV[var] = 'no'
|
76
|
+
assert !EnvironmentSource.new[:disable_harvest_thread]
|
77
|
+
ENV.delete(var)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
59
81
|
def test_set_log_config_from_environment
|
60
82
|
ENV['NEW_RELIC_LOG'] = 'off/in/space.log'
|
61
83
|
source = EnvironmentSource.new
|
@@ -129,7 +129,7 @@ class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Test::Unit::TestCase
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def test_over_queue_limit_positive
|
132
|
-
@errors =
|
132
|
+
@errors = (1..21).map{|_| NewRelic::NoticedError.new("", {}, nil)}
|
133
133
|
expects_logging(:warn, includes('The error reporting queue has reached 20'))
|
134
134
|
assert over_queue_limit?('hooray')
|
135
135
|
end
|
@@ -2,9 +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
|
-
# Run faster standalone
|
6
|
-
ENV['SKIP_RAILS'] = 'true'
|
7
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
|
+
require 'new_relic/agent/internal_agent_error'
|
8
7
|
|
9
8
|
class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
10
9
|
def setup
|
@@ -13,6 +12,8 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
13
12
|
NewRelic::Agent.config.apply_config(@test_config)
|
14
13
|
@error_collector = NewRelic::Agent::ErrorCollector.new
|
15
14
|
@error_collector.stubs(:enabled).returns(true)
|
15
|
+
|
16
|
+
NewRelic::Agent.instance.stats_engine.reset_stats
|
16
17
|
end
|
17
18
|
|
18
19
|
def teardown
|
@@ -197,26 +198,107 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
197
198
|
end
|
198
199
|
|
199
200
|
def test_increment_error_count_record_summary_and_txn_metric
|
200
|
-
stats_engine = NewRelic::Agent.instance.stats_engine
|
201
|
-
stats_engine.reset_stats
|
202
|
-
|
203
201
|
@error_collector.increment_error_count!(StandardError.new('Boo'),
|
204
202
|
:metric => 'Controller/class/method')
|
205
203
|
|
206
|
-
|
207
|
-
'Missing Errors/all metric')
|
208
|
-
assert_equal(1, stats_engine.get_stats('Errors/Controller/class/method').call_count,
|
209
|
-
'Missing Errors/Controller/class/method metric')
|
204
|
+
assert_metrics_recorded(['Errors/all', 'Errors/Controller/class/method'])
|
210
205
|
end
|
211
206
|
|
212
207
|
def test_doesnt_increment_error_count_on_transaction_if_nameless
|
213
|
-
stats_engine = NewRelic::Agent.instance.stats_engine
|
214
|
-
stats_engine.reset_stats
|
215
|
-
|
216
208
|
@error_collector.increment_error_count!(StandardError.new('Boo'),
|
217
209
|
:metric => '(unknown)')
|
218
210
|
|
219
|
-
|
211
|
+
assert_metrics_not_recorded(['Errors/(unknown)'])
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
class DifficultToDebugAgentError < NewRelic::Agent::InternalAgentError
|
216
|
+
end
|
217
|
+
|
218
|
+
class AnotherToughAgentError < NewRelic::Agent::InternalAgentError
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_notices_agent_error
|
222
|
+
@error_collector.notice_agent_error(DifficultToDebugAgentError.new)
|
223
|
+
assert_equal 1, @error_collector.errors.size
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_only_notices_agent_error_per_type
|
227
|
+
@error_collector.notice_agent_error(DifficultToDebugAgentError.new)
|
228
|
+
@error_collector.notice_agent_error(DifficultToDebugAgentError.new)
|
229
|
+
|
230
|
+
assert_equal 1, @error_collector.errors.size
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_only_notices_agent_error_per_type_allows_other_types
|
234
|
+
@error_collector.notice_agent_error(DifficultToDebugAgentError.new)
|
235
|
+
@error_collector.notice_agent_error(DifficultToDebugAgentError.new)
|
236
|
+
@error_collector.notice_agent_error(AnotherToughAgentError.new)
|
237
|
+
|
238
|
+
assert_equal 2, @error_collector.errors.size
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_does_not_touch_error_metrics
|
242
|
+
@error_collector.notice_agent_error(DifficultToDebugAgentError.new)
|
243
|
+
@error_collector.notice_agent_error(DifficultToDebugAgentError.new)
|
244
|
+
@error_collector.notice_agent_error(AnotherToughAgentError.new)
|
245
|
+
|
246
|
+
assert_metrics_recorded_exclusive([])
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_notice_agent_error_set_noticed_error_attributes
|
250
|
+
@error_collector.notice_agent_error(DifficultToDebugAgentError.new)
|
251
|
+
|
252
|
+
err = @error_collector.errors.first
|
253
|
+
assert_equal "NewRelic/AgentError", err.path
|
254
|
+
assert_kind_of Hash, err.params
|
255
|
+
assert_not_nil err.params[:stack_trace]
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_notice_agent_error_uses_exception_backtrace_if_present
|
259
|
+
trace = ["boo", "yeah", "error"]
|
260
|
+
exception = DifficultToDebugAgentError.new
|
261
|
+
exception.set_backtrace(trace)
|
262
|
+
@error_collector.notice_agent_error(exception)
|
263
|
+
|
264
|
+
assert_equal trace, @error_collector.errors.first.params[:stack_trace]
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_notice_agent_error_uses_caller_if_no_exception_backtrace
|
268
|
+
exception = DifficultToDebugAgentError.new
|
269
|
+
exception.set_backtrace(nil)
|
270
|
+
@error_collector.notice_agent_error(exception)
|
271
|
+
|
272
|
+
trace = @error_collector.errors.first.params[:stack_trace]
|
273
|
+
assert trace.any? {|line| line.include?(__FILE__)}
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_notice_agent_error_allows_an_error_past_queue_limit
|
277
|
+
100.times { @error_collector.notice_error(StandardError.new("Ouch")) }
|
278
|
+
|
279
|
+
exception = DifficultToDebugAgentError.new
|
280
|
+
@error_collector.notice_agent_error(exception)
|
281
|
+
|
282
|
+
assert_equal 21, @error_collector.errors.size
|
283
|
+
assert_equal DifficultToDebugAgentError, @error_collector.errors.last.exception_class_constant
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_notice_agent_error_doesnt_clog_up_the_queue_limit
|
287
|
+
exception = DifficultToDebugAgentError.new
|
288
|
+
@error_collector.notice_agent_error(exception)
|
289
|
+
|
290
|
+
100.times { @error_collector.notice_error(StandardError.new("Ouch")) }
|
291
|
+
|
292
|
+
assert_equal 21, @error_collector.errors.size
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_notice_agent_error_adds_support_message
|
296
|
+
exception = DifficultToDebugAgentError.new("BOO")
|
297
|
+
@error_collector.notice_agent_error(exception)
|
298
|
+
|
299
|
+
err = @error_collector.errors.first
|
300
|
+
assert err.message.include?(exception.message)
|
301
|
+
assert err.message.include?("Ruby agent internal error")
|
220
302
|
end
|
221
303
|
|
222
304
|
private
|