newrelic_rpm 3.17.2.327 → 3.18.0.329

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +32 -10
  3. data/CHANGELOG.md +43 -3
  4. data/Rakefile +0 -21
  5. data/lib/new_relic/agent/cross_app_tracing.rb +34 -269
  6. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +10 -2
  7. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +18 -9
  8. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +12 -6
  9. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +13 -6
  10. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +13 -6
  11. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +14 -3
  12. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +10 -15
  13. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +4 -7
  14. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +4 -19
  15. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +0 -1
  16. data/lib/new_relic/agent/instrumentation/curb.rb +9 -7
  17. data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +4 -0
  18. data/lib/new_relic/agent/instrumentation/excon/connection.rb +15 -5
  19. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +17 -12
  20. data/lib/new_relic/agent/instrumentation/http.rb +12 -5
  21. data/lib/new_relic/agent/instrumentation/httpclient.rb +13 -4
  22. data/lib/new_relic/agent/instrumentation/net.rb +13 -2
  23. data/lib/new_relic/agent/instrumentation/rails5/action_controller.rb +2 -10
  24. data/lib/new_relic/agent/instrumentation/typhoeus.rb +8 -3
  25. data/lib/new_relic/agent/method_tracer_helpers.rb +3 -1
  26. data/lib/new_relic/agent/parameter_filtering.rb +1 -1
  27. data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -18
  28. data/lib/new_relic/agent/supported_versions.rb +1 -0
  29. data/lib/new_relic/agent/transaction/abstract_segment.rb +7 -9
  30. data/lib/new_relic/agent/transaction/external_request_segment.rb +139 -0
  31. data/lib/new_relic/agent/transaction/segment.rb +1 -1
  32. data/lib/new_relic/agent/transaction/tracing.rb +10 -1
  33. data/lib/new_relic/recipes/capistrano3.rb +3 -1
  34. data/lib/new_relic/version.rb +2 -2
  35. data/lib/tasks/multiverse.rb +27 -7
  36. data/test/environments/rails42/Gemfile +1 -0
  37. data/test/multiverse/lib/multiverse.rb +32 -0
  38. data/test/multiverse/lib/multiverse/runner.rb +2 -2
  39. data/test/multiverse/lib/multiverse/suite.rb +43 -22
  40. data/test/multiverse/suites/active_record/Envfile +3 -1
  41. data/test/multiverse/suites/activemerchant/Envfile +5 -1
  42. data/test/multiverse/suites/agent_only/Envfile +1 -0
  43. data/test/multiverse/suites/capistrano/deployment_test.rb +6 -9
  44. data/test/multiverse/suites/capistrano2/deployment_test.rb +6 -6
  45. data/test/multiverse/suites/curb/curb_test.rb +2 -3
  46. data/test/multiverse/suites/datamapper/Envfile +4 -0
  47. data/test/multiverse/suites/datamapper/datamapper_test.rb +106 -36
  48. data/test/multiverse/suites/delayed_job/Envfile +3 -3
  49. data/test/multiverse/suites/excon/excon_test.rb +1 -1
  50. data/test/multiverse/suites/grape/grape_test.rb +1 -1
  51. data/test/multiverse/suites/grape/grape_test_api.rb +1 -1
  52. data/test/multiverse/suites/grape/grape_versioning_test.rb +1 -1
  53. data/test/multiverse/suites/grape/grape_versioning_test_api.rb +1 -1
  54. data/test/multiverse/suites/grape/unsupported_version_test.rb +1 -1
  55. data/test/multiverse/suites/httpclient/Envfile +2 -0
  56. data/test/multiverse/suites/httpclient/httpclient_test.rb +1 -1
  57. data/test/multiverse/suites/httprb/Envfile +2 -0
  58. data/test/multiverse/suites/httprb/httprb_test.rb +1 -1
  59. data/test/multiverse/suites/json/Envfile +7 -2
  60. data/test/multiverse/suites/memcached/Envfile +2 -0
  61. data/test/multiverse/suites/mongo/Envfile +2 -0
  62. data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +95 -33
  63. data/test/multiverse/suites/mongo/mongo2_instrumentation_test.rb +62 -23
  64. data/test/multiverse/suites/net_http/Envfile +2 -0
  65. data/test/multiverse/suites/net_http/net_http_test.rb +7 -3
  66. data/test/multiverse/suites/padrino/Envfile +2 -0
  67. data/test/multiverse/suites/rack/Envfile +2 -0
  68. data/test/multiverse/suites/rack/url_map_test.rb +4 -0
  69. data/test/multiverse/suites/rails/Envfile +34 -29
  70. data/test/multiverse/suites/rake/Envfile +11 -6
  71. data/test/multiverse/suites/redis/Envfile +2 -0
  72. data/test/multiverse/suites/redis/redis_instrumentation_test.rb +31 -12
  73. data/test/multiverse/suites/sidekiq/Envfile +6 -2
  74. data/test/multiverse/suites/sinatra/Envfile +2 -0
  75. data/test/multiverse/suites/typhoeus/Envfile +31 -27
  76. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +4 -3
  77. data/test/multiverse/suites/yajl/Envfile +4 -2
  78. data/test/new_relic/agent/datastores_test.rb +0 -10
  79. data/test/new_relic/agent/instrumentation/action_cable_subscriber_test.rb +2 -2
  80. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +64 -65
  81. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +11 -9
  82. data/test/new_relic/agent/instrumentation/instance_identification_test.rb +9 -8
  83. data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +7 -11
  84. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +4 -0
  85. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +0 -9
  86. data/test/new_relic/agent/method_tracer_test.rb +24 -8
  87. data/test/new_relic/agent/parameter_filtering_test.rb +2 -2
  88. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +1 -0
  89. data/test/new_relic/agent/transaction/abstract_segment_test.rb +25 -16
  90. data/test/new_relic/agent/transaction/datastore_segment_test.rb +55 -38
  91. data/test/new_relic/agent/transaction/external_request_segment_test.rb +330 -0
  92. data/test/new_relic/agent/transaction/segment_test.rb +28 -4
  93. data/test/new_relic/agent/transaction/tracing_test.rb +60 -22
  94. data/test/new_relic/agent_test.rb +2 -1
  95. data/test/new_relic/collection_helper_test.rb +1 -0
  96. data/test/new_relic/dispatcher_test.rb +1 -0
  97. data/test/new_relic/fake_external_server.rb +1 -1
  98. data/test/new_relic/filtering_test_app.rb +1 -1
  99. data/test/new_relic/http_client_test_cases.rb +38 -20
  100. data/test/new_relic/rack/error_collector_test.rb +1 -0
  101. data/test/performance/suites/external_segment.rb +82 -0
  102. data/test/script/before_install/update_bundler.sh +12 -0
  103. data/test/script/external_server.rb +31 -0
  104. metadata +8 -5
  105. data/test/multiverse/lib/multiverse/environment.rb +0 -19
  106. data/test/new_relic/agent/cross_app_tracing_test.rb +0 -71
  107. data/test/script/before_install/jruby_bundler.sh +0 -22
@@ -36,7 +36,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
36
36
  end
37
37
 
38
38
  def test_records_metrics_for_insert_one
39
- @collection.insert_one(@tribbles.first)
39
+ in_transaction do
40
+ @collection.insert_one(@tribbles.first)
41
+ end
40
42
 
41
43
  metrics = build_test_metrics(:insert, true)
42
44
  expected = metrics_with_attributes(metrics)
@@ -45,7 +47,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
45
47
  end
46
48
 
47
49
  def test_records_metrics_for_insert_many
48
- @collection.insert_many(@tribbles)
50
+ in_transaction do
51
+ @collection.insert_many(@tribbles)
52
+ end
49
53
 
50
54
  metrics = build_test_metrics(:insert, true)
51
55
  expected = metrics_with_attributes(metrics)
@@ -57,7 +61,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
57
61
  @collection.insert_one(@tribbles.first)
58
62
  NewRelic::Agent.drop_buffered_data
59
63
 
60
- @collection.delete_one(@tribbles.first)
64
+ in_transaction do
65
+ @collection.delete_one(@tribbles.first)
66
+ end
61
67
 
62
68
  metrics = build_test_metrics(:delete, true)
63
69
  expected = metrics_with_attributes(metrics)
@@ -69,7 +75,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
69
75
  @collection.insert_one(@tribbles.first)
70
76
  NewRelic::Agent.drop_buffered_data
71
77
 
72
- @collection.delete_many(@tribbles.first)
78
+ in_transaction do
79
+ @collection.delete_many(@tribbles.first)
80
+ end
73
81
 
74
82
  metrics = build_test_metrics(:delete, true)
75
83
  expected = metrics_with_attributes(metrics)
@@ -81,7 +89,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
81
89
  @collection.insert_one(@tribbles.first)
82
90
  NewRelic::Agent.drop_buffered_data
83
91
 
84
- @collection.replace_one(@tribbles[0], @tribbles[1])
92
+ in_transaction do
93
+ @collection.replace_one(@tribbles[0], @tribbles[1])
94
+ end
85
95
 
86
96
  metrics = build_test_metrics(:update, true)
87
97
  expected = metrics_with_attributes(metrics)
@@ -93,7 +103,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
93
103
  @collection.insert_one(@tribbles.first)
94
104
  NewRelic::Agent.drop_buffered_data
95
105
 
96
- @collection.update_one(@tribbles[0], "$set" => @tribbles[1])
106
+ in_transaction do
107
+ @collection.update_one(@tribbles[0], "$set" => @tribbles[1])
108
+ end
97
109
 
98
110
  metrics = build_test_metrics(:update, true)
99
111
  expected = metrics_with_attributes(metrics)
@@ -105,7 +117,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
105
117
  @collection.insert_one(@tribbles.first)
106
118
  NewRelic::Agent.drop_buffered_data
107
119
 
108
- @collection.update_many(@tribbles[0], "$set" => @tribbles[1])
120
+ in_transaction do
121
+ @collection.update_many(@tribbles[0], "$set" => @tribbles[1])
122
+ end
109
123
 
110
124
  metrics = build_test_metrics(:update, true)
111
125
  expected = metrics_with_attributes(metrics)
@@ -117,7 +131,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
117
131
  @collection.insert_one(@tribbles.first)
118
132
  NewRelic::Agent.drop_buffered_data
119
133
 
120
- @collection.find(@tribbles.first).to_a
134
+ in_transaction do
135
+ @collection.find(@tribbles.first).to_a
136
+ end
121
137
 
122
138
  metrics = build_test_metrics(:find, true)
123
139
  expected = metrics_with_attributes(metrics)
@@ -129,7 +145,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
129
145
  @collection.insert_one(@tribbles.first)
130
146
  NewRelic::Agent.drop_buffered_data
131
147
 
132
- @collection.find_one_and_delete(@tribbles.first)
148
+ in_transaction do
149
+ @collection.find_one_and_delete(@tribbles.first)
150
+ end
133
151
 
134
152
  metrics = build_test_metrics(:findandmodify, true)
135
153
  expected = metrics_with_attributes(metrics)
@@ -141,7 +159,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
141
159
  @collection.insert_one(@tribbles.first)
142
160
  NewRelic::Agent.drop_buffered_data
143
161
 
144
- @collection.find_one_and_replace(@tribbles[0], @tribbles[1])
162
+ in_transaction do
163
+ @collection.find_one_and_replace(@tribbles[0], @tribbles[1])
164
+ end
145
165
 
146
166
  metrics = build_test_metrics(:findandmodify, true)
147
167
  expected = metrics_with_attributes(metrics)
@@ -153,7 +173,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
153
173
  @collection.insert_one(@tribbles.first)
154
174
  NewRelic::Agent.drop_buffered_data
155
175
 
156
- @collection.find_one_and_update(@tribbles[0], "$set" => @tribbles[1])
176
+ in_transaction do
177
+ @collection.find_one_and_update(@tribbles[0], "$set" => @tribbles[1])
178
+ end
157
179
 
158
180
  metrics = build_test_metrics(:findandmodify, true)
159
181
  expected = metrics_with_attributes(metrics)
@@ -162,7 +184,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
162
184
  end
163
185
 
164
186
  def test_records_metrics_for_distinct
165
- @collection.distinct('name')
187
+ in_transaction do
188
+ @collection.distinct('name')
189
+ end
166
190
 
167
191
  metrics = build_test_metrics(:distinct, true)
168
192
  expected = metrics_with_attributes(metrics)
@@ -171,7 +195,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
171
195
  end
172
196
 
173
197
  def test_records_metrics_for_count
174
- @collection.count
198
+ in_transaction do
199
+ @collection.count
200
+ end
175
201
 
176
202
  metrics = build_test_metrics(:count, true)
177
203
  expected = metrics_with_attributes(metrics)
@@ -185,10 +211,15 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
185
211
  end
186
212
  NewRelic::Agent.drop_buffered_data
187
213
 
188
- @collection.find(:active => true).batch_size(10).to_a
214
+ in_transaction("test_txn") do
215
+ @collection.find(:active => true).batch_size(10).to_a
216
+ end
189
217
 
190
218
  expected = {
219
+ "test_txn" => {:call_count=>1},
220
+ ["Datastore/statement/MongoDB/#{@collection_name}/find", "test_txn"] => {:call_count=>1},
191
221
  "Datastore/statement/MongoDB/#{@collection_name}/find" => {:call_count=>1},
222
+ ["Datastore/statement/MongoDB/#{@collection_name}/getMore", "test_txn"] => {:call_count=>2},
192
223
  "Datastore/statement/MongoDB/#{@collection_name}/getMore" => {:call_count=>2},
193
224
  "Datastore/operation/MongoDB/find" => {:call_count=>1},
194
225
  "Datastore/operation/MongoDB/getMore" => {:call_count=>2},
@@ -241,7 +272,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
241
272
  end
242
273
 
243
274
  def test_drop_collection
244
- @collection.drop
275
+ in_transaction do
276
+ @collection.drop
277
+ end
245
278
 
246
279
  metrics = build_test_metrics(:drop, true)
247
280
  expected = metrics_with_attributes(metrics)
@@ -258,11 +291,6 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
258
291
  assert_metrics_recorded([[metric, "webby"]])
259
292
  end
260
293
 
261
- def statement_metric(action)
262
- metrics = build_test_metrics(action, true)
263
- metrics.select { |m| m.start_with?("Datastore/statement") }.first
264
- end
265
-
266
294
  def test_background_scoped_metrics
267
295
  in_background_transaction("backed-up") do
268
296
  @collection.insert_one(@tribbles.first)
@@ -368,7 +396,9 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
368
396
 
369
397
  def test_web_requests_record_all_web_metric
370
398
  NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(true)
371
- @collection.insert_one(@tribbles.first)
399
+ in_web_transaction do
400
+ @collection.insert_one(@tribbles.first)
401
+ end
372
402
 
373
403
  metrics = build_test_metrics(:insert, true)
374
404
  expected = metrics_with_attributes(metrics)
@@ -378,14 +408,18 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
378
408
 
379
409
  def test_web_requests_do_not_record_all_other_metric
380
410
  NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(true)
381
- @collection.insert_one(@tribbles.first)
411
+ in_background_transaction do
412
+ @collection.insert_one(@tribbles.first)
413
+ end
382
414
 
383
415
  assert_metrics_not_recorded(['Datastore/allOther'])
384
416
  end
385
417
 
386
418
  def test_other_requests_record_all_other_metric
387
419
  NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(false)
388
- @collection.insert_one(@tribbles.first)
420
+ in_transaction do
421
+ @collection.insert_one(@tribbles.first)
422
+ end
389
423
 
390
424
  metrics = build_test_metrics(:insert, true)
391
425
  expected = metrics_with_attributes(metrics)
@@ -399,6 +433,11 @@ if NewRelic::Agent::Datastores::Mongo.is_supported_version? &&
399
433
 
400
434
  assert_metrics_not_recorded(['Datastore/allWeb'])
401
435
  end
436
+
437
+ def statement_metric(action)
438
+ metrics = build_test_metrics(action, true)
439
+ metrics.select { |m| m.start_with?("Datastore/statement") }.first
440
+ end
402
441
  end
403
442
  end
404
443
  end
@@ -2,3 +2,5 @@ gemfile <<-RB
2
2
  gem 'rack'
3
3
  gem 'json', :platforms => [:rbx, :mri_18]
4
4
  RB
5
+
6
+ # vim: ft=ruby
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # This file is distributed under New Relic"s license terms.
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
5
  require "net/http"
@@ -90,7 +90,9 @@ class NetHttpTest < Minitest::Test
90
90
  # Don't check this specific condition against SSL, since API doesn't support it
91
91
  return if use_ssl?
92
92
 
93
- Net::HTTP.get default_uri
93
+ in_transaction do
94
+ Net::HTTP.get default_uri
95
+ end
94
96
 
95
97
  assert_metrics_recorded([
96
98
  'External/all',
@@ -103,7 +105,9 @@ class NetHttpTest < Minitest::Test
103
105
  # https://newrelic.atlassian.net/browse/RUBY-835
104
106
  def test_direct_get_request_doesnt_double_count
105
107
  http = create_http(default_uri)
106
- http.request(Net::HTTP::Get.new(default_uri.request_uri))
108
+ in_transaction do
109
+ http.request(Net::HTTP::Get.new(default_uri.request_uri))
110
+ end
107
111
 
108
112
  assert_metrics_recorded(
109
113
  'External/localhost/Net::HTTP/GET' => { :call_count => 1 })
@@ -21,3 +21,5 @@ gemfile <<-RB
21
21
  gem 'rack-test', :require => 'rack/test'
22
22
  gem 'i18n', '< 0.7' if RUBY_VERSION < '1.9.3' # i18n >= 0.7.0 only works on Ruby 1.9.3 and newer
23
23
  RB
24
+
25
+ # vim: ft=ruby
@@ -60,3 +60,5 @@ gemfile <<-RB
60
60
  gem 'rack', '1.0.1'
61
61
  gem 'rack-test'
62
62
  RB
63
+
64
+ # vim: ft=ruby
@@ -11,6 +11,10 @@ if NewRelic::Agent::Instrumentation::RackHelpers.version_supported?
11
11
  class UrlMapTest < Minitest::Test
12
12
  include MultiverseHelpers
13
13
 
14
+ def setup
15
+ NewRelic::Agent.drop_buffered_data
16
+ end
17
+
14
18
  def teardown
15
19
  NewRelic::Agent.drop_buffered_data
16
20
  end
@@ -6,11 +6,12 @@ if RUBY_VERSION >= '2.2.2' && RUBY_PLATFORM != 'java'
6
6
  RB
7
7
  end
8
8
 
9
- if RUBY_VERSION >= '1.9.3'
9
+ if RUBY_VERSION >= '1.9.3' && RUBY_VERSION < '2.4.0'
10
10
  gemfile <<-RB
11
11
  gem 'rails', '~>4.2.1'
12
12
  gem 'haml', :require => false
13
13
  gem 'minitest', '5.2.3'
14
+ gem 'nokogiri', '< 1.7' if RUBY_VERSION < '2.1.0' # nokogiri 1.7.0 only supports >= 2.1.0
14
15
  RB
15
16
 
16
17
  gemfile <<-RB
@@ -29,37 +30,39 @@ if RUBY_VERSION >= '1.9.3'
29
30
  RB
30
31
  end
31
32
 
32
- gemfile <<-RB
33
- gem 'rails', '~>3.2.22.2'
34
- gem 'i18n', '~>0.6.11'
35
- gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
36
- gem 'minitest_tu_shim', :require => false
37
- gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3' # rack-cache 1.3.0 only supports >= 1.9.3
38
- RB
33
+ if RUBY_VERSION < '2.4.0'
34
+ gemfile <<-RB
35
+ gem 'rails', '~>3.2.22.2'
36
+ gem 'i18n', '~>0.6.11'
37
+ gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
38
+ gem 'minitest_tu_shim', :require => false
39
+ gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3' # rack-cache 1.3.0 only supports >= 1.9.3
40
+ RB
39
41
 
40
- gemfile <<-RB
41
- gem 'rails', '~>3.2.22.2'
42
- gem 'i18n', '~>0.6.11'
43
- gem 'sinatra', '~> 1.4.5'
44
- gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
45
- gem 'minitest_tu_shim', :require => false
46
- gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3' # rack-cache 1.3.0 only supports >= 1.9.3
47
- RB
42
+ gemfile <<-RB
43
+ gem 'rails', '~>3.2.22.2'
44
+ gem 'i18n', '~>0.6.11'
45
+ gem 'sinatra', '~> 1.4.5'
46
+ gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
47
+ gem 'minitest_tu_shim', :require => false
48
+ gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3' # rack-cache 1.3.0 only supports >= 1.9.3
49
+ RB
48
50
 
49
- gemfile <<-RB
50
- gem 'rails', '~>3.1.12'
51
- gem 'i18n', '~>0.6.11'
52
- gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
53
- gem 'minitest_tu_shim', :require => false
54
- gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3' # rack-cache 1.3.0 only supports >= 1.9.3
55
- RB
51
+ gemfile <<-RB
52
+ gem 'rails', '~>3.1.12'
53
+ gem 'i18n', '~>0.6.11'
54
+ gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
55
+ gem 'minitest_tu_shim', :require => false
56
+ gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3' # rack-cache 1.3.0 only supports >= 1.9.3
57
+ RB
56
58
 
57
- gemfile <<-RB
58
- gem 'rails', '~>3.0.20'
59
- gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
60
- gem 'minitest_tu_shim', :require => false
61
- gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3' # rack-cache 1.3.0 only supports >= 1.9.3
62
- RB
59
+ gemfile <<-RB
60
+ gem 'rails', '~>3.0.20'
61
+ gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
62
+ gem 'minitest_tu_shim', :require => false
63
+ gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3' # rack-cache 1.3.0 only supports >= 1.9.3
64
+ RB
65
+ end
63
66
 
64
67
  if RUBY_VERSION <= '1.9.3' && (!defined?(RUBY_ENGINE) || RUBY_ENGINE != 'jruby')
65
68
  gemfile <<-RB
@@ -72,3 +75,5 @@ if RUBY_VERSION <= '1.9.3' && (!defined?(RUBY_ENGINE) || RUBY_ENGINE != 'jruby')
72
75
  gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3' # rack-cache 1.3.0 only supports >= 1.9.3
73
76
  RB
74
77
  end
78
+
79
+ # vim: ft=ruby
@@ -12,12 +12,15 @@ RB
12
12
 
13
13
  # No single Rails version works everywhere, so split it up
14
14
  if RUBY_VERSION >= "1.9.3"
15
- gemfile <<-RB
16
- gem 'rack'
17
- gem 'rake', '~> 10.4'
18
- gem 'rails', '~> 4.2.1'
19
- gem 'minitest', '5.2.3'
20
- RB
15
+ if RUBY_VERSION < '2.4.0'
16
+ gemfile <<-RB
17
+ gem 'rack'
18
+ gem 'rake', '~> 10.4'
19
+ gem 'rails', '~> 4.2.1'
20
+ gem 'minitest', '5.2.3'
21
+ gem 'nokogiri', '< 1.7' if RUBY_VERSION < '2.1.0' # nokogiri 1.7.0 only supports >= 2.1.0
22
+ RB
23
+ end
21
24
  else
22
25
  gemfile <<-RB
23
26
  gem 'rack'
@@ -43,3 +46,5 @@ gemfile <<-RB
43
46
  gem 'rake', '~> 10.4'
44
47
  gem 'newrelic-rake', :require => false # Can't coexist with third-party instrumentation
45
48
  RB
49
+
50
+ # vim: ft=ruby
@@ -12,3 +12,5 @@ gemfile <<-RB
12
12
  gem 'rack'
13
13
  gem 'redis', '2.2.2' # newest unsupported version
14
14
  RB
15
+
16
+ # vim: ft=ruby
@@ -26,10 +26,16 @@ class NewRelic::Agent::Instrumentation::RedisInstrumentationTest < Minitest::Tes
26
26
 
27
27
  def test_records_metrics_for_connect
28
28
  redis = Redis.new
29
- redis.get("foo")
29
+
30
+ in_transaction "test_txn" do
31
+ redis.get("foo")
32
+ end
30
33
 
31
34
  expected = {
35
+ "test_txn" => { :call_count => 1 },
36
+ ["Datastore/operation/Redis/connect", "test_txn"] => { :call_count => 1 },
32
37
  "Datastore/operation/Redis/connect" => { :call_count => 1 },
38
+ ["Datastore/operation/Redis/get", "test_txn"] => { :call_count => 1 },
33
39
  "Datastore/operation/Redis/get" => { :call_count => 1 },
34
40
  "Datastore/Redis/allOther" => { :call_count => 2 },
35
41
  "Datastore/Redis/all" => { :call_count => 2 },
@@ -57,7 +63,9 @@ class NewRelic::Agent::Instrumentation::RedisInstrumentationTest < Minitest::Tes
57
63
  end
58
64
 
59
65
  def test_records_metrics_for_set
60
- @redis.set 'time', 'walk'
66
+ in_transaction do
67
+ @redis.set 'time', 'walk'
68
+ end
61
69
 
62
70
  expected = {
63
71
  "Datastore/operation/Redis/set" => { :call_count => 1 },
@@ -86,8 +94,10 @@ class NewRelic::Agent::Instrumentation::RedisInstrumentationTest < Minitest::Tes
86
94
  assert_metrics_recorded(expected)
87
95
  end
88
96
 
89
- def test_records_metrics_for_get
90
- @redis.get 'mox sapphire'
97
+ def test_records_metrics_for_get_in_background_txn
98
+ in_background_transaction do
99
+ @redis.get 'mox sapphire'
100
+ end
91
101
 
92
102
  expected = {
93
103
  "Datastore/operation/Redis/get" => { :call_count => 1 },
@@ -139,12 +149,16 @@ class NewRelic::Agent::Instrumentation::RedisInstrumentationTest < Minitest::Tes
139
149
  end
140
150
 
141
151
  def test_records_metrics_for_pipelined_commands
142
- @redis.pipelined do
143
- @redis.get 'great log'
144
- @redis.get 'late log'
152
+ in_transaction 'test_txn' do
153
+ @redis.pipelined do
154
+ @redis.get 'great log'
155
+ @redis.get 'late log'
156
+ end
145
157
  end
146
158
 
147
159
  expected = {
160
+ "test_txn" => { :call_count => 1 },
161
+ ["Datastore/operation/Redis/pipeline", "test_txn"] => { :call_count => 1 },
148
162
  "Datastore/operation/Redis/pipeline" => { :call_count => 1 },
149
163
  "Datastore/Redis/allOther" => { :call_count => 1 },
150
164
  "Datastore/Redis/all" => { :call_count => 1 },
@@ -170,12 +184,16 @@ class NewRelic::Agent::Instrumentation::RedisInstrumentationTest < Minitest::Tes
170
184
  end
171
185
 
172
186
  def test_records_metrics_for_multi_blocks
173
- @redis.multi do
174
- @redis.get 'darkpact'
175
- @redis.get 'chaos orb'
187
+ in_transaction 'test_txn' do
188
+ @redis.multi do
189
+ @redis.get 'darkpact'
190
+ @redis.get 'chaos orb'
191
+ end
176
192
  end
177
193
 
178
194
  expected = {
195
+ "test_txn" => { :call_count => 1 },
196
+ ["Datastore/operation/Redis/multi", "test_txn"] => { :call_count => 1 },
179
197
  "Datastore/operation/Redis/multi" => { :call_count => 1 },
180
198
  "Datastore/Redis/allOther" => { :call_count => 1 },
181
199
  "Datastore/Redis/all" => { :call_count => 1 },
@@ -279,8 +297,9 @@ class NewRelic::Agent::Instrumentation::RedisInstrumentationTest < Minitest::Tes
279
297
  def test_records_unknown_unknown_metric_when_error_gathering_instance_data
280
298
  redis = Redis.new
281
299
  redis.client.stubs(:path).raises StandardError.new
282
-
283
- redis.get("foo")
300
+ in_transaction do
301
+ redis.get("foo")
302
+ end
284
303
 
285
304
  assert_metrics_recorded('Datastore/instance/Redis/unknown/unknown')
286
305
  end