newrelic_rpm 3.6.8.168 → 3.6.9.171
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.yardopts +17 -0
- data/CHANGELOG +48 -0
- data/README.md +8 -6
- data/lib/new_relic/agent.rb +65 -17
- data/lib/new_relic/agent/agent.rb +42 -113
- data/lib/new_relic/agent/browser_monitoring.rb +9 -1
- data/lib/new_relic/agent/configuration/default_source.rb +12 -0
- data/lib/new_relic/agent/error_collector.rb +13 -6
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +5 -5
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +15 -0
- data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rack.rb +2 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +9 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -0
- data/lib/new_relic/agent/method_tracer.rb +45 -27
- data/lib/new_relic/agent/new_relic_service.rb +14 -6
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/request_sampler.rb +10 -7
- data/lib/new_relic/agent/rules_engine.rb +5 -0
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
- data/lib/new_relic/agent/sql_sampler.rb +4 -2
- data/lib/new_relic/agent/stats_engine.rb +3 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +17 -7
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +5 -7
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +2 -0
- data/lib/new_relic/agent/supported_versions.rb +247 -0
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
- data/lib/new_relic/agent/threading/thread_profile.rb +2 -1
- data/lib/new_relic/agent/transaction.rb +7 -6
- data/lib/new_relic/agent/transaction/developer_mode_sample_buffer.rb +11 -5
- data/lib/new_relic/agent/transaction/force_persist_sample_buffer.rb +3 -3
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +3 -3
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +23 -4
- data/lib/new_relic/agent/transaction/xray_sample_buffer.rb +4 -4
- data/lib/new_relic/agent/transaction_sampler.rb +14 -18
- data/lib/new_relic/agent/worker_loop.rb +1 -0
- data/lib/new_relic/control.rb +1 -0
- data/lib/new_relic/control/instance_methods.rb +0 -1
- data/lib/new_relic/helper.rb +1 -2
- data/lib/new_relic/language_support.rb +12 -2
- data/lib/new_relic/local_environment.rb +12 -11
- data/lib/new_relic/rack.rb +9 -0
- data/lib/new_relic/rack/agent_hooks.rb +6 -0
- data/lib/new_relic/rack/browser_monitoring.rb +9 -2
- data/lib/new_relic/rack/developer_mode.rb +15 -1
- data/lib/new_relic/rack/error_collector.rb +7 -0
- data/lib/new_relic/recipes.rb +2 -0
- data/lib/new_relic/transaction_sample.rb +39 -48
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/install.rake +44 -2
- data/lib/tasks/versions.html.erb +31 -0
- data/lib/tasks/versions.rake +52 -0
- data/lib/tasks/versions.txt.erb +14 -0
- data/newrelic_rpm.gemspec +4 -2
- data/test/agent_helper.rb +21 -1
- data/test/environments/lib/environments/runner.rb +19 -5
- data/test/environments/norails/Gemfile +4 -1
- data/test/environments/rails21/Gemfile +4 -6
- data/test/environments/rails21/Rakefile +4 -0
- data/test/environments/rails21/config/database.yml +2 -7
- data/test/environments/rails22/Gemfile +6 -13
- data/test/environments/rails22/Rakefile +4 -0
- data/test/environments/rails22/config/database.yml +2 -7
- data/test/environments/rails22/config/environment.rb +1 -1
- data/test/environments/rails23/Gemfile +3 -4
- data/test/environments/rails23/Rakefile +4 -0
- data/test/environments/rails23/config/database.yml +2 -7
- data/test/environments/rails30/Gemfile +2 -4
- data/test/environments/rails30/Rakefile +2 -0
- data/test/environments/rails30/config/database.yml +2 -7
- data/test/environments/rails31/Gemfile +2 -4
- data/test/environments/rails31/Rakefile +2 -0
- data/test/environments/rails31/config/database.yml +2 -7
- data/test/environments/rails32/Gemfile +2 -5
- data/test/environments/rails32/Rakefile +2 -0
- data/test/environments/rails32/config/database.yml +1 -1
- data/test/environments/rails40/Gemfile +7 -4
- data/test/environments/rails40/Rakefile +2 -0
- data/test/environments/rails40/config/database.yml +2 -7
- data/test/helpers/runtime_detection.rb +17 -0
- data/test/multiverse/lib/multiverse/suite.rb +20 -4
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +1 -1
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +32 -7
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +1 -0
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +4 -3
- data/test/multiverse/suites/curb/curb_test.rb +8 -0
- data/test/multiverse/suites/excon/excon_test.rb +8 -0
- data/test/multiverse/suites/httpclient/httpclient_test.rb +8 -0
- data/test/multiverse/suites/net_http/net_http_test.rb +8 -0
- data/test/multiverse/suites/padrino/Envfile +3 -2
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +17 -8
- data/test/multiverse/suites/resque/Envfile +3 -3
- data/test/multiverse/suites/resque/instrumentation_test.rb +47 -5
- data/test/multiverse/suites/sequel/Envfile +0 -3
- data/test/multiverse/suites/sequel/database.rb +53 -0
- data/test/{new_relic/agent/instrumentation/sequel_test.rb → multiverse/suites/sequel/sequel_instrumentation_test.rb} +12 -53
- data/test/multiverse/suites/sequel/{sequel_test.rb → sequel_safety_test.rb} +2 -17
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +50 -5
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +15 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +8 -0
- data/test/new_relic/agent/agent/connect_test.rb +3 -2
- data/test/new_relic/agent/agent_test.rb +89 -82
- data/test/new_relic/agent/browser_monitoring_test.rb +44 -1
- data/test/new_relic/agent/error_collector_test.rb +17 -20
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +13 -10
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +16 -1
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
- data/test/new_relic/agent/new_relic_service_test.rb +78 -9
- data/test/new_relic/agent/pipe_channel_manager_test.rb +7 -9
- data/test/new_relic/agent/pipe_service_test.rb +4 -4
- data/test/new_relic/agent/request_sampler_test.rb +2 -2
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +15 -35
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +15 -7
- data/test/new_relic/agent/stats_engine_test.rb +4 -3
- data/test/new_relic/agent/threading/backtrace_service_test.rb +2 -0
- data/test/new_relic/agent/threading/thread_profile_test.rb +19 -0
- data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +4 -4
- data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction_sampler_test.rb +60 -45
- data/test/new_relic/fake_collector.rb +37 -2
- data/test/new_relic/http_client_test_cases.rb +26 -1
- data/test/new_relic/language_support_test.rb +12 -31
- data/test/new_relic/local_environment_test.rb +6 -2
- data/test/new_relic/multiverse_helpers.rb +2 -5
- data/test/new_relic/transaction_sample_test.rb +57 -36
- data/test/performance/suites/config.rb +76 -0
- data/test/rum/no_html_and_no_header.result.html +3 -0
- data/test/rum/no_html_and_no_header.source.html +3 -0
- data/test/script/ci.sh +0 -2
- data/test/test_helper.rb +5 -0
- metadata +43 -26
- metadata.gz.sig +0 -0
@@ -38,7 +38,10 @@ module HttpClientTestCases
|
|
38
38
|
NewRelic::Agent.instance.events.notify(:finished_configuring)
|
39
39
|
|
40
40
|
@nr_header = nil
|
41
|
-
|
41
|
+
# Don't use destructuring on result array with ignores since it fails
|
42
|
+
# on Rubinius: https://github.com/rubinius/rubinius/issues/2678
|
43
|
+
NewRelic::Agent.instance.events.subscribe(:after_call) do |_, result|
|
44
|
+
headers = result[1]
|
42
45
|
headers[ NR_APPDATA_HEADER ] = @nr_header unless @nr_header.nil?
|
43
46
|
end
|
44
47
|
|
@@ -258,6 +261,28 @@ module HttpClientTestCases
|
|
258
261
|
])
|
259
262
|
end
|
260
263
|
|
264
|
+
def test_put
|
265
|
+
put_response
|
266
|
+
|
267
|
+
assert_metrics_recorded([
|
268
|
+
"External/all",
|
269
|
+
"External/localhost/#{client_name}/PUT",
|
270
|
+
"External/allOther",
|
271
|
+
"External/localhost/all"
|
272
|
+
])
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_delete
|
276
|
+
delete_response
|
277
|
+
|
278
|
+
assert_metrics_recorded([
|
279
|
+
"External/all",
|
280
|
+
"External/localhost/#{client_name}/DELETE",
|
281
|
+
"External/allOther",
|
282
|
+
"External/localhost/all"
|
283
|
+
])
|
284
|
+
end
|
285
|
+
|
261
286
|
# When an http call is made, the agent should add a request header named
|
262
287
|
# X-NewRelic-ID with a value equal to the encoded cross_app_id.
|
263
288
|
|
@@ -5,41 +5,22 @@
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
6
6
|
|
7
7
|
class NewRelic::LanguageSupportTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
undefine_constant(:JRuby) do
|
10
|
-
define_constant(:ObjectSpace, mock()) do
|
11
|
-
assert_truthy NewRelic::LanguageSupport.object_space_enabled?
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
8
|
+
include ::NewRelic::TestHelpers::RuntimeDetection
|
15
9
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
10
|
+
def test_object_space_usable_on_jruby_with_object_space_enabled
|
11
|
+
return unless jruby?
|
12
|
+
JRuby.objectspace = true
|
13
|
+
assert_truthy NewRelic::LanguageSupport.object_space_usable?
|
22
14
|
end
|
23
15
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
define_constant(:JRuby, fake_jruby) do
|
29
|
-
undefine_constant(:ObjectSpace) do
|
30
|
-
assert_truthy NewRelic::LanguageSupport.object_space_enabled?
|
31
|
-
end
|
32
|
-
end
|
16
|
+
def test_object_space_not_usable_on_jruby_with_object_space_disabled
|
17
|
+
return unless jruby?
|
18
|
+
JRuby.objectspace = false
|
19
|
+
assert_falsy NewRelic::LanguageSupport.object_space_usable?
|
33
20
|
end
|
34
21
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
define_constant(:JRuby, fake_jruby) do
|
40
|
-
undefine_constant(:ObjectSpace) do
|
41
|
-
assert_falsy NewRelic::LanguageSupport.object_space_enabled?
|
42
|
-
end
|
43
|
-
end
|
22
|
+
def test_object_space_not_usable_on_rubinius
|
23
|
+
return unless rubinius?
|
24
|
+
assert_falsy NewRelic::LanguageSupport.object_space_usable?
|
44
25
|
end
|
45
26
|
end
|
@@ -40,6 +40,8 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
|
|
40
40
|
# around that interaction, so we don't run them on JRuby.
|
41
41
|
unless defined?(JRuby)
|
42
42
|
def test_mongrel_only_checks_once
|
43
|
+
return unless NewRelic::LanguageSupport.object_space_usable?
|
44
|
+
|
43
45
|
define_mongrel
|
44
46
|
|
45
47
|
# One call from LocalEnvironment's initialize, second from first #mongrel call.
|
@@ -50,10 +52,12 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
|
|
50
52
|
5.times { e.mongrel }
|
51
53
|
assert_nil e.mongrel
|
52
54
|
ensure
|
53
|
-
Object.send(:remove_const, :Mongrel)
|
55
|
+
Object.send(:remove_const, :Mongrel) if defined?(Mongrel)
|
54
56
|
end
|
55
57
|
|
56
58
|
def test_check_for_mongrel_allows_one_more_check
|
59
|
+
return unless NewRelic::LanguageSupport.object_space_usable?
|
60
|
+
|
57
61
|
define_mongrel
|
58
62
|
|
59
63
|
ObjectSpace.expects(:each_object).with(::Mongrel::HttpServer).at_least(2)
|
@@ -61,7 +65,7 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
|
|
61
65
|
e = NewRelic::LocalEnvironment.new
|
62
66
|
e.send(:check_for_mongrel)
|
63
67
|
ensure
|
64
|
-
Object.send(:remove_const, :Mongrel)
|
68
|
+
Object.send(:remove_const, :Mongrel) if defined?(Mongrel)
|
65
69
|
end
|
66
70
|
end
|
67
71
|
|
@@ -53,18 +53,15 @@ module MultiverseHelpers
|
|
53
53
|
|
54
54
|
# Renaming rules don't get cleared on connect--only appended to
|
55
55
|
NewRelic::Agent.instance.transaction_rules.rules.clear
|
56
|
-
NewRelic::Agent.instance.metric_rules.rules.clear
|
56
|
+
NewRelic::Agent.instance.stats_engine.metric_rules.rules.clear
|
57
57
|
|
58
58
|
# Clear out lingering stats we didn't transmit
|
59
59
|
NewRelic::Agent.instance.reset_stats
|
60
60
|
|
61
61
|
# Clear out lingering errors in the collector
|
62
|
-
NewRelic::Agent.instance.error_collector.harvest_errors
|
62
|
+
NewRelic::Agent.instance.error_collector.harvest_errors
|
63
63
|
NewRelic::Agent.instance.error_collector.instance_variable_set(:@ignore_filter, nil)
|
64
64
|
|
65
|
-
# Clear out the request sampler!
|
66
|
-
NewRelic::Agent.instance.instance_variable_get(:@request_sampler).reset
|
67
|
-
|
68
65
|
# Clean up any thread-local variables starting with 'newrelic'
|
69
66
|
Thread.current.keys.select { |k| k.to_s =~ /^newrelic/i }.each do |key|
|
70
67
|
Thread.current[key] = nil
|
@@ -6,7 +6,8 @@ require File.expand_path('../../test_helper.rb', __FILE__)
|
|
6
6
|
|
7
7
|
class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
8
8
|
include TransactionSampleTestHelper
|
9
|
-
::SQL_STATEMENT = "SELECT * from sandwiches"
|
9
|
+
::SQL_STATEMENT = "SELECT * from sandwiches WHERE meat='bacon'"
|
10
|
+
::OBFUSCATED_SQL_STATEMENT = "SELECT * from sandwiches WHERE meat=?"
|
10
11
|
|
11
12
|
def setup
|
12
13
|
@test_config = { :developer_mode => true }
|
@@ -32,38 +33,39 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
32
33
|
assert_not_nil @t
|
33
34
|
end
|
34
35
|
|
35
|
-
def
|
36
|
-
s = @t.prepare_to_send(:explain_sql => 0.00000001)
|
36
|
+
def test_prepare_to_send_strips_sql_if_record_sql_omitted
|
37
|
+
s = @t.prepare_to_send!(:explain_sql => 0.00000001)
|
38
|
+
|
37
39
|
s.each_segment do |segment|
|
38
40
|
assert_nil segment.params[:explain_plan]
|
39
41
|
assert_nil segment.params[:sql]
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
|
-
def
|
44
|
-
s = @t.prepare_to_send(:
|
45
|
-
|
45
|
+
def test_prepare_to_send_preserves_raw_sql_if_record_sql_set_to_raw
|
46
|
+
s = @t.prepare_to_send!(:record_sql => :raw)
|
47
|
+
|
48
|
+
sql_statements = []
|
46
49
|
s.each_segment do |segment|
|
47
|
-
|
48
|
-
got_one = got_one || segment.params[:explain_plan] || segment.params[:sql]
|
50
|
+
sql_statements << segment.params[:sql] if segment.params[:sql]
|
49
51
|
end
|
50
|
-
assert got_one
|
51
|
-
end
|
52
52
|
|
53
|
-
|
53
|
+
assert_equal([::SQL_STATEMENT], sql_statements)
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
+
def test_prepare_to_send_obfuscates_sql_if_record_sql_set_to_obfuscated
|
57
|
+
s = @t.prepare_to_send!(:record_sql => :obfuscated)
|
56
58
|
|
57
|
-
|
59
|
+
sql_statements = []
|
58
60
|
s.each_segment do |segment|
|
59
|
-
|
61
|
+
sql_statements << segment.params[:sql] if segment.params[:sql]
|
60
62
|
end
|
61
63
|
|
62
|
-
|
64
|
+
assert_equal([::OBFUSCATED_SQL_STATEMENT], sql_statements)
|
63
65
|
end
|
64
66
|
|
65
67
|
def test_have_sql_rows_when_sql_is_recorded
|
66
|
-
s = @t.prepare_to_send(:explain_sql => 0.00000001)
|
68
|
+
s = @t.prepare_to_send!(:explain_sql => 0.00000001)
|
67
69
|
|
68
70
|
assert s.sql_segments.empty?
|
69
71
|
s.root_segment[:sql] = 'hello'
|
@@ -71,7 +73,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def test_have_sql_rows_when_sql_is_obfuscated
|
74
|
-
s = @t.prepare_to_send(:explain_sql => 0.00000001)
|
76
|
+
s = @t.prepare_to_send!(:explain_sql => 0.00000001)
|
75
77
|
|
76
78
|
assert s.sql_segments.empty?
|
77
79
|
s.root_segment[:sql_obfuscated] = 'hello'
|
@@ -79,7 +81,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
79
81
|
end
|
80
82
|
|
81
83
|
def test_have_sql_rows_when_recording_non_sql_keys
|
82
|
-
s = @t.prepare_to_send(:explain_sql => 0.00000001)
|
84
|
+
s = @t.prepare_to_send!(:explain_sql => 0.00000001)
|
83
85
|
|
84
86
|
assert s.sql_segments.empty?
|
85
87
|
s.root_segment[:key] = 'hello'
|
@@ -89,11 +91,11 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
89
91
|
def test_catch_exceptions
|
90
92
|
@connection_stub.expects(:execute).raises
|
91
93
|
# the sql connection will throw
|
92
|
-
@t.prepare_to_send(:record_sql => :obfuscated, :explain_sql => 0.00000001)
|
94
|
+
@t.prepare_to_send!(:record_sql => :obfuscated, :explain_sql => 0.00000001)
|
93
95
|
end
|
94
96
|
|
95
97
|
def test_have_explains
|
96
|
-
s = @t.prepare_to_send(:record_sql => :obfuscated, :explain_sql => 0.00000001)
|
98
|
+
s = @t.prepare_to_send!(:record_sql => :obfuscated, :explain_sql => 0.00000001)
|
97
99
|
|
98
100
|
s.each_segment do |segment|
|
99
101
|
if segment.params[:explain_plan]
|
@@ -111,7 +113,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
111
113
|
t = make_sql_transaction(::SQL_STATEMENT, ::SQL_STATEMENT)
|
112
114
|
end
|
113
115
|
|
114
|
-
s = t.prepare_to_send(:explain_sql => 0.00000001)
|
116
|
+
s = t.prepare_to_send!(:explain_sql => 0.00000001)
|
115
117
|
|
116
118
|
s.each_segment do |segment|
|
117
119
|
assert_nil segment.params[:explain_plan]
|
@@ -127,7 +129,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
127
129
|
end
|
128
130
|
|
129
131
|
def test_path_string
|
130
|
-
s = @t.prepare_to_send(:explain_sql => 0.1)
|
132
|
+
s = @t.prepare_to_send!(:explain_sql => 0.1)
|
131
133
|
fake_segment = mock('segment')
|
132
134
|
fake_segment.expects(:path_string).returns('a path string')
|
133
135
|
s.instance_eval do
|
@@ -138,7 +140,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
138
140
|
end
|
139
141
|
|
140
142
|
def test_params_equals
|
141
|
-
s = @t.prepare_to_send(:explain_sql => 0.1)
|
143
|
+
s = @t.prepare_to_send!(:explain_sql => 0.1)
|
142
144
|
s.params = {:params => 'hash' }
|
143
145
|
assert_equal({:params => 'hash'}, s.params, "should have the specified hash, but instead was #{s.params}")
|
144
146
|
end
|
@@ -148,7 +150,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
148
150
|
end
|
149
151
|
|
150
152
|
def test_to_s_with_bad_object
|
151
|
-
s = @t.prepare_to_send(:explain_sql => 0.1)
|
153
|
+
s = @t.prepare_to_send!(:explain_sql => 0.1)
|
152
154
|
s.params[:fake] = Hat.new
|
153
155
|
assert_raise(RuntimeError) do
|
154
156
|
s.to_s
|
@@ -156,14 +158,14 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
156
158
|
end
|
157
159
|
|
158
160
|
def test_to_s_includes_keys
|
159
|
-
s = @t.prepare_to_send(:explain_sql => 0.1)
|
161
|
+
s = @t.prepare_to_send!(:explain_sql => 0.1)
|
160
162
|
s.params[:fake_key] = 'a fake param'
|
161
163
|
assert(s.to_s.include?('fake_key'), "should include 'fake_key' but instead was (#{s.to_s})")
|
162
164
|
assert(s.to_s.include?('a fake param'), "should include 'a fake param' but instead was (#{s.to_s})")
|
163
165
|
end
|
164
166
|
|
165
167
|
def test_find_segment
|
166
|
-
s = @t.prepare_to_send(:explain_sql => 0.1)
|
168
|
+
s = @t.prepare_to_send!(:explain_sql => 0.1)
|
167
169
|
fake_segment = mock('segment')
|
168
170
|
fake_segment.expects(:find_segment).with(1).returns('a segment')
|
169
171
|
s.instance_eval do
|
@@ -174,23 +176,38 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
174
176
|
end
|
175
177
|
|
176
178
|
def test_timestamp
|
177
|
-
s = @t.prepare_to_send(:explain_sql => 0.1)
|
179
|
+
s = @t.prepare_to_send!(:explain_sql => 0.1)
|
178
180
|
assert(s.timestamp.instance_of?(Float), "s.timestamp should be a Float, but is #{s.timestamp.class.inspect}")
|
179
181
|
end
|
180
182
|
|
181
183
|
def test_xray_session_id
|
182
184
|
@t.xray_session_id = 123
|
183
|
-
s = @t.prepare_to_send
|
185
|
+
s = @t.prepare_to_send!
|
184
186
|
assert_equal(123, s.xray_session_id)
|
185
187
|
end
|
186
188
|
|
187
|
-
def
|
189
|
+
def test_prepare_to_send_marks_returned_sample_as_prepared
|
190
|
+
assert(!@t.prepared?)
|
191
|
+
prepared_sample = @t.prepare_to_send!
|
192
|
+
assert(prepared_sample.prepared?)
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_prepare_to_send_does_not_re_prepare
|
196
|
+
opts = { :record_sql => :raw, :explain_sql => 0.00001 }
|
197
|
+
@t.prepare_to_send!(opts)
|
198
|
+
|
199
|
+
@t.expects(:collect_explain_plans!).never
|
200
|
+
@t.expects(:prepare_sql_for_transmission!).never
|
201
|
+
|
202
|
+
@t.prepare_to_send!(opts)
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_threshold_preserved_by_prepare_to_send
|
188
206
|
@t.threshold = 4.2
|
189
|
-
s = @t.prepare_to_send
|
207
|
+
s = @t.prepare_to_send!
|
190
208
|
assert_equal(4.2, s.threshold)
|
191
209
|
end
|
192
210
|
|
193
|
-
|
194
211
|
def test_count_segments
|
195
212
|
transaction = run_sample_trace_on(NewRelic::Agent::TransactionSampler.new) do |sampler|
|
196
213
|
sampler.notice_push_scope "level0"
|
@@ -205,11 +222,15 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
205
222
|
end
|
206
223
|
|
207
224
|
def test_to_array
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
225
|
+
# Round-trip through Time.at makes minor rounding diffs in Rubinius
|
226
|
+
# Check each element separately so we can reconcile the delta
|
227
|
+
result = @t.to_array
|
228
|
+
assert_equal 4, result.length
|
229
|
+
|
230
|
+
assert_in_delta(@t.start_time.to_f, result[0], 0.000001)
|
231
|
+
assert_equal @t.params[:request_params], result[1]
|
232
|
+
assert_equal @t.params[:custom_params], result[2]
|
233
|
+
assert_equal @t.root_segment.to_array, result[3]
|
213
234
|
end
|
214
235
|
|
215
236
|
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
class ConfigPerfTests < Performance::TestCase
|
6
|
+
def setup
|
7
|
+
@config = NewRelic::Agent::Configuration::Manager.new
|
8
|
+
@config.apply_config(:my_value => "boo")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_raw_access
|
12
|
+
iterations.times do
|
13
|
+
v = @config[:my_value]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_defaulting_access
|
18
|
+
iterations.times do
|
19
|
+
v = @config[:log_level]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_missing_key
|
24
|
+
iterations.times do
|
25
|
+
v = @config[:nope]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_blowing_cache
|
30
|
+
iterations.times do
|
31
|
+
@config.reset_cache
|
32
|
+
v = @config[:my_value]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_deep_config_stack_raw_access(timer)
|
37
|
+
with_deep_config_stack
|
38
|
+
|
39
|
+
timer.measure do
|
40
|
+
iterations.times do
|
41
|
+
v = @config[:my_value]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_deep_config_stack_defaulting_access(timer)
|
47
|
+
with_deep_config_stack
|
48
|
+
|
49
|
+
timer.measure do
|
50
|
+
iterations.times do
|
51
|
+
v = @config[:log_level]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_deep_config_stack_across_all_levels(timer)
|
57
|
+
keys = with_deep_config_stack
|
58
|
+
|
59
|
+
timer.measure do
|
60
|
+
iterations.times do
|
61
|
+
keys.each do |key|
|
62
|
+
v = @config[key]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
def with_deep_config_stack
|
70
|
+
keys = (0..100).map {|i| "my_value_#{i}".to_sym}
|
71
|
+
keys.each do |key|
|
72
|
+
@config.apply_config(key => key)
|
73
|
+
end
|
74
|
+
keys
|
75
|
+
end
|
76
|
+
end
|