newrelic_rpm 3.10.0.279 → 3.11.0.283

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +61 -0
  3. data/lib/new_relic/agent.rb +14 -8
  4. data/lib/new_relic/agent/agent.rb +43 -28
  5. data/lib/new_relic/agent/agent_logger.rb +21 -20
  6. data/lib/new_relic/agent/configuration/default_source.rb +31 -1
  7. data/lib/new_relic/agent/database.rb +2 -1
  8. data/lib/new_relic/agent/datastores.rb +177 -0
  9. data/lib/new_relic/agent/datastores/metric_helper.rb +85 -0
  10. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +11 -20
  11. data/lib/new_relic/agent/deprecator.rb +18 -0
  12. data/lib/new_relic/agent/instrumentation/active_record.rb +20 -35
  13. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +116 -57
  14. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +11 -20
  15. data/lib/new_relic/agent/instrumentation/data_mapper.rb +104 -172
  16. data/lib/new_relic/agent/instrumentation/memcache.rb +104 -52
  17. data/lib/new_relic/agent/instrumentation/metric_frame.rb +9 -0
  18. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +15 -2
  19. data/lib/new_relic/agent/instrumentation/mongo.rb +5 -18
  20. data/lib/new_relic/agent/instrumentation/sequel_helper.rb +36 -0
  21. data/lib/new_relic/agent/new_relic_service.rb +4 -0
  22. data/lib/new_relic/agent/stats_engine/metric_stats.rb +2 -17
  23. data/lib/new_relic/agent/threading/backtrace_service.rb +28 -5
  24. data/lib/new_relic/agent/transaction.rb +63 -34
  25. data/lib/new_relic/agent/transaction_event_aggregator.rb +0 -4
  26. data/lib/new_relic/agent/transaction_sampler.rb +11 -5
  27. data/lib/new_relic/rack/error_collector.rb +0 -1
  28. data/lib/new_relic/version.rb +1 -1
  29. data/lib/sequel/extensions/newrelic_instrumentation.rb +28 -56
  30. data/lib/sequel/plugins/newrelic_instrumentation.rb +28 -45
  31. data/newrelic_rpm.gemspec +0 -7
  32. data/test/agent_helper.rb +35 -16
  33. data/test/environments/rails31/Gemfile +1 -0
  34. data/test/environments/rails32/Gemfile +1 -0
  35. data/test/helpers/mongo_metric_builder.rb +2 -3
  36. data/test/multiverse/lib/multiverse/output_collector.rb +24 -9
  37. data/test/multiverse/lib/multiverse/suite.rb +5 -0
  38. data/test/multiverse/suites/active_record/Envfile +6 -4
  39. data/test/multiverse/suites/active_record/active_record_test.rb +32 -73
  40. data/test/multiverse/suites/active_record/ar_method_aliasing.rb +0 -1
  41. data/test/multiverse/suites/activemerchant/activemerchant_test.rb +0 -3
  42. data/test/multiverse/suites/agent_only/agent_run_id_handling_test.rb +0 -1
  43. data/test/multiverse/suites/agent_only/audit_log_test.rb +0 -1
  44. data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +0 -2
  45. data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +0 -1
  46. data/test/multiverse/suites/agent_only/custom_analytics_events_test.rb +0 -2
  47. data/test/multiverse/suites/agent_only/custom_queue_time_test.rb +0 -1
  48. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +0 -2
  49. data/test/multiverse/suites/agent_only/exclusive_time_test.rb +0 -2
  50. data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +0 -1
  51. data/test/multiverse/suites/agent_only/http_response_code_test.rb +0 -1
  52. data/test/multiverse/suites/agent_only/keepalive_test.rb +0 -1
  53. data/test/multiverse/suites/agent_only/key_transactions_test.rb +54 -9
  54. data/test/multiverse/suites/agent_only/labels_test.rb +0 -2
  55. data/test/multiverse/suites/agent_only/logging_test.rb +0 -1
  56. data/test/multiverse/suites/agent_only/marshaling_test.rb +0 -1
  57. data/test/multiverse/suites/agent_only/pipe_manager_test.rb +0 -2
  58. data/test/multiverse/suites/agent_only/rename_rule_test.rb +5 -7
  59. data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +0 -1
  60. data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +0 -2
  61. data/test/multiverse/suites/agent_only/ssl_test.rb +0 -2
  62. data/test/multiverse/suites/agent_only/synthetics_test.rb +0 -1
  63. data/test/multiverse/suites/agent_only/testing_app.rb +21 -0
  64. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +1 -2
  65. data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +0 -2
  66. data/test/multiverse/suites/agent_only/utilization_data_collection_test.rb +0 -1
  67. data/test/multiverse/suites/agent_only/xray_sessions_test.rb +69 -34
  68. data/test/multiverse/suites/capistrano/deployment_test.rb +0 -1
  69. data/test/multiverse/suites/capistrano2/deployment_test.rb +0 -1
  70. data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +0 -2
  71. data/test/multiverse/suites/curb/curb_test.rb +0 -2
  72. data/test/multiverse/suites/datamapper/Envfile +26 -3
  73. data/test/multiverse/suites/datamapper/config/newrelic.yml +1 -0
  74. data/test/multiverse/suites/datamapper/datamapper_test.rb +271 -37
  75. data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +0 -1
  76. data/test/multiverse/suites/delayed_job/Envfile +31 -8
  77. data/test/multiverse/suites/delayed_job/delayed_job_sampler_test.rb +0 -3
  78. data/test/multiverse/suites/delayed_job/unsupported_backend_test.rb +0 -3
  79. data/test/multiverse/suites/excon/excon_test.rb +0 -2
  80. data/test/multiverse/suites/grape/grape_test.rb +0 -3
  81. data/test/multiverse/suites/grape/grape_versioning_test.rb +0 -3
  82. data/test/multiverse/suites/grape/unsupported_version_test.rb +0 -3
  83. data/test/multiverse/suites/high_security/high_security_test.rb +0 -1
  84. data/test/multiverse/suites/httpclient/httpclient_test.rb +0 -2
  85. data/test/multiverse/suites/json/json_test.rb +0 -1
  86. data/test/multiverse/suites/marshalling/marshalling_test.rb +0 -1
  87. data/test/multiverse/suites/memcached/Envfile +52 -0
  88. data/test/multiverse/suites/memcached/dalli_test.rb +89 -0
  89. data/test/multiverse/suites/memcached/memcache_client_test.rb +25 -0
  90. data/test/multiverse/suites/memcached/memcache_test_cases.rb +302 -0
  91. data/test/multiverse/suites/memcached/memcached_test.rb +159 -0
  92. data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +26 -17
  93. data/test/multiverse/suites/mongo/mongo_connection_test.rb +0 -1
  94. data/test/multiverse/suites/mongo/mongo_instrumentation_test.rb +0 -1
  95. data/test/multiverse/suites/mongo/mongo_unsupported_version_test.rb +0 -1
  96. data/test/multiverse/suites/net_http/net_http_test.rb +0 -2
  97. data/test/multiverse/suites/padrino/padrino_test.rb +0 -3
  98. data/test/multiverse/suites/rack/http_response_code_test.rb +0 -1
  99. data/test/multiverse/suites/rack/nested_non_rack_app_test.rb +1 -1
  100. data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +12 -12
  101. data/test/multiverse/suites/rack/rack_cascade_test.rb +0 -1
  102. data/test/multiverse/suites/rack/rack_env_mutation_test.rb +0 -1
  103. data/test/multiverse/suites/rack/rack_parameter_filtering_test.rb +0 -1
  104. data/test/multiverse/suites/rack/rack_unsupported_version_test.rb +0 -2
  105. data/test/multiverse/suites/rack/url_map_test.rb +3 -2
  106. data/test/multiverse/suites/rails/Envfile +3 -0
  107. data/test/multiverse/suites/rails/activejob_test.rb +0 -1
  108. data/test/multiverse/suites/rails/app.rb +0 -1
  109. data/test/multiverse/suites/rails/parameter_capture_test.rb +13 -0
  110. data/test/multiverse/suites/rails/rails3_app/app_rails3_plus.rb +5 -0
  111. data/test/multiverse/suites/rails/transaction_ignoring_test.rb +0 -2
  112. data/test/multiverse/suites/resque/instrumentation_test.rb +0 -2
  113. data/test/multiverse/suites/resque/resque_marshalling_test.rb +0 -1
  114. data/test/multiverse/suites/sequel/sequel_extension_test.rb +135 -0
  115. data/test/multiverse/suites/sequel/sequel_helpers.rb +62 -0
  116. data/test/multiverse/suites/sequel/sequel_plugin_test.rb +230 -0
  117. data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +0 -2
  118. data/test/multiverse/suites/sinatra/ignoring_test.rb +0 -2
  119. data/test/multiverse/suites/sinatra/nested_middleware_test.rb +0 -2
  120. data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +0 -1
  121. data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +0 -2
  122. data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +14 -12
  123. data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +0 -1
  124. data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +0 -2
  125. data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +0 -2
  126. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +0 -2
  127. data/test/multiverse/suites/yajl/yajl_test.rb +0 -1
  128. data/test/new_relic/agent/agent/start_test.rb +2 -2
  129. data/test/new_relic/agent/agent_logger_test.rb +6 -3
  130. data/test/new_relic/agent/datastores/metric_helper_test.rb +61 -0
  131. data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +20 -21
  132. data/test/new_relic/agent/datastores_test.rb +195 -0
  133. data/test/new_relic/agent/deprecator_test.rb +52 -0
  134. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +20 -26
  135. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +58 -53
  136. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +7 -20
  137. data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +19 -0
  138. data/test/new_relic/agent/instrumentation/sequel_helper_test.rb +36 -0
  139. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +1 -0
  140. data/test/new_relic/agent/method_tracer_test.rb +3 -4
  141. data/test/new_relic/agent/pipe_channel_manager_test.rb +1 -1
  142. data/test/new_relic/agent/threading/backtrace_service_test.rb +29 -4
  143. data/test/new_relic/agent/transaction_event_aggregator_test.rb +0 -4
  144. data/test/new_relic/agent/transaction_test.rb +100 -2
  145. data/test/new_relic/agent_test.rb +3 -3
  146. data/test/new_relic/http_client_test_cases.rb +0 -1
  147. data/test/new_relic/multiverse_helpers.rb +7 -0
  148. data/test/new_relic/transaction_ignoring_test_cases.rb +0 -2
  149. data/test/new_relic/transaction_sample_test.rb +11 -2
  150. data/test/performance/README.md +37 -17
  151. data/test/performance/lib/performance.rb +1 -0
  152. data/test/performance/lib/performance/baseline_compare_reporter.rb +11 -7
  153. data/test/performance/lib/performance/console_reporter.rb +29 -5
  154. data/test/performance/lib/performance/formatting_helpers.rb +22 -0
  155. data/test/performance/lib/performance/instrumentation/stackprof.rb +11 -1
  156. data/test/performance/lib/performance/result.rb +17 -6
  157. data/test/performance/lib/performance/runner.rb +7 -3
  158. data/test/performance/lib/performance/test_case.rb +89 -21
  159. data/test/performance/script/runner +13 -1
  160. data/test/performance/suites/active_record.rb +47 -0
  161. data/test/performance/suites/config.rb +4 -48
  162. data/test/performance/suites/marshalling.rb +20 -30
  163. data/test/performance/suites/queue_time.rb +1 -1
  164. data/test/performance/suites/rack_middleware.rb +1 -1
  165. data/test/performance/suites/rum_autoinsertion.rb +1 -1
  166. data/test/performance/suites/sql_obfuscation.rb +2 -2
  167. data/test/performance/suites/startup.rb +1 -1
  168. data/test/performance/suites/stats_hash.rb +7 -11
  169. data/test/performance/suites/thread_profiling.rb +20 -25
  170. data/test/performance/suites/trace_execution_scoped.rb +2 -2
  171. data/test/performance/suites/transaction_tracing.rb +4 -2
  172. data/test/test_helper.rb +5 -1
  173. metadata +53 -100
  174. data.tar.gz.sig +0 -0
  175. data/gem-public_cert.pem +0 -20
  176. data/lib/new_relic/agent/datastores/mongo/metric_generator.rb +0 -33
  177. data/test/multiverse/suites/sequel/sequel_instrumentation_test.rb +0 -289
  178. data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +0 -69
  179. data/test/new_relic/agent/memcache_instrumentation_test.rb +0 -155
  180. metadata.gz.sig +0 -2
@@ -418,6 +418,7 @@ module Multiverse
418
418
  patch_minitest_base_for_old_versions
419
419
  prevent_minitest_auto_run
420
420
  require_mocha
421
+ require_helpers
421
422
  end
422
423
 
423
424
  def patch_minitest_base_for_old_versions
@@ -464,6 +465,10 @@ module Multiverse
464
465
  ENV["NEWRELIC_OMIT_FAKE_COLLECTOR"] = "true" if environments.omit_collector
465
466
  end
466
467
 
468
+ def require_helpers
469
+ require 'multiverse_helpers'
470
+ end
471
+
467
472
  def execute_ruby_files
468
473
  Dir.chdir directory
469
474
  ordered_ruby_files(directory).each do |file|
@@ -9,20 +9,22 @@ boilerplate_gems = <<-BOILERPLATE
9
9
  BOILERPLATE
10
10
 
11
11
  if RUBY_VERSION >= '1.9.3'
12
- # JRuby currently having problem with Rails 4.2 beta. Remove condition on GA.
13
- if !defined?(RUBY_ENGINE) || RUBY_ENGINE != 'jruby'
14
12
  gemfile <<-RB
15
- gem 'activerecord', '~> 4.2.0.rc1'
13
+ gem 'activerecord', '~> 4.2.0'
16
14
  gem 'minitest', '~> 5.2.3'
17
15
  #{boilerplate_gems}
18
16
  RB
19
- end
20
17
 
21
18
  gemfile <<-RB
22
19
  gem 'activerecord', '~> 4.1.6'
23
20
  gem 'minitest', '~> 5.2.3'
24
21
  #{boilerplate_gems}
25
22
  RB
23
+
24
+ gemfile <<-RB
25
+ gem 'activerecord', '~> 4.0.11'
26
+ #{boilerplate_gems}
27
+ RB
26
28
  end
27
29
 
28
30
  gemfile <<-RB
@@ -2,7 +2,6 @@
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 'multiverse_helpers'
6
5
  require File.expand_path(File.join(__FILE__, "..", "app", "models", "models"))
7
6
 
8
7
  class ActiveRecordInstrumentationTest < Minitest::Test
@@ -25,7 +24,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
25
24
  else
26
25
  assert_activerecord_metrics(Order, 'create')
27
26
  end
28
- assert_remote_service_metrics
29
27
  end
30
28
 
31
29
  def test_metrics_for_create_via_association
@@ -36,7 +34,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
36
34
  end
37
35
 
38
36
  assert_generic_rollup_metrics('insert')
39
- assert_remote_service_metrics
40
37
  end
41
38
 
42
39
  def test_metrics_for_find
@@ -49,17 +46,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
49
46
  end
50
47
 
51
48
  assert_activerecord_metrics(Order, 'find')
52
- assert_remote_service_metrics
53
- end
54
-
55
- def test_metrics_for_find_by_id
56
- in_web_transaction do
57
- order = Order.create(:name => 'kathy')
58
- Order.find(order.id)
59
- end
60
-
61
- assert_activerecord_metrics(Order, 'find')
62
- assert_remote_service_metrics
63
49
  end
64
50
 
65
51
  def test_metrics_for_find_via_association
@@ -70,7 +56,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
70
56
  end
71
57
 
72
58
  assert_activerecord_metrics(Shipment, 'find')
73
- assert_remote_service_metrics
74
59
  end
75
60
 
76
61
  def test_metrics_for_find_all
@@ -86,7 +71,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
86
71
  end
87
72
 
88
73
  assert_activerecord_metrics(Order, 'find')
89
- assert_remote_service_metrics
90
74
  end
91
75
 
92
76
  def test_metrics_for_find_via_named_scope
@@ -111,7 +95,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
111
95
  end
112
96
 
113
97
  assert_activerecord_metrics(Order, 'find')
114
- assert_remote_service_metrics
115
98
  end
116
99
 
117
100
  def test_metrics_for_exists
@@ -125,7 +108,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
125
108
  else
126
109
  assert_activerecord_metrics(Order, 'find')
127
110
  end
128
- assert_remote_service_metrics
129
111
  end
130
112
 
131
113
  def test_metrics_for_update
@@ -135,12 +117,7 @@ class ActiveRecordInstrumentationTest < Minitest::Test
135
117
  order.save
136
118
  end
137
119
 
138
- if active_record_major_version >= 3
139
- assert_generic_rollup_metrics('update')
140
- else
141
- assert_activerecord_metrics(Order, 'save')
142
- end
143
- assert_remote_service_metrics
120
+ assert_generic_rollup_metrics('update')
144
121
  end
145
122
 
146
123
  def test_metrics_for_destroy
@@ -154,7 +131,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
154
131
  else
155
132
  assert_activerecord_metrics(Order, 'destroy')
156
133
  end
157
- assert_remote_service_metrics
158
134
  end
159
135
 
160
136
  def test_metrics_for_direct_sql_select
@@ -164,7 +140,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
164
140
  end
165
141
 
166
142
  assert_generic_rollup_metrics('select')
167
- assert_remote_service_metrics
168
143
  end
169
144
 
170
145
  def test_metrics_for_direct_sql_other
@@ -175,7 +150,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
175
150
  end
176
151
 
177
152
  assert_generic_rollup_metrics('other')
178
- assert_remote_service_metrics
179
153
  end
180
154
 
181
155
  def test_metrics_for_direct_sql_show
@@ -186,7 +160,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
186
160
  end
187
161
 
188
162
  assert_generic_rollup_metrics('show')
189
- assert_remote_service_metrics
190
163
  end
191
164
  end
192
165
 
@@ -207,7 +180,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
207
180
  end
208
181
 
209
182
  assert_generic_rollup_metrics('select')
210
- assert_remote_service_metrics
211
183
  end
212
184
 
213
185
  def test_passes_through_errors
@@ -235,9 +207,9 @@ class ActiveRecordInstrumentationTest < Minitest::Test
235
207
  Order.first
236
208
  end
237
209
  sample = NewRelic::Agent.instance.transaction_sampler.last_sample
238
- segment = find_segment_with_name(sample, 'ActiveRecord/Order/find')
239
-
240
- assert_equal('ActiveRecord/Order/find', segment.metric_name)
210
+ metric = "Datastore/statement/#{current_product}/Order/find"
211
+ segment = find_segment_with_name(sample, metric)
212
+ assert_equal(metric, segment.metric_name)
241
213
 
242
214
  sql = segment.params[:sql]
243
215
  assert_match(/^SELECT /, sql)
@@ -254,7 +226,8 @@ class ActiveRecordInstrumentationTest < Minitest::Test
254
226
  end
255
227
 
256
228
  sample = NewRelic::Agent.instance.transaction_sampler.last_sample
257
- sql_segment = find_segment_with_name(sample, 'ActiveRecord/Order/find')
229
+ metric = "Datastore/statement/#{current_product}/Order/find"
230
+ sql_segment = find_segment_with_name(sample, metric)
258
231
 
259
232
  assert_match(/^SELECT /, sql_segment.params[:sql])
260
233
 
@@ -268,31 +241,24 @@ class ActiveRecordInstrumentationTest < Minitest::Test
268
241
  end
269
242
  end
270
243
 
244
+ def test_sql_samplers_get_proper_metrics
245
+ with_config(:'transaction_tracer.explain_threshold' => -0.1) do
246
+ in_web_transaction do
247
+ Order.first
248
+ end
249
+
250
+ metric = "Datastore/statement/#{current_product}/Order/find"
251
+ refute_nil find_sql_trace(metric)
252
+ end
253
+ end
254
+
271
255
  def test_records_metrics_on_background_transaction
272
256
  in_transaction('back it up') do
273
257
  Order.create(:name => 'bob')
274
258
  end
275
259
 
276
- assert_metrics_recorded(['Datastore/allOther'])
277
- assert_metrics_not_recorded(['ActiveRecord/all'])
278
- end
279
-
280
- def test_remote_service_metric_respects_dynamic_connection_config
281
- if supports_remote_service_metrics?
282
- q = "SELECT * FROM #{Shipment.table_name} LIMIT 1"
283
- Shipment.connection.execute(q)
284
- assert_remote_service_metrics
285
-
286
- config = Shipment.connection.instance_eval { @config }
287
- config[:host] = '127.0.0.1'
288
- Shipment.establish_connection(config)
289
-
290
- Shipment.connection.execute(q)
291
- assert_remote_service_metrics('127.0.0.1')
292
-
293
- config[:host] = 'localhost'
294
- Shipment.establish_connection(config)
295
- end
260
+ assert_metrics_recorded(['Datastore/all', 'Datastore/allOther'])
261
+ assert_metrics_not_recorded(['Datastore/allWeb'])
296
262
  end
297
263
 
298
264
  def test_cached_calls_are_not_recorded_with_find
@@ -306,7 +272,6 @@ class ActiveRecordInstrumentationTest < Minitest::Test
306
272
  end
307
273
 
308
274
  assert_activerecord_metrics(Order, 'find', :call_count => 1)
309
- assert_remote_service_metrics
310
275
  end
311
276
 
312
277
  def test_cached_calls_are_not_recorded_with_select_all
@@ -328,7 +293,7 @@ class ActiveRecordInstrumentationTest < Minitest::Test
328
293
  end
329
294
 
330
295
  assert_metrics_recorded(
331
- {'Database/SQL/select' => {:call_count => 1}}
296
+ {"Datastore/operation/#{current_product}/select" => {:call_count => 1}}
332
297
  )
333
298
  end
334
299
 
@@ -341,8 +306,10 @@ class ActiveRecordInstrumentationTest < Minitest::Test
341
306
  end
342
307
 
343
308
  assert_metrics_recorded(
344
- { 'ActiveRecord/Eel/squirm' => {:call_count => 1}}
345
- )
309
+ {
310
+ "Datastore/statement/#{current_product}/Eel/squirm" => {:call_count => 1},
311
+ "Datastore/operation/#{current_product}/squirm" => {:call_count => 1}
312
+ })
346
313
  end
347
314
 
348
315
  ## helpers
@@ -356,12 +323,12 @@ class ActiveRecordInstrumentationTest < Minitest::Test
356
323
  [:mysql, :postgres].include?(adapter)
357
324
  end
358
325
 
359
- def supports_remote_service_metrics?
326
+ def supports_explain_plans?
360
327
  [:mysql, :postgres].include?(adapter)
361
328
  end
362
329
 
363
- def supports_explain_plans?
364
- [:mysql, :postgres].include?(adapter)
330
+ def current_product
331
+ NewRelic::Agent::Instrumentation::ActiveRecordHelper::PRODUCT_NAMES[adapter.to_s]
365
332
  end
366
333
 
367
334
  def active_record_major_version
@@ -390,26 +357,18 @@ class ActiveRecordInstrumentationTest < Minitest::Test
390
357
 
391
358
  def assert_activerecord_metrics(model, operation, stats={})
392
359
  assert_metrics_recorded({
393
- "ActiveRecord/all" => {},
394
- "ActiveRecord/#{operation}" => {},
395
- "ActiveRecord/#{model}/#{operation}" => stats,
360
+ "Datastore/statement/#{current_product}/#{model}/#{operation}" => stats,
361
+ "Datastore/operation/#{current_product}/#{operation}" => {},
362
+ "Datastore/allWeb" => {},
396
363
  "Datastore/all" => {}
397
364
  })
398
365
  end
399
366
 
400
367
  def assert_generic_rollup_metrics(operation)
401
368
  assert_metrics_recorded([
402
- "ActiveRecord/all",
403
- "Database/SQL/#{operation}",
369
+ "Datastore/operation/#{current_product}/#{operation}",
370
+ "Datastore/allWeb",
404
371
  "Datastore/all"
405
372
  ])
406
373
  end
407
-
408
- def assert_remote_service_metrics(host='localhost')
409
- if supports_remote_service_metrics?
410
- assert_metrics_recorded([
411
- "RemoteService/sql/#{adapter}/#{host}"
412
- ])
413
- end
414
- end
415
374
  end
@@ -8,7 +8,6 @@ require 'active_record'
8
8
  require 'active_support/multibyte'
9
9
 
10
10
  require 'multiverse/color'
11
- require 'multiverse_helpers'
12
11
 
13
12
  require File.expand_path(File.join(__FILE__, "..", "app", "models", "models"))
14
13
 
@@ -14,9 +14,6 @@ end
14
14
 
15
15
  require 'newrelic_rpm'
16
16
 
17
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper.rb')
18
- require 'multiverse_helpers'
19
-
20
17
  class ActiveMerchantTest < Minitest::Test
21
18
 
22
19
  attr_reader :gateway
@@ -3,7 +3,6 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require 'newrelic_rpm'
6
- require 'multiverse_helpers'
7
6
 
8
7
  class AgentRunIdHandlingTest < Minitest::Test
9
8
  include MultiverseHelpers
@@ -5,7 +5,6 @@
5
5
  # RUBY-981 Audit Log
6
6
 
7
7
  require 'newrelic_rpm'
8
- require 'multiverse_helpers'
9
8
 
10
9
  class AuditLogTest < Minitest::Test
11
10
  include MultiverseHelpers
@@ -2,8 +2,6 @@
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 'multiverse_helpers'
6
-
7
5
  class CollectorExceptionHandlingTest < Minitest::Test
8
6
  include MultiverseHelpers
9
7
 
@@ -5,7 +5,6 @@
5
5
  require 'rack/test'
6
6
  require 'fake_collector'
7
7
  require './testing_app'
8
- require 'multiverse_helpers'
9
8
  require 'new_relic/rack/agent_hooks'
10
9
 
11
10
  class CrossApplicationTracingTest < Minitest::Test
@@ -2,8 +2,6 @@
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 'multiverse_helpers'
6
-
7
5
  class CustomAnalyticsEventsTest < Minitest::Test
8
6
  include MultiverseHelpers
9
7
 
@@ -3,7 +3,6 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require 'newrelic_rpm'
6
- require 'multiverse_helpers'
7
6
 
8
7
  class CustomQueueTimeTest < Minitest::Test
9
8
  include MultiverseHelpers
@@ -2,8 +2,6 @@
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 'multiverse_helpers'
6
-
7
5
  if RUBY_VERSION >= '1.9'
8
6
 
9
7
  class EncodingHandlingTest < Minitest::Test
@@ -2,8 +2,6 @@
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 'multiverse_helpers'
6
-
7
5
  class ExclusiveTimeTest < Minitest::Test
8
6
  include MultiverseHelpers
9
7
 
@@ -3,7 +3,6 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require 'newrelic_rpm'
6
- require 'multiverse_helpers'
7
6
 
8
7
  class HarvestTimestampsTest < Minitest::Test
9
8
  include MultiverseHelpers
@@ -4,7 +4,6 @@
4
4
 
5
5
  # https://newrelic.atlassian.net/browse/RUBY-765
6
6
  require 'fake_collector'
7
- require 'multiverse_helpers'
8
7
 
9
8
  class HttpResponseCodeTest < Minitest::Test
10
9
  include MultiverseHelpers
@@ -3,7 +3,6 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require 'newrelic_rpm'
6
- require 'multiverse_helpers'
7
6
 
8
7
  class KeepaliveTest < Minitest::Test
9
8
  include MultiverseHelpers
@@ -2,18 +2,20 @@
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 File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper')
6
- require 'multiverse_helpers'
7
-
8
5
  class KeyTransactionsTest < Minitest::Test
9
6
 
10
7
  include MultiverseHelpers
11
8
 
9
+ WEB_KEY_TXN = 'Controller/KeyTransactionsTest::TestWidget/key_txn'
10
+ OTHER_KEY_TXN = 'OtherTransaction/SidekiqJob/JobClass/key_txn'
11
+ OTHER_TXN = 'OtherTransaction/SidekiqJob/JobClass/other_txn'
12
+
12
13
  setup_and_teardown_agent do |collector|
13
- key_txn_name = 'Controller/KeyTransactionsTest::TestWidget/key_txn'
14
- collector.stub('connect',
15
- {
16
- 'web_transactions_apdex' => { key_txn_name => 1 },
14
+ collector.stub('connect', {
15
+ 'web_transactions_apdex' => {
16
+ WEB_KEY_TXN => 1,
17
+ OTHER_KEY_TXN => 1
18
+ },
17
19
  'apdex_t' => 10
18
20
  })
19
21
  end
@@ -36,6 +38,23 @@ class KeyTransactionsTest < Minitest::Test
36
38
  add_transaction_tracer :other_txn
37
39
  end
38
40
 
41
+ class TestBackgroundWidget
42
+ def key_txn
43
+ job(OTHER_KEY_TXN)
44
+ end
45
+
46
+ def other_txn
47
+ job(OTHER_TXN)
48
+ end
49
+
50
+ def job(name)
51
+ state = ::NewRelic::Agent::TransactionState.tl_get
52
+ ::NewRelic::Agent::Transaction.wrap(state, name, :other) do
53
+ advance_time(5)
54
+ end
55
+ end
56
+ end
57
+
39
58
  SATISFYING = 0
40
59
  TOLERATING = 1
41
60
  FAILING = 2
@@ -66,8 +85,34 @@ class KeyTransactionsTest < Minitest::Test
66
85
 
67
86
  traces = $collector.calls_for('transaction_sample_data')
68
87
  assert_equal 1, traces.size
69
- assert_equal('Controller/KeyTransactionsTest::TestWidget/key_txn',
70
- traces[0].metric_name)
88
+ assert_equal(WEB_KEY_TXN, traces[0].metric_name)
89
+ end
90
+
91
+ def test_applied_correct_apdex_t_to_background_key_txn
92
+ TestBackgroundWidget.new.key_txn
93
+ NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)
94
+
95
+ stats = $collector.reported_stats_for_metric('ApdexOther')[0]
96
+ assert_equal(1.0, stats[FAILING],
97
+ "Expected stats (#{stats}) to be apdex failing")
98
+ end
99
+
100
+ def test_no_apdex_for_regular_background_txn
101
+ TestBackgroundWidget.new.other_txn
102
+ NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)
103
+
104
+ assert_empty $collector.reported_stats_for_metric('ApdexOther')
105
+ end
106
+
107
+ def test_applied_correct_tt_theshold_to_background
108
+ TestBackgroundWidget.new.key_txn
109
+ TestBackgroundWidget.new.other_txn
110
+
111
+ NewRelic::Agent.instance.send(:harvest_and_send_transaction_traces)
112
+
113
+ traces = $collector.calls_for('transaction_sample_data')
114
+ assert_equal 1, traces.size
115
+ assert_equal(OTHER_KEY_TXN, traces[0].metric_name)
71
116
  end
72
117
 
73
118
  end