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.
Files changed (137) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.gitignore +1 -0
  3. data/.yardopts +17 -0
  4. data/CHANGELOG +48 -0
  5. data/README.md +8 -6
  6. data/lib/new_relic/agent.rb +65 -17
  7. data/lib/new_relic/agent/agent.rb +42 -113
  8. data/lib/new_relic/agent/browser_monitoring.rb +9 -1
  9. data/lib/new_relic/agent/configuration/default_source.rb +12 -0
  10. data/lib/new_relic/agent/error_collector.rb +13 -6
  11. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +5 -5
  12. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +15 -0
  13. data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
  14. data/lib/new_relic/agent/instrumentation/metric_frame.rb +2 -2
  15. data/lib/new_relic/agent/instrumentation/rack.rb +2 -0
  16. data/lib/new_relic/agent/instrumentation/resque.rb +9 -3
  17. data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -0
  18. data/lib/new_relic/agent/method_tracer.rb +45 -27
  19. data/lib/new_relic/agent/new_relic_service.rb +14 -6
  20. data/lib/new_relic/agent/pipe_service.rb +1 -1
  21. data/lib/new_relic/agent/request_sampler.rb +10 -7
  22. data/lib/new_relic/agent/rules_engine.rb +5 -0
  23. data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
  24. data/lib/new_relic/agent/sql_sampler.rb +4 -2
  25. data/lib/new_relic/agent/stats_engine.rb +3 -0
  26. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +17 -7
  27. data/lib/new_relic/agent/stats_engine/metric_stats.rb +5 -7
  28. data/lib/new_relic/agent/stats_engine/stats_hash.rb +2 -0
  29. data/lib/new_relic/agent/supported_versions.rb +247 -0
  30. data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
  31. data/lib/new_relic/agent/threading/thread_profile.rb +2 -1
  32. data/lib/new_relic/agent/transaction.rb +7 -6
  33. data/lib/new_relic/agent/transaction/developer_mode_sample_buffer.rb +11 -5
  34. data/lib/new_relic/agent/transaction/force_persist_sample_buffer.rb +3 -3
  35. data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +3 -3
  36. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +23 -4
  37. data/lib/new_relic/agent/transaction/xray_sample_buffer.rb +4 -4
  38. data/lib/new_relic/agent/transaction_sampler.rb +14 -18
  39. data/lib/new_relic/agent/worker_loop.rb +1 -0
  40. data/lib/new_relic/control.rb +1 -0
  41. data/lib/new_relic/control/instance_methods.rb +0 -1
  42. data/lib/new_relic/helper.rb +1 -2
  43. data/lib/new_relic/language_support.rb +12 -2
  44. data/lib/new_relic/local_environment.rb +12 -11
  45. data/lib/new_relic/rack.rb +9 -0
  46. data/lib/new_relic/rack/agent_hooks.rb +6 -0
  47. data/lib/new_relic/rack/browser_monitoring.rb +9 -2
  48. data/lib/new_relic/rack/developer_mode.rb +15 -1
  49. data/lib/new_relic/rack/error_collector.rb +7 -0
  50. data/lib/new_relic/recipes.rb +2 -0
  51. data/lib/new_relic/transaction_sample.rb +39 -48
  52. data/lib/new_relic/version.rb +1 -1
  53. data/lib/tasks/install.rake +44 -2
  54. data/lib/tasks/versions.html.erb +31 -0
  55. data/lib/tasks/versions.rake +52 -0
  56. data/lib/tasks/versions.txt.erb +14 -0
  57. data/newrelic_rpm.gemspec +4 -2
  58. data/test/agent_helper.rb +21 -1
  59. data/test/environments/lib/environments/runner.rb +19 -5
  60. data/test/environments/norails/Gemfile +4 -1
  61. data/test/environments/rails21/Gemfile +4 -6
  62. data/test/environments/rails21/Rakefile +4 -0
  63. data/test/environments/rails21/config/database.yml +2 -7
  64. data/test/environments/rails22/Gemfile +6 -13
  65. data/test/environments/rails22/Rakefile +4 -0
  66. data/test/environments/rails22/config/database.yml +2 -7
  67. data/test/environments/rails22/config/environment.rb +1 -1
  68. data/test/environments/rails23/Gemfile +3 -4
  69. data/test/environments/rails23/Rakefile +4 -0
  70. data/test/environments/rails23/config/database.yml +2 -7
  71. data/test/environments/rails30/Gemfile +2 -4
  72. data/test/environments/rails30/Rakefile +2 -0
  73. data/test/environments/rails30/config/database.yml +2 -7
  74. data/test/environments/rails31/Gemfile +2 -4
  75. data/test/environments/rails31/Rakefile +2 -0
  76. data/test/environments/rails31/config/database.yml +2 -7
  77. data/test/environments/rails32/Gemfile +2 -5
  78. data/test/environments/rails32/Rakefile +2 -0
  79. data/test/environments/rails32/config/database.yml +1 -1
  80. data/test/environments/rails40/Gemfile +7 -4
  81. data/test/environments/rails40/Rakefile +2 -0
  82. data/test/environments/rails40/config/database.yml +2 -7
  83. data/test/helpers/runtime_detection.rb +17 -0
  84. data/test/multiverse/lib/multiverse/suite.rb +20 -4
  85. data/test/multiverse/suites/agent_only/key_transactions_test.rb +1 -1
  86. data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -1
  87. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +32 -7
  88. data/test/multiverse/suites/agent_only/xray_sessions_test.rb +1 -0
  89. data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +4 -3
  90. data/test/multiverse/suites/curb/curb_test.rb +8 -0
  91. data/test/multiverse/suites/excon/excon_test.rb +8 -0
  92. data/test/multiverse/suites/httpclient/httpclient_test.rb +8 -0
  93. data/test/multiverse/suites/net_http/net_http_test.rb +8 -0
  94. data/test/multiverse/suites/padrino/Envfile +3 -2
  95. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +17 -8
  96. data/test/multiverse/suites/resque/Envfile +3 -3
  97. data/test/multiverse/suites/resque/instrumentation_test.rb +47 -5
  98. data/test/multiverse/suites/sequel/Envfile +0 -3
  99. data/test/multiverse/suites/sequel/database.rb +53 -0
  100. data/test/{new_relic/agent/instrumentation/sequel_test.rb → multiverse/suites/sequel/sequel_instrumentation_test.rb} +12 -53
  101. data/test/multiverse/suites/sequel/{sequel_test.rb → sequel_safety_test.rb} +2 -17
  102. data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +50 -5
  103. data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +15 -2
  104. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +8 -0
  105. data/test/new_relic/agent/agent/connect_test.rb +3 -2
  106. data/test/new_relic/agent/agent_test.rb +89 -82
  107. data/test/new_relic/agent/browser_monitoring_test.rb +44 -1
  108. data/test/new_relic/agent/error_collector_test.rb +17 -20
  109. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +13 -10
  110. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +16 -1
  111. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -2
  112. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
  113. data/test/new_relic/agent/new_relic_service_test.rb +78 -9
  114. data/test/new_relic/agent/pipe_channel_manager_test.rb +7 -9
  115. data/test/new_relic/agent/pipe_service_test.rb +4 -4
  116. data/test/new_relic/agent/request_sampler_test.rb +2 -2
  117. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +15 -35
  118. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +15 -7
  119. data/test/new_relic/agent/stats_engine_test.rb +4 -3
  120. data/test/new_relic/agent/threading/backtrace_service_test.rb +2 -0
  121. data/test/new_relic/agent/threading/thread_profile_test.rb +19 -0
  122. data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +4 -4
  123. data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +1 -1
  124. data/test/new_relic/agent/transaction_sampler_test.rb +60 -45
  125. data/test/new_relic/fake_collector.rb +37 -2
  126. data/test/new_relic/http_client_test_cases.rb +26 -1
  127. data/test/new_relic/language_support_test.rb +12 -31
  128. data/test/new_relic/local_environment_test.rb +6 -2
  129. data/test/new_relic/multiverse_helpers.rb +2 -5
  130. data/test/new_relic/transaction_sample_test.rb +57 -36
  131. data/test/performance/suites/config.rb +76 -0
  132. data/test/rum/no_html_and_no_header.result.html +3 -0
  133. data/test/rum/no_html_and_no_header.source.html +3 -0
  134. data/test/script/ci.sh +0 -2
  135. data/test/test_helper.rb +5 -0
  136. metadata +43 -26
  137. 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
- NewRelic::Agent.instance.events.subscribe(:after_call) do |_, (_, headers, _)|
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
- def test_object_space_enabled_true_without_jruby_with_object_space
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 test_object_space_enabled_false_without_object_space_without_jruby
17
- undefine_constant(:ObjectSpace) do
18
- undefine_constant(:JRuby) do
19
- assert_falsy NewRelic::LanguageSupport.object_space_enabled?
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 test_object_space_enabled_true_if_enabled_in_jruby_without_object_space
25
- fake_runtime = mock(:is_object_space_enabled => true)
26
- fake_jruby = mock(:runtime => fake_runtime)
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 test_object_space_enabled_false_if_disabled_in_jruby_without_object_space
36
- fake_runtime = mock(:is_object_space_enabled => false)
37
- fake_jruby = mock(:runtime => fake_runtime)
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(nil)
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 test_not_record_sql_when_record_sql_off
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 test_record_raw_sql
44
- s = @t.prepare_to_send(:explain_sql => 0.00000001, :record_sql => :raw)
45
- got_one = false
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
- fail if segment.params[:obfuscated_sql]
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
- def test_record_obfuscated_sql
53
+ assert_equal([::SQL_STATEMENT], sql_statements)
54
+ end
54
55
 
55
- s = @t.prepare_to_send(:explain_sql => 0.00000001, :record_sql => :obfuscated)
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
- got_one = false
59
+ sql_statements = []
58
60
  s.each_segment do |segment|
59
- got_one = got_one || segment.params[:explain_plan] || segment.params[:sql]
61
+ sql_statements << segment.params[:sql] if segment.params[:sql]
60
62
  end
61
63
 
62
- assert got_one
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 test_threshold
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
- expected_array = [@t.start_time.to_f,
209
- @t.params[:request_params],
210
- @t.params[:custom_params],
211
- @t.root_segment.to_array]
212
- assert_equal expected_array, @t.to_array
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
@@ -0,0 +1,3 @@
1
+ |||I AM THE RUM HEADER|||<body>
2
+ This isn't great HTML but it's what we've got.
3
+ |||I AM THE RUM FOOTER|||</body>
@@ -0,0 +1,3 @@
1
+ <body>
2
+ This isn't great HTML but it's what we've got.
3
+ </body>
@@ -66,8 +66,6 @@ echo `which ruby`
66
66
  ruby -v
67
67
  gem --version
68
68
 
69
- rake -h > /dev/null || gem install rake
70
-
71
69
  # make sure that we're in the project root
72
70
  script_dirname=`dirname $0`
73
71
  cd "$script_dirname/../../"