newrelic_rpm 3.7.1.188 → 3.7.2.190.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data.tar.gz.sig +3 -2
  2. data/CHANGELOG +1 -1
  3. data/Guardfile +3 -3
  4. data/README.md +1 -1
  5. data/Rakefile +0 -2
  6. data/init.rb +2 -5
  7. data/lib/new_relic/agent.rb +3 -0
  8. data/lib/new_relic/agent/agent.rb +2 -0
  9. data/lib/new_relic/agent/configuration/default_source.rb +32 -14
  10. data/lib/new_relic/agent/configuration/environment_source.rb +1 -0
  11. data/lib/new_relic/agent/cross_app_monitor.rb +2 -2
  12. data/lib/new_relic/agent/cross_app_tracing.rb +2 -2
  13. data/lib/new_relic/agent/error_collector.rb +1 -1
  14. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +4 -1
  15. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +10 -8
  16. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +11 -6
  17. data/lib/new_relic/agent/javascript_instrumentor.rb +27 -36
  18. data/lib/new_relic/agent/method_tracer.rb +20 -2
  19. data/lib/new_relic/agent/new_relic_service.rb +35 -27
  20. data/lib/new_relic/agent/request_sampler.rb +20 -13
  21. data/lib/new_relic/agent/sampler_collection.rb +4 -0
  22. data/lib/new_relic/agent/stats_engine/stats_hash.rb +4 -4
  23. data/lib/new_relic/agent/system_info.rb +25 -15
  24. data/lib/new_relic/agent/transaction.rb +23 -4
  25. data/lib/new_relic/agent/transaction_sampler.rb +1 -1
  26. data/lib/new_relic/cli/install.rb +1 -1
  27. data/lib/new_relic/control.rb +1 -0
  28. data/lib/new_relic/helper.rb +1 -29
  29. data/lib/new_relic/json_wrapper.rb +92 -0
  30. data/lib/new_relic/language_support.rb +4 -0
  31. data/lib/new_relic/rack/agent_hooks.rb +4 -0
  32. data/lib/new_relic/rack/browser_monitoring.rb +4 -0
  33. data/lib/new_relic/rack/developer_mode.rb +4 -1
  34. data/lib/new_relic/rack/error_collector.rb +5 -0
  35. data/lib/new_relic/rack/transaction_reset.rb +20 -0
  36. data/lib/new_relic/version.rb +1 -1
  37. data/lib/tasks/install.rake +0 -1
  38. data/newrelic_rpm.gemspec +1 -1
  39. data/test/agent_helper.rb +7 -8
  40. data/test/environments/norails/Gemfile +2 -1
  41. data/test/environments/rails21/Gemfile +2 -2
  42. data/test/environments/rails21/config/environment.rb +1 -3
  43. data/test/environments/rails21/config/environments/development.rb +0 -6
  44. data/test/environments/rails22/Gemfile +2 -2
  45. data/test/environments/rails22/config/environment.rb +0 -2
  46. data/test/environments/rails22/config/environments/development.rb +0 -6
  47. data/test/environments/rails23/Gemfile +2 -3
  48. data/test/environments/rails23/config/environment.rb +0 -9
  49. data/test/environments/rails23/config/environments/development.rb +0 -5
  50. data/test/environments/rails30/Gemfile +2 -2
  51. data/test/environments/rails31/Gemfile +2 -2
  52. data/test/environments/rails32/Gemfile +2 -1
  53. data/test/environments/rails40/Gemfile +2 -1
  54. data/test/intentional_fail.rb +1 -2
  55. data/test/multiverse/lib/multiverse/envfile.rb +1 -5
  56. data/test/multiverse/lib/multiverse/suite.rb +10 -27
  57. data/test/multiverse/suites/active_record/ar_method_aliasing.rb +49 -67
  58. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +128 -0
  59. data/test/multiverse/suites/agent_only/marshaling_test.rb +7 -9
  60. data/test/multiverse/suites/agent_only/script/loading.rb +20 -0
  61. data/test/multiverse/suites/agent_only/start_up_test.rb +7 -0
  62. data/test/multiverse/suites/bare/Envfile +3 -0
  63. data/test/multiverse/suites/bare/standalone_instrumentation_test.rb +43 -0
  64. data/test/multiverse/suites/rails/Envfile +0 -2
  65. data/test/multiverse/suites/rails/app/views/views/_a_partial.html.erb +1 -0
  66. data/test/multiverse/suites/rails/app/views/views/index.html.erb +1 -1
  67. data/test/multiverse/suites/rails/error_tracing_test.rb +1 -1
  68. data/test/multiverse/suites/rails/request_statistics_test.rb +9 -4
  69. data/test/multiverse/suites/rails/view_instrumentation_test.rb +111 -106
  70. data/test/multiverse/suites/typhoeus/Envfile +1 -1
  71. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +16 -2
  72. data/test/multiverse/test/multiverse_test.rb +2 -2
  73. data/test/new_relic/agent/agent/connect_test.rb +1 -1
  74. data/test/new_relic/agent/agent/start_test.rb +1 -1
  75. data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -1
  76. data/test/new_relic/agent/agent_logger_test.rb +3 -7
  77. data/test/new_relic/agent/agent_test.rb +33 -57
  78. data/test/new_relic/agent/apdex_from_server_test.rb +1 -1
  79. data/test/new_relic/agent/audit_logger_test.rb +5 -8
  80. data/test/new_relic/agent/autostart_test.rb +1 -1
  81. data/test/new_relic/agent/browser_token_test.rb +1 -1
  82. data/test/new_relic/agent/busy_calculator_test.rb +2 -4
  83. data/test/new_relic/agent/commands/agent_command_router_test.rb +5 -5
  84. data/test/new_relic/agent/commands/agent_command_test.rb +1 -1
  85. data/test/new_relic/agent/commands/thread_profiler_session_test.rb +6 -6
  86. data/test/new_relic/agent/commands/xray_session_collection_test.rb +10 -10
  87. data/test/new_relic/agent/commands/xray_session_test.rb +1 -1
  88. data/test/new_relic/agent/configuration/default_source_test.rb +4 -4
  89. data/test/new_relic/agent/configuration/environment_source_test.rb +14 -2
  90. data/test/new_relic/agent/configuration/manager_test.rb +3 -3
  91. data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
  92. data/test/new_relic/agent/configuration/server_source_test.rb +1 -1
  93. data/test/new_relic/agent/configuration/yaml_source_test.rb +2 -2
  94. data/test/new_relic/agent/cpu_sampler_test.rb +1 -1
  95. data/test/new_relic/agent/cross_app_monitor_test.rb +3 -3
  96. data/test/new_relic/agent/cross_app_tracing_test.rb +5 -4
  97. data/test/new_relic/agent/database_test.rb +1 -1
  98. data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +1 -1
  99. data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +1 -1
  100. data/test/new_relic/agent/datastores/mongo/obfuscator_test.rb +1 -1
  101. data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +2 -2
  102. data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
  103. data/test/new_relic/agent/error_collector_test.rb +5 -3
  104. data/test/new_relic/agent/event_listener_test.rb +1 -1
  105. data/test/new_relic/agent/harvester_test.rb +1 -1
  106. data/test/new_relic/agent/http_clients/uri_util_test.rb +1 -1
  107. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +1 -1
  108. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +1 -1
  109. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +1 -1
  110. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +495 -495
  111. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +2 -2
  112. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +1 -1
  113. data/test/new_relic/agent/instrumentation/instrumentation_test.rb +1 -1
  114. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +1 -1
  115. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +4 -6
  116. data/test/new_relic/agent/instrumentation/queue_time_test.rb +1 -1
  117. data/test/new_relic/agent/instrumentation/rack_test.rb +1 -1
  118. data/test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb +1 -1
  119. data/test/new_relic/agent/instrumentation/sinatra_test.rb +1 -1
  120. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +7 -7
  121. data/test/new_relic/agent/javascript_instrumentor_test.rb +47 -55
  122. data/test/new_relic/agent/memcache_instrumentation_test.rb +1 -1
  123. data/test/new_relic/agent/memory_logger_test.rb +1 -1
  124. data/test/new_relic/agent/method_interrobang_test.rb +2 -3
  125. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +4 -4
  126. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
  127. data/test/new_relic/agent/method_tracer_test.rb +6 -7
  128. data/test/new_relic/agent/method_visibility_test.rb +1 -1
  129. data/test/new_relic/agent/new_relic_service_test.rb +129 -19
  130. data/test/new_relic/agent/obfuscator_test.rb +1 -1
  131. data/test/new_relic/agent/pipe_channel_manager_test.rb +143 -145
  132. data/test/new_relic/agent/pipe_service_test.rb +2 -4
  133. data/test/new_relic/agent/request_sampler_test.rb +23 -19
  134. data/test/new_relic/agent/rpm_agent_test.rb +3 -3
  135. data/test/new_relic/agent/rules_engine_test.rb +1 -1
  136. data/test/new_relic/agent/sampled_buffer_test.rb +1 -1
  137. data/test/new_relic/agent/sampler_collection_test.rb +3 -3
  138. data/test/new_relic/agent/sampler_test.rb +1 -1
  139. data/test/new_relic/agent/shim_agent_test.rb +1 -1
  140. data/test/new_relic/agent/sql_sampler_test.rb +4 -6
  141. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -1
  142. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +5 -5
  143. data/test/new_relic/agent/stats_engine/samplers_test.rb +2 -2
  144. data/test/new_relic/agent/stats_engine_test.rb +3 -3
  145. data/test/new_relic/agent/stats_hash_test.rb +2 -2
  146. data/test/new_relic/agent/stats_test.rb +1 -1
  147. data/test/new_relic/agent/threading/agent_thread_test.rb +2 -4
  148. data/test/new_relic/agent/threading/backtrace_node_test.rb +1 -1
  149. data/test/new_relic/agent/threading/backtrace_service_test.rb +5 -5
  150. data/test/new_relic/agent/threading/thread_profile_test.rb +1 -1
  151. data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +1 -1
  152. data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +1 -1
  153. data/test/new_relic/agent/transaction/pop_test.rb +1 -1
  154. data/test/new_relic/agent/transaction/slowest_sample_buffer_test.rb +1 -1
  155. data/test/new_relic/agent/transaction/xray_sample_buffer_test.rb +1 -1
  156. data/test/new_relic/agent/transaction_interrobang_test.rb +2 -3
  157. data/test/new_relic/agent/transaction_sample_builder_test.rb +16 -14
  158. data/test/new_relic/agent/transaction_sampler_test.rb +16 -21
  159. data/test/new_relic/agent/transaction_state_test.rb +1 -1
  160. data/test/new_relic/agent/transaction_test.rb +61 -1
  161. data/test/new_relic/agent/transaction_timings_test.rb +1 -1
  162. data/test/new_relic/agent/worker_loop_test.rb +1 -1
  163. data/test/new_relic/agent_test.rb +2 -3
  164. data/test/new_relic/cli/deployments_test.rb +3 -3
  165. data/test/new_relic/coerce_test.rb +1 -1
  166. data/test/new_relic/collection_helper_test.rb +1 -1
  167. data/test/new_relic/control/class_methods_test.rb +2 -2
  168. data/test/new_relic/control/frameworks/rails_test.rb +1 -1
  169. data/test/new_relic/control_test.rb +9 -4
  170. data/test/new_relic/dependency_detection_test.rb +1 -1
  171. data/test/new_relic/dispatcher_test.rb +1 -1
  172. data/test/new_relic/environment_report_test.rb +4 -6
  173. data/test/new_relic/fake_collector.rb +1 -158
  174. data/test/new_relic/framework_test.rb +2 -1
  175. data/test/new_relic/http_client_test_cases.rb +2 -3
  176. data/test/new_relic/json_wrapper_test.rb +77 -0
  177. data/test/new_relic/language_support_test.rb +1 -1
  178. data/test/new_relic/license_test.rb +2 -2
  179. data/test/new_relic/load_test.rb +2 -8
  180. data/test/new_relic/local_environment_test.rb +1 -1
  181. data/test/new_relic/metric_data_test.rb +1 -1
  182. data/test/new_relic/metric_parser/metric_parser_test.rb +1 -1
  183. data/test/new_relic/metric_spec_test.rb +1 -1
  184. data/test/new_relic/multiverse_helpers.rb +26 -30
  185. data/test/new_relic/noticed_error_test.rb +1 -1
  186. data/test/new_relic/rack/agent_hooks_test.rb +1 -1
  187. data/test/new_relic/rack/all_test.rb +1 -1
  188. data/test/new_relic/rack/browser_monitoring_test.rb +4 -2
  189. data/test/new_relic/rack/deferred_instrumentation_test.rb +3 -5
  190. data/test/new_relic/rack/developer_mode_helper_test.rb +1 -1
  191. data/test/new_relic/rack/developer_mode_test.rb +1 -1
  192. data/test/new_relic/rack/error_collector_test.rb +8 -8
  193. data/test/new_relic/rack/transaction_reset_test.rb +35 -0
  194. data/test/new_relic/transaction_analysis/segment_summary_test.rb +2 -2
  195. data/test/new_relic/transaction_analysis_test.rb +1 -1
  196. data/test/new_relic/transaction_sample/composite_segment_test.rb +1 -1
  197. data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -4
  198. data/test/new_relic/transaction_sample/segment_test.rb +3 -7
  199. data/test/new_relic/transaction_sample/summary_segment_test.rb +1 -1
  200. data/test/new_relic/transaction_sample_subtest_test.rb +1 -1
  201. data/test/new_relic/transaction_sample_test.rb +4 -6
  202. data/test/new_relic/version_number_test.rb +1 -1
  203. data/test/performance/lib/performance/instrumentation/gc_stats.rb +1 -1
  204. data/test/performance/lib/performance/json_reporter.rb +1 -1
  205. data/test/performance/suites/marshalling.rb +76 -0
  206. data/test/test_helper.rb +6 -39
  207. metadata +19 -12
  208. metadata.gz.sig +0 -0
  209. data/test/new_relic/helper_test.rb +0 -32
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
6
6
 
7
7
  class NewRelic::Agent::Transaction
8
- class ForcePersistSampleBufferTest < Test::Unit::TestCase
8
+ class ForcePersistSampleBufferTest < MiniTest::Unit::TestCase
9
9
  def setup
10
10
  @buffer = ForcePersistSampleBuffer.new
11
11
  end
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper'))
6
6
  require 'new_relic/agent/transaction/pop'
7
- class NewRelic::Agent::Transaction::PopTest < Test::Unit::TestCase
7
+ class NewRelic::Agent::Transaction::PopTest < MiniTest::Unit::TestCase
8
8
  include NewRelic::Agent::Transaction::Pop
9
9
 
10
10
  attr_reader :agent
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
6
6
 
7
7
  class NewRelic::Agent::Transaction
8
- class SlowestSampleBufferTest < Test::Unit::TestCase
8
+ class SlowestSampleBufferTest < MiniTest::Unit::TestCase
9
9
  def setup
10
10
  @buffer = SlowestSampleBuffer.new
11
11
  end
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
6
6
 
7
7
  class NewRelic::Agent::Transaction
8
- class XraySampleBufferTest < Test::Unit::TestCase
8
+ class XraySampleBufferTest < MiniTest::Unit::TestCase
9
9
 
10
10
  XRAY_SESSION_ID = 123
11
11
  MATCHING_TRANSACTION = "Matching/transaction/name"
@@ -2,11 +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
- require 'test/unit'
6
- require 'newrelic_rpm'
5
+ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
7
6
  require 'new_relic/agent/instrumentation/controller_instrumentation'
8
7
 
9
- class TransactionInterrobangTest < Test::Unit::TestCase
8
+ class TransactionInterrobangTest < MiniTest::Unit::TestCase
10
9
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
11
10
 
12
11
  def interrogate?
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
6
 
7
- class NewRelic::Agent::TransationSampleBuilderTest < Test::Unit::TestCase
7
+ class NewRelic::Agent::TransationSampleBuilderTest < MiniTest::Unit::TestCase
8
8
 
9
9
  def setup
10
10
  freeze_time
@@ -211,10 +211,8 @@ class NewRelic::Agent::TransationSampleBuilderTest < Test::Unit::TestCase
211
211
  6.times { |i| build_segment "s#{i}" }
212
212
  # now we should have a placeholder segment
213
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
214
+ @builder.current_segment['eggs'] = 'ham'
215
+ @builder.current_segment.params.merge!('foo' => 'bar')
218
216
  end
219
217
  end
220
218
  end
@@ -235,21 +233,25 @@ class NewRelic::Agent::TransationSampleBuilderTest < Test::Unit::TestCase
235
233
  end
236
234
 
237
235
  def test_has_correct_transaction_trace_threshold_when_default
238
- NewRelic::Agent::TransactionState.get.transaction = stub()
239
- NewRelic::Agent::TransactionState.get.transaction.stubs(:apdex_t).returns(1.5)
240
- assert_equal 6.0, @builder.transaction_trace_threshold
236
+ in_transaction do
237
+ with_config(:apdex_t => 1.5) do
238
+ assert_equal 6.0, @builder.transaction_trace_threshold
239
+ end
241
240
 
242
- NewRelic::Agent::TransactionState.get.transaction.stubs(:apdex_t).returns(2.0)
243
- assert_equal 8.0, @builder.transaction_trace_threshold
241
+ with_config(:apdex_t => 2.0) do
242
+ assert_equal 8.0, @builder.transaction_trace_threshold
243
+ end
244
+ end
244
245
  end
245
246
 
246
247
  def test_has_correct_transaction_trace_threshold_when_explicitly_specified
247
248
  config = { :'transaction_tracer.transaction_threshold' => 4.0 }
248
249
 
249
- with_config(config, :do_not_cast => true) do
250
- NewRelic::Agent::TransactionState.get.transaction = stub()
251
- NewRelic::Agent::TransactionState.get.transaction.stubs(:apdex_t).returns(1.5)
252
- assert_equal 4.0, @builder.transaction_trace_threshold
250
+ in_transaction do
251
+ with_config(config, :do_not_cast => true) do
252
+ NewRelic::Agent::TransactionState.get.transaction.stubs(:apdex_t).returns(1.5)
253
+ assert_equal 4.0, @builder.transaction_trace_threshold
254
+ end
253
255
  end
254
256
  end
255
257
 
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
6
  require File.expand_path(File.join(File.dirname(__FILE__),'..','data_container_tests'))
7
7
 
8
- class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
8
+ class NewRelic::Agent::TransactionSamplerTest < MiniTest::Unit::TestCase
9
9
 
10
10
  module MockGCStats
11
11
 
@@ -102,7 +102,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
102
102
  sample.expects(:finished).returns(true)
103
103
  @sampler.expects(:builder).returns(builder).twice
104
104
 
105
- assert_raise(RuntimeError) do
105
+ assert_raises(RuntimeError) do
106
106
  @sampler.notice_pop_scope('a scope', Time.at(100))
107
107
  end
108
108
  end
@@ -640,7 +640,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
640
640
  @sampler.notice_scope_empty(@txn)
641
641
  @sampler.notice_scope_empty(@txn)
642
642
 
643
- assert_not_nil @sampler.harvest![0]
643
+ refute_nil @sampler.harvest![0]
644
644
  end
645
645
  end
646
646
 
@@ -761,9 +761,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
761
761
  @sampler.start_builder
762
762
  segment = @sampler.notice_push_scope
763
763
  segment.metric_name = 'External/www.google.com/Net::HTTP/GET'
764
- assert_nothing_raised do
765
- @sampler.notice_pop_scope( 'External/www.google.com/Net::HTTP/GET' )
766
- end
764
+ @sampler.notice_pop_scope( 'External/www.google.com/Net::HTTP/GET' )
767
765
  end
768
766
 
769
767
  def test_adding_segment_parameters
@@ -782,10 +780,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
782
780
  with_config(config) do
783
781
  run_long_sample_trace(110)
784
782
 
785
- samples = nil
786
- assert_nothing_raised do
787
- samples = @sampler.harvest!
788
- end
783
+ samples = @sampler.harvest!
789
784
  assert_equal(1, samples.size)
790
785
 
791
786
  # Verify that the TT stopped recording after 100 nodes
@@ -832,7 +827,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
832
827
  def test_custom_params_omitted_if_config_says_so
833
828
  config = {
834
829
  :'transaction_tracer.transaction_threshold' => 0.0,
835
- :'capture_attributes.traces' => false
830
+ :'transaction_tracer.capture_attributes' => false
836
831
  }
837
832
  with_config(config) do
838
833
  in_transaction do
@@ -847,7 +842,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
847
842
  def test_custom_params_included_if_config_says_so
848
843
  config = {
849
844
  :'transaction_tracer.transaction_threshold' => 0.0,
850
- :'capture_attributes.traces' => true
845
+ :'transaction_tracer.capture_attributes' => true
851
846
  }
852
847
  with_config(config) do
853
848
  in_transaction do
@@ -856,7 +851,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
856
851
  end
857
852
  sample = NewRelic::Agent.agent.transaction_sampler.harvest![0]
858
853
  custom_params = sample.params[:custom_params]
859
- assert(custom_params.keys.include?(:foo), "Expected custom param on TT because capture_attributes.traces is true")
854
+ assert_includes custom_params.keys, :foo
860
855
  end
861
856
 
862
857
  class Dummy
@@ -870,16 +865,16 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
870
865
  end
871
866
 
872
867
  # TODO: this test seems to be destabilizing CI in a way that I don't grok.
873
- def sadly_do_not_test_harvest_during_transaction_safety
874
- n = 3000
875
- harvester = Thread.new do
876
- n.times { @sampler.harvest! }
877
- end
868
+ #def sadly_do_not_test_harvest_during_transaction_safety
869
+ # n = 3000
870
+ # harvester = Thread.new do
871
+ # n.times { @sampler.harvest! }
872
+ # end
878
873
 
879
- assert_nothing_raised { Dummy.new.run(n) }
874
+ # Dummy.new.run(n)
880
875
 
881
- harvester.join
882
- end
876
+ # harvester.join
877
+ #end
883
878
 
884
879
  private
885
880
 
@@ -7,7 +7,7 @@ require 'new_relic/agent/transaction'
7
7
  require 'new_relic/agent/transaction_state'
8
8
 
9
9
  module NewRelic::Agent
10
- class TransactionStateTest < Test::Unit::TestCase
10
+ class TransactionStateTest < MiniTest::Unit::TestCase
11
11
  attr_reader :state
12
12
 
13
13
  def setup
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
6
 
7
- class NewRelic::Agent::TransactionTest < Test::Unit::TestCase
7
+ class NewRelic::Agent::TransactionTest < MiniTest::Unit::TestCase
8
8
 
9
9
  attr_reader :txn
10
10
 
@@ -12,11 +12,17 @@ class NewRelic::Agent::TransactionTest < Test::Unit::TestCase
12
12
  @txn = NewRelic::Agent::Transaction.new
13
13
  @stats_engine = NewRelic::Agent.instance.stats_engine
14
14
  @stats_engine.reset!
15
+ NewRelic::Agent.instance.error_collector.reset!
15
16
  end
16
17
 
17
18
  def teardown
18
19
  # Failed transactions can leave partial stack, so pave it for next test
20
+ cleanup_transaction
21
+ end
22
+
23
+ def cleanup_transaction
19
24
  NewRelic::Agent::Transaction.stack.clear
25
+ NewRelic::Agent::TransactionState.clear
20
26
  end
21
27
 
22
28
  def test_request_parsing__none
@@ -321,6 +327,60 @@ class NewRelic::Agent::TransactionTest < Test::Unit::TestCase
321
327
  end
322
328
  end
323
329
 
330
+ def test_notice_error_in_current_transaction_saves_it_for_finishing
331
+ in_transaction('failing') do
332
+ NewRelic::Agent::Transaction.notice_error("")
333
+ assert_equal 1, NewRelic::Agent::Transaction.current.exceptions.count
334
+ end
335
+ end
336
+
337
+ def test_notice_error_after_current_transaction_notifies_error_collector
338
+ in_transaction('failing') do
339
+ # no-op
340
+ end
341
+ NewRelic::Agent::Transaction.notice_error("")
342
+ assert_equal 1, NewRelic::Agent.instance.error_collector.errors.count
343
+ end
344
+
345
+ def test_notice_error_after_current_transaction_gets_custom_params
346
+ in_transaction('failing') do
347
+ NewRelic::Agent.add_custom_parameters(:custom => "parameter")
348
+ end
349
+ NewRelic::Agent::Transaction.notice_error("")
350
+
351
+ error = NewRelic::Agent.instance.error_collector.errors.first
352
+ assert_equal({ :custom => "parameter" }, error.params[:custom_params])
353
+ end
354
+
355
+ def test_notice_error_after_current_transcation_doesnt_tromp_passed_params
356
+ in_transaction('failing') do
357
+ NewRelic::Agent.add_custom_parameters(:custom => "parameter")
358
+ end
359
+ NewRelic::Agent::Transaction.notice_error("", :custom_params => { :passing => true })
360
+
361
+ error = NewRelic::Agent.instance.error_collector.errors.first
362
+ expected = {
363
+ :custom => "parameter",
364
+ :passing => true,
365
+ }
366
+ assert_equal(expected, error.params[:custom_params])
367
+ end
368
+
369
+ def test_notice_error_after_current_transaction_gets_name
370
+ in_transaction('failing') do
371
+ #no-op
372
+ end
373
+ NewRelic::Agent::Transaction.notice_error("")
374
+ error = NewRelic::Agent.instance.error_collector.errors.first
375
+ assert_equal 'failing', error.path
376
+ end
377
+
378
+ def test_notice_error_without_transaction_notifies_error_collector
379
+ cleanup_transaction
380
+ NewRelic::Agent::Transaction.notice_error("")
381
+ assert_equal 1, NewRelic::Agent.instance.error_collector.errors.count
382
+ end
383
+
324
384
  def assert_has_custom_parameter(key, value = key)
325
385
  assert_equal(value, NewRelic::Agent::Transaction.current.custom_parameters[key])
326
386
  end
@@ -6,7 +6,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper
6
6
  require 'new_relic/agent/transaction_timings'
7
7
 
8
8
  module NewRelic::Agent
9
- class TransactionTimingsTest < Test::Unit::TestCase
9
+ class TransactionTimingsTest < MiniTest::Unit::TestCase
10
10
 
11
11
  def setup
12
12
  @start_time = freeze_time
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
6
 
7
- class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase
7
+ class NewRelic::Agent::WorkerLoopTest < MiniTest::Unit::TestCase
8
8
  def setup
9
9
  @worker_loop = NewRelic::Agent::WorkerLoop.new
10
10
  end
@@ -9,7 +9,7 @@ module NewRelic
9
9
  # mostly this class just passes through to the active agent
10
10
  # through the agent method or the control instance through
11
11
  # NewRelic::Control.instance . But it's nice to make sure.
12
- class MainAgentTest < Test::Unit::TestCase
12
+ class MainAgentTest < MiniTest::Unit::TestCase
13
13
  include NewRelic::Agent::MethodTracer
14
14
 
15
15
  def setup
@@ -18,7 +18,6 @@ module NewRelic
18
18
  end
19
19
 
20
20
  def teardown
21
- super
22
21
  NewRelic::Agent::TransactionState.clear
23
22
  end
24
23
 
@@ -108,7 +107,7 @@ module NewRelic
108
107
  def test_agent_not_started
109
108
  old_agent = NewRelic::Agent.agent
110
109
  NewRelic::Agent.instance_eval { @agent = nil }
111
- assert_raise(RuntimeError) do
110
+ assert_raises(RuntimeError) do
112
111
  NewRelic::Agent.agent
113
112
  end
114
113
  NewRelic::Agent.instance_eval { @agent = old_agent }
@@ -6,7 +6,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper
6
6
  require 'new_relic/cli/command'
7
7
  require 'new_relic/cli/deployments'
8
8
 
9
- class NewRelic::Cli::DeploymentsTest < Test::Unit::TestCase
9
+ class NewRelic::Cli::DeploymentsTest < MiniTest::Unit::TestCase
10
10
 
11
11
  def setup
12
12
  NewRelic::Cli::Deployments.class_eval do
@@ -35,7 +35,7 @@ class NewRelic::Cli::DeploymentsTest < Test::Unit::TestCase
35
35
  end
36
36
  end
37
37
  def test_bad_command
38
- assert_raise NewRelic::Cli::Command::CommandFailure do
38
+ assert_raises NewRelic::Cli::Command::CommandFailure do
39
39
  NewRelic::Cli::Deployments.new ["-foo", "bar"]
40
40
  end
41
41
  end
@@ -70,7 +70,7 @@ class NewRelic::Cli::DeploymentsTest < Test::Unit::TestCase
70
70
 
71
71
  def test_error_if_no_license_key
72
72
  with_config(:license_key => '') do
73
- assert_raise NewRelic::Cli::Command::CommandFailure do
73
+ assert_raises NewRelic::Cli::Command::CommandFailure do
74
74
  deployment = NewRelic::Cli::Deployments.new(%w[-a APP -r 3838 --user=Bill] << "Some lengthy description")
75
75
  deployment.run
76
76
  end
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
6
6
  require 'new_relic/coerce'
7
7
 
8
- class CoerceTest < Test::Unit::TestCase
8
+ class CoerceTest < MiniTest::Unit::TestCase
9
9
 
10
10
  include NewRelic::Coerce
11
11
 
@@ -7,7 +7,7 @@ require 'ostruct'
7
7
  require 'active_record_fixtures' if defined?(::ActiveRecord)
8
8
 
9
9
  require 'new_relic/collection_helper'
10
- class NewRelic::CollectionHelperTest < Test::Unit::TestCase
10
+ class NewRelic::CollectionHelperTest < MiniTest::Unit::TestCase
11
11
 
12
12
  def setup
13
13
  NewRelic::Agent.manual_start
@@ -10,7 +10,7 @@ class BaseClassMethods
10
10
  include NewRelic::Control::ClassMethods
11
11
  end
12
12
 
13
- class NewRelic::Control::ClassMethodsTest < Test::Unit::TestCase
13
+ class NewRelic::Control::ClassMethodsTest < MiniTest::Unit::TestCase
14
14
  def setup
15
15
  @base = ::BaseClassMethods.new
16
16
  super
@@ -41,7 +41,7 @@ class NewRelic::Control::ClassMethodsTest < Test::Unit::TestCase
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
43
43
  # NewRelic::Control::Framework::FooBar
44
- assert_raise(NameError) do
44
+ assert_raises(NameError) do
45
45
  @base.load_framework_class('missing')
46
46
  end
47
47
  end
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'/../../../test_helper'))
6
6
 
7
- class NewRelic::Control::Frameworks::RailsTest < Test::Unit::TestCase
7
+ class NewRelic::Control::Frameworks::RailsTest < MiniTest::Unit::TestCase
8
8
  def test_install_browser_monitoring
9
9
  require 'new_relic/rack/browser_monitoring'
10
10
  middleware = stub('middleware config')
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'/../test_helper'))
6
6
 
7
- class NewRelic::ControlTest < Test::Unit::TestCase
7
+ class NewRelic::ControlTest < MiniTest::Unit::TestCase
8
8
  attr_reader :control
9
9
 
10
10
  def setup
@@ -35,7 +35,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
35
35
  end
36
36
 
37
37
  def test_settings_accessor
38
- assert_not_nil control.settings
38
+ refute_nil control.settings
39
39
  end
40
40
 
41
41
  def test_root
@@ -179,7 +179,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
179
179
  end
180
180
 
181
181
  def test_init_plugin_loads_samplers_enabled
182
- NewRelic::Agent.shutdown
182
+ reset_agent
183
183
  with_config(:disable_samplers => false, :agent_enabled => true) do
184
184
  NewRelic::Control.instance.init_plugin
185
185
  assert NewRelic::Agent.instance.harvest_samplers.any?
@@ -187,10 +187,15 @@ class NewRelic::ControlTest < Test::Unit::TestCase
187
187
  end
188
188
 
189
189
  def test_init_plugin_loads_samplers_disabled
190
- NewRelic::Agent.shutdown
190
+ reset_agent
191
191
  with_config(:disable_samplers => true, :agent_enabled => true) do
192
192
  NewRelic::Control.instance.init_plugin
193
193
  assert !NewRelic::Agent.instance.harvest_samplers.any?
194
194
  end
195
195
  end
196
+
197
+ def reset_agent
198
+ NewRelic::Agent.shutdown
199
+ NewRelic::Agent.instance.harvest_samplers.clear
200
+ end
196
201
  end