newrelic_rpm 3.18.1.330 → 4.0.0.332

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -74
  3. data/CHANGELOG.md +77 -0
  4. data/CONTRIBUTING.md +14 -6
  5. data/LICENSE +1 -88
  6. data/lib/new_relic/agent.rb +2 -103
  7. data/lib/new_relic/agent/agent.rb +3 -32
  8. data/lib/new_relic/agent/commands/thread_profiler_session.rb +2 -6
  9. data/lib/new_relic/agent/configuration/default_source.rb +1 -8
  10. data/lib/new_relic/agent/configuration/yaml_source.rb +1 -12
  11. data/lib/new_relic/agent/cross_app_monitor.rb +2 -1
  12. data/lib/new_relic/agent/cross_app_tracing.rb +4 -2
  13. data/lib/new_relic/agent/datastores/mongo.rb +1 -1
  14. data/lib/new_relic/agent/datastores/redis.rb +1 -1
  15. data/lib/new_relic/agent/encoding_normalizer.rb +1 -20
  16. data/lib/new_relic/agent/error_collector.rb +8 -21
  17. data/lib/new_relic/agent/inbound_request_monitor.rb +4 -1
  18. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +14 -30
  19. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
  20. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -5
  21. data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
  22. data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
  23. data/lib/new_relic/agent/instrumentation/grape.rb +3 -3
  24. data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
  25. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -2
  26. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -2
  27. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +3 -7
  28. data/lib/new_relic/agent/instrumentation/queue_time.rb +13 -15
  29. data/lib/new_relic/agent/instrumentation/rack.rb +4 -50
  30. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/resque.rb +1 -2
  32. data/lib/new_relic/agent/instrumentation/sinatra.rb +0 -1
  33. data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
  34. data/lib/new_relic/agent/javascript_instrumentor.rb +3 -2
  35. data/lib/new_relic/agent/method_tracer.rb +1 -60
  36. data/lib/new_relic/agent/new_relic_service.rb +3 -2
  37. data/lib/new_relic/agent/new_relic_service/encoders.rb +5 -6
  38. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +7 -16
  39. data/lib/new_relic/agent/pipe_channel_manager.rb +1 -3
  40. data/lib/new_relic/agent/pipe_service.rb +1 -3
  41. data/lib/new_relic/agent/rules_engine.rb +2 -17
  42. data/lib/new_relic/agent/stats_engine.rb +0 -2
  43. data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -48
  44. data/lib/new_relic/agent/supported_versions.rb +12 -19
  45. data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
  46. data/lib/new_relic/agent/transaction.rb +0 -3
  47. data/lib/new_relic/agent/transaction/attributes.rb +1 -10
  48. data/lib/new_relic/agent/vm.rb +1 -4
  49. data/lib/new_relic/agent/vm/jruby_vm.rb +1 -3
  50. data/lib/new_relic/agent/vm/mri_vm.rb +2 -10
  51. data/lib/new_relic/control.rb +1 -2
  52. data/lib/new_relic/control/frameworks/rails.rb +1 -1
  53. data/lib/new_relic/control/frameworks/rails3.rb +1 -2
  54. data/lib/new_relic/control/frameworks/rails4.rb +1 -1
  55. data/lib/new_relic/control/frameworks/rails5.rb +1 -1
  56. data/lib/new_relic/control/instance_methods.rb +1 -1
  57. data/{vendor/gems/dependency_detection-0.0.1.build/lib → lib/new_relic}/dependency_detection.rb +0 -1
  58. data/lib/new_relic/helper.rb +6 -13
  59. data/lib/new_relic/language_support.rb +44 -139
  60. data/lib/new_relic/metric_spec.rb +0 -17
  61. data/lib/new_relic/noticed_error.rb +18 -27
  62. data/lib/new_relic/version.rb +3 -48
  63. data/lib/tasks/versions.rake +7 -5
  64. data/newrelic_rpm.gemspec +1 -16
  65. data/test/agent_helper.rb +4 -2
  66. data/test/environments/lib/environments/runner.rb +5 -14
  67. data/test/environments/norails/Gemfile +0 -8
  68. data/test/environments/rails21/Gemfile +0 -8
  69. data/test/environments/rails21/config/database.yml +1 -1
  70. data/test/environments/rails22/Gemfile +0 -8
  71. data/test/environments/rails22/config/database.yml +1 -1
  72. data/test/environments/rails23/Gemfile +1 -7
  73. data/test/environments/rails23/config/database.yml +1 -1
  74. data/test/environments/rails30/Gemfile +0 -1
  75. data/test/environments/rails30/config/database.yml +1 -1
  76. data/test/environments/rails31/Gemfile +0 -3
  77. data/test/environments/rails31/config/database.yml +1 -1
  78. data/test/environments/rails32/Gemfile +0 -3
  79. data/test/environments/rails32/config/database.yml +1 -1
  80. data/test/environments/rails40/Gemfile +0 -26
  81. data/test/environments/rails40/config/database.yml +1 -1
  82. data/test/environments/rails41/Gemfile +0 -18
  83. data/test/environments/rails41/config/database.yml +1 -1
  84. data/test/environments/rails42/Gemfile +0 -22
  85. data/test/environments/rails42/config/database.yml +1 -1
  86. data/test/environments/rails50/Gemfile +0 -13
  87. data/test/environments/rails50/config/database.yml +1 -1
  88. data/test/helpers/logging.rb +37 -0
  89. data/test/helpers/minitest.rb +50 -0
  90. data/test/helpers/misc.rb +87 -0
  91. data/test/helpers/transaction_sample.rb +44 -0
  92. data/test/multiverse/lib/multiverse/suite.rb +6 -91
  93. data/test/multiverse/script/runner +1 -1
  94. data/test/multiverse/suites/active_record/Envfile +1 -28
  95. data/test/multiverse/suites/active_record/active_record_test.rb +6 -6
  96. data/test/multiverse/suites/active_record/config/database.rb +2 -3
  97. data/test/multiverse/suites/active_record/config/database.yml +0 -2
  98. data/test/multiverse/suites/activemerchant/Envfile +4 -18
  99. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +7 -15
  100. data/test/multiverse/suites/agent_only/error_events_test.rb +1 -7
  101. data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +4 -20
  102. data/test/multiverse/suites/agent_only/labels_test.rb +1 -1
  103. data/test/multiverse/suites/agent_only/marshaling_test.rb +5 -10
  104. data/test/multiverse/suites/agent_only/script/public_api_when_disabled.rb +0 -11
  105. data/test/multiverse/suites/agent_only/start_up_test.rb +3 -3
  106. data/test/multiverse/suites/agent_only/synthetics_test.rb +1 -1
  107. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +0 -3
  108. data/test/multiverse/suites/agent_only/xray_sessions_test.rb +0 -3
  109. data/test/multiverse/suites/capistrano/Envfile +2 -4
  110. data/test/multiverse/suites/capistrano2/Envfile +0 -4
  111. data/test/multiverse/suites/curb/Envfile +3 -7
  112. data/test/multiverse/suites/datamapper/Envfile +2 -2
  113. data/test/multiverse/suites/datamapper/datamapper_test.rb +2 -2
  114. data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +0 -1
  115. data/test/multiverse/suites/delayed_job/Envfile +28 -41
  116. data/test/multiverse/suites/excon/Envfile +0 -3
  117. data/test/multiverse/suites/grape/Envfile +0 -4
  118. data/test/multiverse/suites/grape/grape_versioning_test.rb +2 -2
  119. data/test/multiverse/suites/grape/grape_versioning_test_api.rb +2 -2
  120. data/test/multiverse/suites/json/Envfile +1 -9
  121. data/test/multiverse/suites/marshalling/Envfile +0 -9
  122. data/test/multiverse/suites/memcached/Envfile +5 -23
  123. data/test/multiverse/suites/mongo/Envfile +9 -11
  124. data/test/multiverse/suites/padrino/Envfile +0 -6
  125. data/test/multiverse/suites/rack/http_response_code_test.rb +0 -1
  126. data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +5 -10
  127. data/test/multiverse/suites/rack/rack_cascade_test.rb +0 -1
  128. data/test/multiverse/suites/rack/rack_env_mutation_test.rb +0 -1
  129. data/test/multiverse/suites/rack/response_content_type_test.rb +0 -1
  130. data/test/multiverse/suites/rails/Envfile +1 -19
  131. data/test/multiverse/suites/rails/activejob_test.rb +1 -2
  132. data/test/multiverse/suites/rails/error_tracing_test.rb +0 -13
  133. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +12 -32
  134. data/test/multiverse/suites/rake/Envfile +15 -22
  135. data/test/multiverse/suites/redis/redis_instrumentation_test.rb +1 -1
  136. data/test/multiverse/suites/sequel/database.rb +1 -4
  137. data/test/multiverse/suites/sidekiq/Envfile +13 -23
  138. data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +3 -3
  139. data/test/multiverse/suites/typhoeus/Envfile +0 -19
  140. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +3 -3
  141. data/test/multiverse/suites/yajl/Envfile +5 -0
  142. data/test/multiverse/suites/yajl/yajl_test.rb +1 -3
  143. data/test/new_relic/agent/agent/start_test.rb +3 -3
  144. data/test/new_relic/agent/agent_logger_test.rb +2 -2
  145. data/test/new_relic/agent/agent_test.rb +2 -2
  146. data/test/new_relic/agent/attribute_processing_test.rb +3 -4
  147. data/test/new_relic/agent/audit_logger_test.rb +4 -6
  148. data/test/new_relic/agent/aws_info_test.rb +17 -1
  149. data/test/new_relic/agent/busy_calculator_test.rb +14 -16
  150. data/test/new_relic/agent/configuration/manager_test.rb +1 -7
  151. data/test/new_relic/agent/cross_app_monitor_test.rb +1 -1
  152. data/test/new_relic/agent/database_test.rb +2 -10
  153. data/test/new_relic/agent/datastores/mongo/event_formatter_test.rb +90 -93
  154. data/test/new_relic/agent/datastores/redis_test.rb +14 -16
  155. data/test/new_relic/agent/encoding_normalizer_test.rb +38 -40
  156. data/test/new_relic/agent/error_collector_test.rb +16 -49
  157. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +0 -6
  158. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
  159. data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +101 -103
  160. data/test/new_relic/agent/instrumentation/rack_test.rb +11 -14
  161. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +0 -10
  162. data/test/new_relic/agent/javascript_instrumentor_test.rb +2 -2
  163. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +0 -10
  164. data/test/new_relic/agent/method_tracer_test.rb +35 -76
  165. data/test/new_relic/agent/new_relic_service_test.rb +86 -102
  166. data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -9
  167. data/test/new_relic/agent/pipe_service_test.rb +2 -3
  168. data/test/new_relic/agent/rpm_agent_test.rb +0 -4
  169. data/test/new_relic/agent/sampled_buffer_test.rb +2 -2
  170. data/test/new_relic/agent/samplers/cpu_sampler_test.rb +28 -0
  171. data/test/new_relic/agent/samplers/memory_sampler_test.rb +66 -0
  172. data/test/new_relic/agent/sized_buffer_test.rb +1 -1
  173. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +2 -14
  174. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +44 -66
  175. data/test/new_relic/agent/stats_test.rb +6 -8
  176. data/test/new_relic/agent/synthetics_event_buffer_test.rb +1 -1
  177. data/test/new_relic/agent/transaction/attributes_test.rb +4 -12
  178. data/test/new_relic/agent/transaction_test.rb +2 -10
  179. data/test/new_relic/agent/utilization_data_test.rb +17 -1
  180. data/test/new_relic/agent/vm/mri_vm_test.rb +5 -7
  181. data/test/new_relic/agent_test.rb +0 -43
  182. data/test/new_relic/coerce_test.rb +1 -3
  183. data/test/new_relic/fake_collector.rb +3 -3
  184. data/test/new_relic/fake_external_server.rb +1 -1
  185. data/test/new_relic/fake_server.rb +1 -1
  186. data/test/new_relic/http_client_test_cases.rb +3 -3
  187. data/test/new_relic/language_support_test.rb +6 -12
  188. data/test/new_relic/latest_changes_test.rb +0 -11
  189. data/test/new_relic/license_test.rb +3 -8
  190. data/test/new_relic/multiverse_helpers.rb +1 -1
  191. data/test/new_relic/noticed_error_test.rb +11 -7
  192. data/test/new_relic/rack/browser_monitoring_test.rb +1 -3
  193. data/test/nullverse/nullverse_helper.rb +1 -1
  194. data/test/performance/lib/performance.rb +1 -1
  195. data/test/performance/lib/performance/instrumentation/gc_stats.rb +4 -6
  196. data/test/performance/lib/performance/instrumentation/perf_tools.rb +1 -1
  197. data/test/performance/lib/performance/instrumentation/stackprof.rb +1 -1
  198. data/test/performance/lib/performance/platform.rb +1 -8
  199. data/test/performance/script/runner +1 -3
  200. data/test/performance/suites/active_record.rb +3 -24
  201. data/test/test_helper.rb +9 -216
  202. metadata +9 -45
  203. data/lib/conditional_vendored_dependency_detection.rb +0 -7
  204. data/lib/new_relic/agent/hash_extensions.rb +0 -41
  205. data/lib/new_relic/agent/instrumentation/metric_frame.rb +0 -39
  206. data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -51
  207. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +0 -47
  208. data/lib/new_relic/agent/instrumentation/rails4/errors.rb +0 -46
  209. data/lib/new_relic/agent/stats_engine/samplers.rb +0 -22
  210. data/lib/new_relic/agent/vm/rubinius_vm.rb +0 -140
  211. data/lib/new_relic/json_wrapper.rb +0 -78
  212. data/lib/new_relic/okjson.rb +0 -602
  213. data/lib/new_relic/rack/error_collector.rb +0 -27
  214. data/lib/new_relic/timer_lib.rb +0 -31
  215. data/test/helpers/runtime_detection.rb +0 -17
  216. data/test/multiverse/suites/no_json/Envfile +0 -12
  217. data/test/multiverse/suites/no_json/config/newrelic.yml +0 -27
  218. data/test/multiverse/suites/no_json/marshal_config_test.rb +0 -22
  219. data/test/new_relic/agent/hash_extensions_test.rb +0 -59
  220. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +0 -22
  221. data/test/new_relic/agent/stats_engine/samplers_test.rb +0 -98
  222. data/test/new_relic/agent/vm/rubinius_vm_test.rb +0 -69
  223. data/test/new_relic/json_wrapper_test.rb +0 -32
  224. data/test/new_relic/rack/deferred_instrumentation_test.rb +0 -33
  225. data/test/new_relic/rack/error_collector_test.rb +0 -83
  226. data/test/new_relic/version_number_test.rb +0 -101
  227. data/test/script/before_install/revert_rubygems.sh +0 -15
  228. data/test/script/before_install/update_bundler.sh +0 -12
  229. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +0 -7
@@ -162,34 +162,32 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
162
162
  ])
163
163
  end
164
164
 
165
- unless NewRelic::LanguageSupport.rubinius? # Routine segfaults with rbx, see RUBY-1507
166
- def test_record_scoped_and_unscoped_metrics_is_thread_safe
167
- threads = []
168
- nthreads = 25
169
- iterations = 100
170
-
171
- nthreads.times do |tid|
172
- threads << Thread.new do
173
- iterations.times do
174
- in_transaction('txn') do
175
- @engine.tl_record_scoped_and_unscoped_metrics('m1', ['m3'], 1)
176
- @engine.tl_record_scoped_and_unscoped_metrics('m2', ['m4'], 1)
177
- end
165
+ def test_record_scoped_and_unscoped_metrics_is_thread_safe
166
+ threads = []
167
+ nthreads = 25
168
+ iterations = 100
169
+
170
+ nthreads.times do |tid|
171
+ threads << Thread.new do
172
+ iterations.times do
173
+ in_transaction('txn') do
174
+ @engine.tl_record_scoped_and_unscoped_metrics('m1', ['m3'], 1)
175
+ @engine.tl_record_scoped_and_unscoped_metrics('m2', ['m4'], 1)
178
176
  end
179
177
  end
180
178
  end
181
- threads.each { |t| t.join }
182
-
183
- expected = { :call_count => nthreads * iterations }
184
- assert_metrics_recorded(
185
- 'm1' => expected,
186
- 'm2' => expected,
187
- ['m1', 'txn'] => expected,
188
- ['m2', 'txn'] => expected,
189
- 'm3' => expected,
190
- 'm4' => expected
191
- )
192
179
  end
180
+ threads.each { |t| t.join }
181
+
182
+ expected = { :call_count => nthreads * iterations }
183
+ assert_metrics_recorded(
184
+ 'm1' => expected,
185
+ 'm2' => expected,
186
+ ['m1', 'txn'] => expected,
187
+ ['m2', 'txn'] => expected,
188
+ 'm3' => expected,
189
+ 'm4' => expected
190
+ )
193
191
  end
194
192
 
195
193
  def test_record_scoped_and_unscoped_metrics_records_unscoped_if_not_in_txn
@@ -206,41 +204,22 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
206
204
  )
207
205
  end
208
206
 
209
- def test_get_no_scope
210
- s1 = @engine.get_stats "a"
211
- s2 = @engine.get_stats "a"
212
- s3 = @engine.get_stats "b"
213
-
214
- refute_nil s1
215
- refute_nil s2
216
- refute_nil s3
217
-
218
- assert s1 == s2
219
- refute_same(s1, s3)
220
- end
221
-
222
207
  def test_harvest
223
208
  @engine.clear_stats
224
- s1 = @engine.get_stats "a"
225
- s2 = @engine.get_stats "c"
226
209
 
227
- s1.trace_call 10
228
- s2.trace_call 1
229
- s2.trace_call 3
210
+ @engine.tl_record_unscoped_metrics "a", 10
211
+ @engine.tl_record_unscoped_metrics "c", 1
212
+ @engine.tl_record_unscoped_metrics "c", 3
230
213
 
231
- assert_equal 1, @engine.get_stats("a").call_count
232
- assert_equal 10, @engine.get_stats("a").total_call_time
233
-
234
- assert_equal 2, @engine.get_stats("c").call_count
235
- assert_equal 4, @engine.get_stats("c").total_call_time
214
+ assert_metrics_recorded({
215
+ "a" => {:call_count => 1, :total_call_time => 10},
216
+ "c" => {:call_count => 2, :total_call_time => 4}
217
+ })
236
218
 
237
219
  harvested = @engine.harvest!.to_h
238
220
 
239
221
  # after harvest, all the metrics should be reset
240
- assert_equal 0, @engine.get_stats("a").call_count
241
- assert_equal 0, @engine.get_stats("a").total_call_time
242
- assert_equal 0, @engine.get_stats("c").call_count
243
- assert_equal 0, @engine.get_stats("c").total_call_time
222
+ refute_metrics_recorded %w(a c)
244
223
 
245
224
  spec_a = NewRelic::MetricSpec.new('a')
246
225
 
@@ -258,9 +237,9 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
258
237
  rules_engine = NewRelic::Agent::RulesEngine.new([rule])
259
238
 
260
239
  @engine.metric_rules = rules_engine
261
- @engine.get_stats_no_scope('Custom/foo/1/bar/22').record_data_point(1)
262
- @engine.get_stats_no_scope('Custom/foo/3/bar/44').record_data_point(1)
263
- @engine.get_stats_no_scope('Custom/foo/5/bar/66').record_data_point(1)
240
+ @engine.tl_record_unscoped_metrics('Custom/foo/1/bar/22', 1)
241
+ @engine.tl_record_unscoped_metrics('Custom/foo/3/bar/44', 1)
242
+ @engine.tl_record_unscoped_metrics('Custom/foo/5/bar/66', 1)
264
243
 
265
244
  harvested = @engine.harvest!.to_h
266
245
 
@@ -290,16 +269,15 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
290
269
  end
291
270
 
292
271
  def test_harvest_with_merge
293
- s = @engine.get_stats "a"
294
- s.trace_call 1
295
- assert_equal 1, @engine.get_stats("a").call_count
272
+ @engine.tl_record_unscoped_metrics "a", 1
273
+ assert_metrics_recorded "a" => {:call_count => 1, :total_call_time => 1}
296
274
 
297
275
  harvest = @engine.harvest!
298
276
 
299
- s = @engine.get_stats "a"
300
- assert_equal 0, s.call_count
301
- s.trace_call 2
302
- assert_equal 1, s.call_count
277
+ assert_metrics_not_recorded "a"
278
+
279
+ @engine.tl_record_unscoped_metrics "a", 2
280
+ assert_metrics_recorded "a" => {:call_count => 1, :total_call_time => 2}
303
281
 
304
282
  # this should merge the contents of the previous harvest,
305
283
  # so the stats for metric "a" should have 2 data points
@@ -311,7 +289,7 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
311
289
  end
312
290
 
313
291
  def test_merge_merges
314
- @engine.get_stats("foo").record_data_point(1)
292
+ @engine.tl_record_unscoped_metrics "foo", 1
315
293
 
316
294
  other_stats_hash = NewRelic::Agent::StatsHash.new()
317
295
  other_stats_hash.record(NewRelic::MetricSpec.new('foo'), 1)
@@ -319,10 +297,10 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
319
297
 
320
298
  @engine.merge!(other_stats_hash)
321
299
 
322
- foo_stats = @engine.get_stats('foo')
323
- bar_stats = @engine.get_stats('bar')
324
- assert_equal(2, foo_stats.call_count)
325
- assert_equal(1, bar_stats.call_count)
300
+ assert_metrics_recorded ({
301
+ 'foo' => {:call_count => 2},
302
+ 'bar' => {:call_count => 1}
303
+ })
326
304
  end
327
305
 
328
306
  def test_harvest_adds_harvested_at_time
@@ -168,18 +168,16 @@ class NewRelic::Agent::StatsTest < Minitest::Test
168
168
  assert_equal(42, chained_stats.total_call_time)
169
169
  end
170
170
 
171
- if RUBY_VERSION >= '1.9'
172
- def test_to_json_enforces_float_values
173
- s1 = NewRelic::Agent::Stats.new
174
- s1.trace_call 3.to_r
175
- s1.trace_call 7.to_r
171
+ def test_to_json_enforces_float_values
172
+ s1 = NewRelic::Agent::Stats.new
173
+ s1.trace_call 3.to_r
174
+ s1.trace_call 7.to_r
176
175
 
177
- assert_equal 3.0, JSON.load(s1.to_json)['min_call_time']
178
- end
176
+ assert_equal 3.0, JSON.load(s1.to_json)['min_call_time']
179
177
  end
180
178
 
181
179
  private
182
- def validate (stats, count, total, min, max, exclusive = nil)
180
+ def validate(stats, count, total, min, max, exclusive = nil)
183
181
  assert_equal count, stats.call_count
184
182
  assert_equal total, stats.total_call_time
185
183
  assert_equal min, stats.min_call_time
@@ -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
- require 'test/new_relic/agent/event_buffer_test_cases'
6
+ require 'new_relic/agent/event_buffer_test_cases'
7
7
  require 'new_relic/agent/synthetics_event_buffer'
8
8
 
9
9
  module NewRelic::Agent
@@ -118,12 +118,8 @@ class AttributesTest < Minitest::Test
118
118
 
119
119
  custom_attributes = attributes.custom_attributes_for(AttributeFilter::DST_TRANSACTION_TRACER)
120
120
  result = custom_attributes["key"]
121
- if RUBY_VERSION >= "1.9.3"
122
- assert result.valid_encoding?
123
- assert result.bytesize < NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT
124
- else
125
- assert_equal NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT, result.bytesize
126
- end
121
+ assert result.valid_encoding?
122
+ assert result.bytesize < NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT
127
123
  end
128
124
 
129
125
  def test_truncates_multibyte_symbol
@@ -135,12 +131,8 @@ class AttributesTest < Minitest::Test
135
131
 
136
132
  custom_attributes = attributes.custom_attributes_for(AttributeFilter::DST_TRANSACTION_TRACER)
137
133
  result = custom_attributes["key"]
138
- if RUBY_VERSION >= "1.9.3"
139
- assert result.valid_encoding?
140
- assert result.bytesize < NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT
141
- else
142
- assert_equal NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT, result.bytesize
143
- end
134
+ assert result.valid_encoding?
135
+ assert result.bytesize < NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT
144
136
  end
145
137
 
146
138
  def test_limits_key_length
@@ -680,13 +680,6 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
680
680
  end
681
681
  end
682
682
 
683
- def test_user_attributes_alias_to_custom_parameters
684
- in_transaction('user_attributes') do |txn|
685
- txn.set_user_attributes(:set_instance => :set_instance)
686
- assert_has_custom_attribute(txn, "set_instance")
687
- end
688
- end
689
-
690
683
  def test_notice_error_in_current_transaction_saves_it_for_finishing
691
684
  in_transaction('failing') do |txn|
692
685
  NewRelic::Agent::Transaction.notice_error("")
@@ -885,11 +878,10 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
885
878
  end
886
879
 
887
880
  def with_java_classes_loaded
888
- # class_variable_set is private on 1.8.7 :(
889
- ::NewRelic::Agent::Transaction.send(:class_variable_set, :@@java_classes_loaded, true)
881
+ ::NewRelic::Agent::Transaction.class_variable_set :@@java_classes_loaded, true
890
882
  yield
891
883
  ensure
892
- ::NewRelic::Agent::Transaction.send(:class_variable_set, :@@java_classes_loaded, false)
884
+ ::NewRelic::Agent::Transaction.class_variable_set :@@java_classes_loaded, false
893
885
  end
894
886
 
895
887
  def test_cpu_burn_normal
@@ -7,6 +7,22 @@ require 'new_relic/agent/utilization_data'
7
7
 
8
8
  module NewRelic::Agent
9
9
  class UtilizationDataTest < Minitest::Test
10
+
11
+ # recurses through hashes and arrays and symbolizes keys
12
+ def self.symbolize_keys_in_object(object)
13
+ case object
14
+ when Hash
15
+ object.inject({}) do |memo, (k, v)|
16
+ memo[k.to_sym] = symbolize_keys_in_object(v)
17
+ memo
18
+ end
19
+ when Array
20
+ object.map {|o| symbolize_keys_in_object(o)}
21
+ else
22
+ object
23
+ end
24
+ end
25
+
10
26
  def setup
11
27
  stub_aws_info
12
28
  end
@@ -170,7 +186,7 @@ module NewRelic::Agent
170
186
 
171
187
  load_cross_agent_test("utilization/utilization_json").each do |test_case|
172
188
 
173
- test_case = HashExtensions.symbolize_keys_in_object test_case
189
+ test_case = NewRelic::Agent::UtilizationDataTest.symbolize_keys_in_object test_case
174
190
  define_method("test_#{test_case[:testname]}".tr(" ", "_")) do
175
191
  setup_cross_agent_test_stubs test_case
176
192
  # This is a little bit ugly, but TravisCI runs these tests in a docker environment,
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..', '..','..','test_helper'))
6
6
  require 'new_relic/agent/vm/mri_vm'
7
7
 
8
- unless NewRelic::LanguageSupport.jruby? || NewRelic::LanguageSupport.rubinius?
8
+ unless NewRelic::LanguageSupport.jruby?
9
9
  module NewRelic
10
10
  module Agent
11
11
  module VM
@@ -15,12 +15,10 @@ unless NewRelic::LanguageSupport.jruby? || NewRelic::LanguageSupport.rubinius?
15
15
  @vm = MriVM.new
16
16
  end
17
17
 
18
- unless RUBY_VERSION < '1.9.2'
19
- def test_gather_gc_time_sets_gc_total_time_if_gc_profiler_is_enabled
20
- NewRelic::LanguageSupport.stubs(:gc_profiler_enabled?).returns(true)
21
- @vm.gather_gc_time(@snap)
22
- refute_nil @snap.gc_total_time
23
- end
18
+ def test_gather_gc_time_sets_gc_total_time_if_gc_profiler_is_enabled
19
+ NewRelic::LanguageSupport.stubs(:gc_profiler_enabled?).returns(true)
20
+ @vm.gather_gc_time(@snap)
21
+ refute_nil @snap.gc_total_time
24
22
  end
25
23
 
26
24
  def test_gather_gc_time_does_not_set_gc_total_time_if_gc_profiler_is_disabled
@@ -63,12 +63,6 @@ module NewRelic
63
63
  NewRelic::Agent.after_fork
64
64
  end
65
65
 
66
- def test_reset_stats
67
- mock_agent = mocked_agent
68
- mock_agent.expects(:drop_buffered_data)
69
- NewRelic::Agent.reset_stats
70
- end
71
-
72
66
  def test_manual_start_default
73
67
  mock_control = mocked_control
74
68
  mock_control.expects(:init_plugin).with({:agent_enabled => true, :sync_startup => true})
@@ -100,23 +94,6 @@ module NewRelic
100
94
  NewRelic::Agent.shutdown
101
95
  end
102
96
 
103
- def test_get_stats
104
- agent = mocked_agent
105
- mock_stats_engine = mock('stats_engine')
106
- agent.expects(:stats_engine).returns(mock_stats_engine)
107
- mock_stats_engine.expects(:get_stats).with('Custom/test/metric', false)
108
- NewRelic::Agent.get_stats('Custom/test/metric')
109
- end
110
-
111
- # note that this is the same as get_stats above, they're just aliases
112
- def test_get_stats_no_scope
113
- agent = mocked_agent
114
- mock_stats_engine = mock('stats_engine')
115
- agent.expects(:stats_engine).returns(mock_stats_engine)
116
- mock_stats_engine.expects(:get_stats).with('Custom/test/metric', false)
117
- NewRelic::Agent.get_stats_no_scope('Custom/test/metric')
118
- end
119
-
120
97
  def test_agent_logs_warning_when_not_started
121
98
  with_unstarted_agent do
122
99
  expects_logging(:warn, includes("hasn't been started"))
@@ -137,11 +114,6 @@ module NewRelic
137
114
  NewRelic::Agent.instance_eval { @agent = old_agent }
138
115
  end
139
116
 
140
- def test_abort_transaction_bang
141
- NewRelic::Agent::Transaction.expects(:abort_transaction!)
142
- NewRelic::Agent.abort_transaction!
143
- end
144
-
145
117
  def test_is_transaction_traced_true
146
118
  NewRelic::Agent::TransactionState.tl_get.record_tt = true
147
119
  assert_equal(true, NewRelic::Agent.tl_is_transaction_traced?, 'should be true since the thread local is set')
@@ -420,21 +392,6 @@ module NewRelic
420
392
  end
421
393
  end
422
394
 
423
- def test_add_custom_parameters_deprecated
424
- NewRelic::Agent::Deprecator.expects(:deprecate)
425
- NewRelic::Agent.add_custom_parameters(:is => "bunk")
426
- end
427
-
428
- def test_add_request_parameters_deprecated
429
- NewRelic::Agent::Deprecator.expects(:deprecate)
430
- NewRelic::Agent.add_request_parameters(:is => "bunk")
431
- end
432
-
433
- def test_set_user_attributes_deprecated
434
- NewRelic::Agent::Deprecator.expects(:deprecate)
435
- NewRelic::Agent.set_user_attributes(:is => "bunk")
436
- end
437
-
438
395
  def test_modules_and_classes_return_name_properly
439
396
  valid = [Module, Class]
440
397
  stack = [NewRelic]
@@ -16,9 +16,7 @@ class CoerceTest < Minitest::Test
16
16
  assert_equal 1, int(Rational(1, 1))
17
17
  assert_equal 0, int("invalid")
18
18
  assert_equal 0, int(nil)
19
-
20
- # http://ruby-doc.org/core-1.8.7/Symbol.html#method-i-to_i
21
- assert_equal 0, int(:wat) unless RUBY_VERSION < '1.9'
19
+ assert_equal 0, int(:wat)
22
20
  end
23
21
 
24
22
  def test_int_coerce_logs
@@ -10,7 +10,7 @@ require 'timeout'
10
10
  require 'ostruct'
11
11
  require 'fake_server'
12
12
 
13
- require 'json' if RUBY_VERSION >= '1.9'
13
+ require 'json'
14
14
 
15
15
  module NewRelic
16
16
  class FakeCollector < FakeServer
@@ -117,7 +117,7 @@ module NewRelic
117
117
  if @mock.keys.include? method
118
118
  status, body = @mock[method].evaluate
119
119
  res.status = status
120
- res.write ::NewRelic::JSONWrapper.dump(body)
120
+ res.write ::JSON.dump(body)
121
121
  else
122
122
  res.status = 500
123
123
  res.write "Method not found"
@@ -129,7 +129,7 @@ module NewRelic
129
129
  raw_body = req.body.read
130
130
  raw_body = Zlib::Inflate.inflate(raw_body) if req.env["HTTP_CONTENT_ENCODING"] == "deflate"
131
131
 
132
- body = ::NewRelic::JSONWrapper.load(raw_body)
132
+ body = ::JSON.load(raw_body)
133
133
  rescue
134
134
  body = "UNABLE TO DECODE BODY: #{raw_body}"
135
135
 
@@ -6,7 +6,7 @@ require 'rack'
6
6
  require 'new_relic/fake_server'
7
7
  require 'new_relic/rack/agent_hooks'
8
8
 
9
- require 'json' if RUBY_VERSION >= '1.9'
9
+ require 'json'
10
10
 
11
11
  module NewRelic
12
12
  class FakeExternalServer < FakeServer
@@ -8,7 +8,7 @@ require 'rack'
8
8
  require 'rack/handler'
9
9
  require 'timeout'
10
10
 
11
- require 'json' if RUBY_VERSION >= '1.9'
11
+ require 'json'
12
12
 
13
13
  module NewRelic
14
14
  class FakeServer
@@ -437,7 +437,7 @@ module HttpClientTestCases
437
437
  # https://newrelic.atlassian.net/browse/RUBY-1244
438
438
  def test_failure_in_our_start_code_still_records_externals
439
439
  # Fake a failure in our start-up code...
440
- NewRelic::JSONWrapper.stubs(:dump).raises("Boom!")
440
+ ::JSON.stubs(:dump).raises("Boom!")
441
441
 
442
442
  with_config(:"cross_application_tracer.enabled" => true) do
443
443
  in_transaction { get_response }
@@ -449,7 +449,7 @@ module HttpClientTestCases
449
449
  # https://newrelic.atlassian.net/browse/RUBY-1244
450
450
  def test_failure_to_add_tt_node_doesnt_append_params_to_wrong_node
451
451
  # Fake a failure in our start-up code...
452
- NewRelic::JSONWrapper.stubs(:dump).raises("Boom!")
452
+ ::JSON.stubs(:dump).raises("Boom!")
453
453
 
454
454
  in_transaction do
455
455
  with_config(:"cross_application_tracer.enabled" => true) do
@@ -606,7 +606,7 @@ module HttpClientTestCases
606
606
 
607
607
  def decode_payload(payload)
608
608
  obfuscator = NewRelic::Agent::Obfuscator.new('gringletoes')
609
- NewRelic::JSONWrapper.load(obfuscator.deobfuscate(payload))
609
+ ::JSON.load(obfuscator.deobfuscate(payload))
610
610
  end
611
611
 
612
612
  def set_explicit_transaction_name(name)