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
@@ -9,7 +9,7 @@ if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i >= MIN_RAILS_VERSION && !Ne
9
9
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
10
10
  require 'new_relic/agent/instrumentation/active_record_subscriber'
11
11
 
12
- class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Test::Unit::TestCase
12
+ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < MiniTest::Unit::TestCase
13
13
  class Order; end
14
14
 
15
15
  def setup
@@ -124,7 +124,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Test::Unit:
124
124
 
125
125
  def test_should_not_raise_due_to_an_exception_during_instrumentation_callback
126
126
  @subscriber.stubs(:record_metrics).raises(StandardError)
127
- assert_nothing_raised { simulate_query }
127
+ simulate_query
128
128
  end
129
129
 
130
130
  def simulate_query(duration=nil)
@@ -3,7 +3,7 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper'))
6
- class NewRelic::Agent::Instrumentation::ControllerInstrumentationTest < Test::Unit::TestCase
6
+ class NewRelic::Agent::Instrumentation::ControllerInstrumentationTest < MiniTest::Unit::TestCase
7
7
  require 'new_relic/agent/instrumentation/controller_instrumentation'
8
8
  class TestObject
9
9
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
@@ -3,7 +3,7 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper'))
6
- class NewRelic::Agent::Instrumentation::InstrumentationTest < Test::Unit::TestCase
6
+ class NewRelic::Agent::Instrumentation::InstrumentationTest < MiniTest::Unit::TestCase
7
7
  def test_load_all_instrumentation_files
8
8
  # just checking for syntax errors and unguarded code
9
9
  Dir.glob('new_relic/agent/instrumentation/**/*.rb') do |f|
@@ -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::Instrumentation::MetricFrameTest < Test::Unit::TestCase
7
+ class NewRelic::Agent::Instrumentation::MetricFrameTest < MiniTest::Unit::TestCase
8
8
 
9
9
  # These tests are just here to make sure that we're maintaining the required
10
10
  # old interface for folks. Real testing of the underlying functionality
@@ -7,7 +7,7 @@ require 'net/http'
7
7
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
8
8
  require 'new_relic/agent/cross_app_tracing'
9
9
 
10
- class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::TestCase
10
+ class NewRelic::Agent::Instrumentation::NetInstrumentationTest < MiniTest::Unit::TestCase
11
11
  def setup
12
12
  NewRelic::Agent.manual_start(
13
13
  :"cross_application_tracer.enabled" => false,
@@ -25,11 +25,9 @@ class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::Tes
25
25
  def test_scope_stack_integrity_maintained_on_request_failure
26
26
  @socket.stubs(:write).raises('fake network error')
27
27
  with_config(:"cross_application_tracer.enabled" => true) do
28
- assert_nothing_raised do
29
- expected = @engine.push_scope('dummy')
30
- Net::HTTP.get(URI.parse('http://www.google.com/index.html')) rescue nil
31
- @engine.pop_scope(expected, 42)
32
- end
28
+ expected = @engine.push_scope('dummy')
29
+ Net::HTTP.get(URI.parse('http://www.google.com/index.html')) rescue nil
30
+ @engine.pop_scope(expected, 42)
33
31
  end
34
32
  end
35
33
 
@@ -3,7 +3,7 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper'))
6
- class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
6
+ class NewRelic::Agent::Instrumentation::QueueTimeTest < MiniTest::Unit::TestCase
7
7
  include NewRelic::Agent::Instrumentation
8
8
 
9
9
  def setup
@@ -17,7 +17,7 @@ class MinimalRackApp
17
17
  include NewRelic::Agent::Instrumentation::Rack
18
18
  end
19
19
 
20
- class NewRelic::Agent::Instrumentation::RackTest < Test::Unit::TestCase
20
+ class NewRelic::Agent::Instrumentation::RackTest < MiniTest::Unit::TestCase
21
21
 
22
22
  def test_basic_rack_app
23
23
  # should return what we send in, even when instrumented
@@ -10,7 +10,7 @@ module NewRelic
10
10
  module Instrumentation
11
11
  module Sinatra
12
12
 
13
- class TransactionNamerTest < Test::Unit::TestCase
13
+ class TransactionNamerTest < MiniTest::Unit::TestCase
14
14
 
15
15
  def test_transaction_name_for_route
16
16
  env = { "newrelic.last_route" => /^\/the_route$/}
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper'))
6
6
  require 'new_relic/agent/instrumentation/sinatra'
7
7
 
8
- class NewRelic::Agent::Instrumentation::SinatraTest < Test::Unit::TestCase
8
+ class NewRelic::Agent::Instrumentation::SinatraTest < MiniTest::Unit::TestCase
9
9
 
10
10
  # This fake app is not an actual Sinatra app to avoid having our unit tests
11
11
  # take a dependency directly on it. If you need actual Sinatra classes, go
@@ -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::Instrumentation::TaskInstrumentationTest < Test::Unit::TestCase
7
+ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < MiniTest::Unit::TestCase
8
8
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
9
9
 
10
10
  def run_task_inner(n)
@@ -112,8 +112,8 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
112
112
  assert_metrics_not_recorded(['Controller'])
113
113
 
114
114
  sample = @agent.transaction_sampler.last_sample
115
- assert_not_nil(sample)
116
- assert_not_nil(sample.params[:custom_params][:cpu_time], "cpu time nil: \n#{sample}")
115
+ refute_nil(sample)
116
+ refute_nil(sample.params[:custom_params][:cpu_time], "cpu time nil: \n#{sample}")
117
117
  assert((sample.params[:custom_params][:cpu_time] >= 0), "cpu time: #{sample.params[:cpu_time]},\n#{sample}")
118
118
  assert_equal('10', sample.params[:request_params][:level])
119
119
  end
@@ -137,13 +137,13 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
137
137
 
138
138
  assert_metrics_recorded(['Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/hello'])
139
139
  sample = @agent.transaction_sampler.last_sample
140
- assert_not_nil(sample)
140
+ refute_nil(sample)
141
141
  assert_equal(account, sample.params[:request_params][:account])
142
142
  end
143
143
 
144
144
  def test_errors_are_noticed_and_not_swallowed
145
145
  @agent.error_collector.expects(:notice_error).once
146
- assert_raise(RuntimeError) { run_task_exception }
146
+ assert_raises(RuntimeError) { run_task_exception }
147
147
  end
148
148
 
149
149
  def test_error_collector_captures_custom_params
@@ -154,8 +154,8 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Test::Unit::Te
154
154
  assert_equal(1, errors.size)
155
155
  error = errors.first
156
156
  assert_equal("Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/run_task_exception", error.path)
157
- assert_not_nil(error.params[:stack_trace])
158
- assert_not_nil(error.params[:custom_params])
157
+ refute_nil(error.params[:stack_trace])
158
+ refute_nil(error.params[:custom_params])
159
159
  end
160
160
 
161
161
  def test_instrument_background_job
@@ -6,7 +6,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper
6
6
  require "new_relic/agent/javascript_instrumentor"
7
7
  require "base64"
8
8
 
9
- class NewRelic::Agent::JavascriptInstrumentorTest < Test::Unit::TestCase
9
+ class NewRelic::Agent::JavascriptInstrumentorTest < MiniTest::Unit::TestCase
10
10
  attr_reader :instrumentor
11
11
 
12
12
  def setup
@@ -142,53 +142,34 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Test::Unit::TestCase
142
142
  end
143
143
  end
144
144
 
145
- def test_data_for_js_agent_extra_parameter
145
+ def test_browser_timing_header_safe_when_insert_js_fails
146
146
  in_transaction do
147
- with_config(CAPTURE_ATTRIBUTES_PAGE_EVENTS => true) do
148
- NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
149
- assert_equal({:boo => "hoo"}, instrumentor.data_for_js_agent_extra_parameter)
150
- end
147
+ NewRelic::Agent.stubs(:config).raises("Hahahaha")
148
+ assert_equal "", instrumentor.browser_timing_header
151
149
  end
150
+ ensure
151
+ # Teardown touches config, so make sure we're clean before we bail here
152
+ NewRelic::Agent.unstub(:config)
152
153
  end
153
154
 
154
- def test_data_for_js_agent_extra_parameter_outside_transaction
155
- with_config(CAPTURE_ATTRIBUTES_PAGE_EVENTS => true) do
156
- NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
157
- assert_empty instrumentor.data_for_js_agent_extra_parameter
155
+ def test_browser_timing_header_safe_when_loader_generation_fails
156
+ in_transaction do
157
+ instrumentor.stubs(:html_safe_if_needed).raises("Hahahaha")
158
+ assert_equal "", instrumentor.browser_timing_header
158
159
  end
159
160
  end
160
161
 
161
- def test_format
162
- assert_formatted({:a => "1", "b" => 2}, "a=1", "b=#2")
163
- end
164
-
165
- def test_format_extra_data_escaping
166
- assert_formatted({"semi;colon" => "gets;escaped"}, "semi:colon=gets:escaped")
167
- assert_formatted({"equal=key" => "equal=value"}, "equal-key=equal-value")
168
- assert_formatted({'"quoted"' => '"marks"'}, %Q['quoted'='marks'])
169
- end
170
-
171
- def test_format_extra_data_disallowed_types
172
- assert_formatted_empty({"nested" => { "hashes?" => "nope" }})
173
- assert_formatted_empty({"lists" => ["are", "they", "allowed?", "nope"]})
174
- end
175
-
176
- def assert_formatted(data, *expected)
177
- result = instrumentor.format_extra_data(data).split(";")
178
- expected.each do |expect|
179
- assert_includes(result, expect)
162
+ def test_browser_timing_header_safe_when_json_dump_fails
163
+ in_transaction do
164
+ NewRelic::JSONWrapper.stubs(:dump).raises("Serialize? Hahahaha")
165
+ assert_equal "", instrumentor.browser_timing_header
180
166
  end
181
167
  end
182
168
 
183
- def assert_formatted_empty(data)
184
- result = instrumentor.format_extra_data(data)
185
- assert_equal("", result)
186
- end
187
-
188
169
  def test_config_data_for_js_agent
189
170
  freeze_time
190
171
  in_transaction do
191
- with_config(CAPTURE_ATTRIBUTES_PAGE_EVENTS => true) do
172
+ with_config(CAPTURE_ATTRIBUTES => true) do
192
173
  NewRelic::Agent.set_user_attributes(:user => "user")
193
174
 
194
175
  txn = NewRelic::Agent::Transaction.current
@@ -212,7 +193,7 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Test::Unit::TestCase
212
193
  "ttGuid" => "ABC",
213
194
  "agentToken" => "0123456789ABCDEF",
214
195
  "agent" => "",
215
- "extra" => pack("user=user")
196
+ "userAttributes" => pack('{"user":"user"}')
216
197
  }
217
198
 
218
199
  assert_equal(expected, data)
@@ -227,7 +208,7 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Test::Unit::TestCase
227
208
 
228
209
  def test_ssl_for_http_not_included_by_default
229
210
  data = instrumentor.data_for_js_agent
230
- assert_false data.include?("sslForHttp")
211
+ assert_not_includes data, "sslForHttp"
231
212
  end
232
213
 
233
214
  def test_ssl_for_http_enabled
@@ -244,42 +225,48 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Test::Unit::TestCase
244
225
  end
245
226
  end
246
227
 
247
- ANALYTICS_ENABLED = :'analytics_events.enabled'
248
- CAPTURE_ATTRIBUTES_PAGE_EVENTS = :'capture_attributes.page_view_events'
228
+ CAPTURE_ATTRIBUTES = :'browser_monitoring.capture_attributes'
229
+ CAPTURE_ATTRIBUTES_DEPRECATED = :'capture_attributes.page_view_events'
249
230
 
250
- def test_data_for_js_agent_doesnt_pick_up_extras_by_default
231
+ def test_data_for_js_agent_doesnt_get_custom_parameters_by_default
251
232
  in_transaction do
252
233
  NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
253
- assert_extra_data_is("")
234
+ assert_user_attributes_missing
235
+ end
236
+ end
237
+
238
+ def test_data_for_js_agent_doesnt_get_custom_parameters_outside_transaction
239
+ with_config(CAPTURE_ATTRIBUTES => true) do
240
+ NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
241
+ assert_user_attributes_missing
254
242
  end
255
243
  end
256
244
 
257
- def test_data_for_js_agent_picks_up_extras_when_configured
245
+
246
+ def test_data_for_js_agent_gets_custom_parameters_when_configured
258
247
  in_transaction do
259
- with_config(ANALYTICS_ENABLED => true,
260
- CAPTURE_ATTRIBUTES_PAGE_EVENTS => true) do
248
+ with_config(CAPTURE_ATTRIBUTES => true) do
261
249
  NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
262
- assert_extra_data_is("boo=hoo")
250
+ assert_user_attributes_are('{"boo":"hoo"}')
263
251
  end
264
252
  end
265
253
  end
266
254
 
267
- def test_data_for_js_agent_ignores_extras_if_no_analytics
255
+ def test_data_for_js_agent_ignores_custom_parameters_by_config
268
256
  in_transaction do
269
- with_config(ANALYTICS_ENABLED => false,
270
- CAPTURE_ATTRIBUTES_PAGE_EVENTS => true) do
257
+ with_config(CAPTURE_ATTRIBUTES => false) do
271
258
  NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
272
- assert_extra_data_is("")
259
+ assert_user_attributes_missing
273
260
  end
274
261
  end
275
262
  end
276
263
 
277
- def test_data_for_js_agent_ignores_extras_if_not_allowed_in_page
264
+ def test_data_for_js_agent_gets_custom_parameters_with_deprecated_key
278
265
  in_transaction do
279
- with_config(ANALYTICS_ENABLED => true,
280
- CAPTURE_ATTRIBUTES_PAGE_EVENTS => false) do
266
+ with_config(CAPTURE_ATTRIBUTES => false,
267
+ CAPTURE_ATTRIBUTES_DEPRECATED => true) do
281
268
  NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
282
- assert_extra_data_is("")
269
+ assert_user_attributes_are('{"boo":"hoo"}')
283
270
  end
284
271
  end
285
272
  end
@@ -318,9 +305,14 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Test::Unit::TestCase
318
305
  assert(footer.include?(snippet), "Expected footer to include snippet: #{snippet}, but instead was #{footer}")
319
306
  end
320
307
 
321
- def assert_extra_data_is(expected)
308
+ def assert_user_attributes_are(expected)
309
+ data = instrumentor.data_for_js_agent
310
+ assert_equal pack(expected), data["userAttributes"]
311
+ end
312
+
313
+ def assert_user_attributes_missing
322
314
  data = instrumentor.data_for_js_agent
323
- assert_equal pack(expected), data["extra"]
315
+ assert_not_includes data, "userAttributes"
324
316
  end
325
317
 
326
318
  def pack(text)
@@ -28,7 +28,7 @@ rescue Errno::ETIMEDOUT
28
28
  end
29
29
 
30
30
  if memcached_ready
31
- class NewRelic::Agent::MemcacheInstrumentationTest < Test::Unit::TestCase
31
+ class NewRelic::Agent::MemcacheInstrumentationTest < MiniTest::Unit::TestCase
32
32
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
33
33
 
34
34
  def setup
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
6
  require 'new_relic/agent/memory_logger'
7
7
 
8
- class MemoryLoggerTest < Test::Unit::TestCase
8
+ class MemoryLoggerTest < MiniTest::Unit::TestCase
9
9
  LEVELS = [:fatal, :error, :warn, :info, :debug]
10
10
 
11
11
  def setup
@@ -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/method_tracer'
8
7
 
9
- class MethodInterrobangTest < Test::Unit::TestCase
8
+ class MethodInterrobangTest < MiniTest::Unit::TestCase
10
9
  include NewRelic::Agent::MethodTracer
11
10
 
12
11
  def interrogate?
@@ -10,12 +10,12 @@ module NewRelic
10
10
  class Agent
11
11
  module MethodTracer
12
12
  module ClassMethods
13
- class AddMethodTracerTest < Test::Unit::TestCase
13
+ class AddMethodTracerTest < MiniTest::Unit::TestCase
14
14
  # require 'new_relic/agent/method_tracer'
15
15
  include NewRelic::Agent::MethodTracer::ClassMethods::AddMethodTracer
16
16
 
17
17
  def test_validate_options_nonhash
18
- assert_raise(TypeError) do
18
+ assert_raises(TypeError) do
19
19
  validate_options([])
20
20
  end
21
21
  end
@@ -99,7 +99,7 @@ module NewRelic
99
99
  end
100
100
 
101
101
  def test_check_for_illegal_keys_positive
102
- assert_raise(RuntimeError) do
102
+ assert_raises(RuntimeError) do
103
103
  check_for_illegal_keys!({:unknown_key => nil})
104
104
  end
105
105
  end
@@ -138,7 +138,7 @@ module NewRelic
138
138
  end
139
139
 
140
140
  def test_check_for_push_scope_and_metric_negative
141
- assert_raise(RuntimeError) do
141
+ assert_raises(RuntimeError) do
142
142
  check_for_push_scope_and_metric({:push_scope => false, :metric => false})
143
143
  end
144
144
  end
@@ -3,7 +3,7 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','..','test_helper'))
6
- class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Test::Unit::TestCase
6
+ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < MiniTest::Unit::TestCase
7
7
  require 'new_relic/agent/method_tracer'
8
8
  include NewRelic::Agent::MethodTracer
9
9
 
@@ -58,7 +58,7 @@ module TestModuleWithLog
58
58
  add_method_tracer :other_method, 'Custom/foo/bar'
59
59
  end
60
60
 
61
- class NewRelic::Agent::MethodTracerTest < Test::Unit::TestCase
61
+ class NewRelic::Agent::MethodTracerTest < MiniTest::Unit::TestCase
62
62
  attr_reader :stats_engine
63
63
 
64
64
  def setup
@@ -93,9 +93,8 @@ class NewRelic::Agent::MethodTracerTest < Test::Unit::TestCase
93
93
  end
94
94
 
95
95
  def test_record_metrics_does_not_raise_outside_transaction
96
- assert_nothing_raised do
97
- NewRelic::Agent::MethodTracer::TraceExecutionScoped.record_metrics('a', ['b'], 12, 10, :metric => true)
98
- end
96
+ NewRelic::Agent::MethodTracer::TraceExecutionScoped.record_metrics('a', ['b'], 12, 10, :metric => true)
97
+
99
98
  expected = { :call_count => 1, :total_call_time => 12, :total_exclusive_time => 10 }
100
99
  assert_metrics_recorded('a' => expected, 'b' => expected)
101
100
  end
@@ -190,9 +189,9 @@ class NewRelic::Agent::MethodTracerTest < Test::Unit::TestCase
190
189
 
191
190
  method_c1
192
191
 
193
- assert_not_nil @stats_engine.lookup_stats("c1")
192
+ refute_nil @stats_engine.lookup_stats("c1")
194
193
  assert_nil @stats_engine.lookup_stats("c2")
195
- assert_not_nil @stats_engine.lookup_stats("c3")
194
+ refute_nil @stats_engine.lookup_stats("c3")
196
195
 
197
196
  assert_equal ['c2', 'c1'], @scope_listener.scopes
198
197
  end
@@ -213,7 +212,7 @@ class NewRelic::Agent::MethodTracerTest < Test::Unit::TestCase
213
212
  stats = @stats_engine.get_stats("thrower")
214
213
  assert_equal 6, stats.call_count
215
214
  sample = @old_sampler.harvest!
216
- assert_not_nil sample
215
+ refute_nil sample
217
216
  end
218
217
 
219
218
  def test_add_same_tracer_twice