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
@@ -22,7 +22,7 @@ if RUBY_VERSION >= '1.9.3'
22
22
  RB
23
23
  end
24
24
 
25
- if RUBY_VERSION >= '1.9.3'
25
+ if RUBY_VERSION >= '1.9.3' && RUBY_VERSION < '2.4.0'
26
26
  gemfile <<-RB
27
27
  gem 'delayed_job', '~> 4.1.0'
28
28
  gem 'delayed_job_active_record', '~> 4.1.0'
@@ -33,7 +33,7 @@ if RUBY_VERSION >= '1.9.3'
33
33
  end
34
34
 
35
35
  # delayed_job_active_record (and older baked into delayed_job) support
36
- if RUBY_VERSION >= '1.9.3'
36
+ if RUBY_VERSION >= '1.9.3' && RUBY_VERSION < '2.4.0'
37
37
  dj4_with_active_record = <<-DJ
38
38
  gem 'delayed_job', '~> 4.0.4'
39
39
  gem 'delayed_job_active_record', '~> 4.0.2'
@@ -60,7 +60,7 @@ dj2_with_active_record3 = <<-DJ
60
60
  #{boilerplate_gems}
61
61
  DJ
62
62
 
63
- if RUBY_VERSION >= '1.9.3'
63
+ if RUBY_VERSION >= '1.9.3' && RUBY_VERSION < '2.4.0'
64
64
  gemfile <<-RB
65
65
  gem 'activerecord', '~> 4.2.0'
66
66
  gem 'i18n', '~> 0.7.0'
@@ -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 "excon"
@@ -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 "grape"
@@ -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 'grape'
@@ -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
  unless ::Grape::VERSION == '0.1.5'
@@ -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
  unless ::Grape::VERSION == '0.1.5'
@@ -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 "grape"
@@ -11,3 +11,5 @@ httpclient_versions.each do |httpclient_version|
11
11
  gem 'json', :platforms => [:rbx, :mri_18]
12
12
  RB
13
13
  end
14
+
15
+ # 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 "httpclient"
@@ -17,3 +17,5 @@ httprb_versions.each do |httprb_version|
17
17
  gem 'rack'
18
18
  RB
19
19
  end
20
+
21
+ # 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 "http"
@@ -1,9 +1,12 @@
1
- all_versions = [ '~> 1.8.1' ]
1
+ after_2_0_0 = [ '~> 2.0.2' ]
2
+ before_2_4_0 = [ '~> 1.8.1' ]
2
3
  before_2_2_0 = [ '~> 1.7.7', '~> 1.6.8', '~> 1.5.5' ]
3
4
  before_2_0_0 = [ '~> 1.4.6', '~> 1.2.4', '~> 1.1.9' ]
4
5
  before_1_9_2 = [ '1.1.2' ]
5
6
 
6
- json_gems = all_versions.dup
7
+ json_gems = []
8
+ json_gems += after_2_0_0 if RUBY_VERSION >= '2.0.0'
9
+ json_gems += before_2_4_0 if RUBY_VERSION < '2.4.0'
7
10
  json_gems += before_2_2_0 if RUBY_VERSION < '2.2.0'
8
11
  json_gems += before_2_0_0 if RUBY_VERSION < '2.0.0'
9
12
  json_gems += before_1_9_2 if RUBY_VERSION < '1.9.2'
@@ -23,3 +26,5 @@ json_gems.each do |version|
23
26
  gem 'json', '#{version}'
24
27
  RB
25
28
  end
29
+
30
+ # vim: ft=ruby
@@ -50,3 +50,5 @@ end
50
50
  before_suite do
51
51
  system('memcached -d -l localhost') unless memcache_running?
52
52
  end
53
+
54
+ # vim: ft=ruby
@@ -72,3 +72,5 @@ end
72
72
  after_suite do
73
73
  $mongo.stop
74
74
  end
75
+
76
+ # vim: ft=ruby
@@ -4,7 +4,9 @@
4
4
 
5
5
  module MongoOperationTests
6
6
  def test_records_metrics_for_insert
7
- @collection.insert(@tribble)
7
+ in_transaction do
8
+ @collection.insert(@tribble)
9
+ end
8
10
 
9
11
  metrics = build_test_metrics(:insert)
10
12
  expected = metrics_with_attributes(metrics)
@@ -16,7 +18,9 @@ module MongoOperationTests
16
18
  @collection.insert(@tribble)
17
19
  NewRelic::Agent.drop_buffered_data
18
20
 
19
- @collection.find(@tribble).to_a
21
+ in_transaction do
22
+ @collection.find(@tribble).to_a
23
+ end
20
24
 
21
25
  metrics = build_test_metrics(:find)
22
26
  expected = metrics_with_attributes(metrics)
@@ -28,7 +32,9 @@ module MongoOperationTests
28
32
  @collection.insert(@tribble)
29
33
  NewRelic::Agent.drop_buffered_data
30
34
 
31
- @collection.find_one
35
+ in_transaction do
36
+ @collection.find_one
37
+ end
32
38
 
33
39
  metrics = build_test_metrics(:findOne)
34
40
  expected = metrics_with_attributes(metrics)
@@ -40,7 +46,9 @@ module MongoOperationTests
40
46
  @collection.insert(@tribble)
41
47
  NewRelic::Agent.drop_buffered_data
42
48
 
43
- @collection.remove(@tribble).to_a
49
+ in_transaction do
50
+ @collection.remove(@tribble).to_a
51
+ end
44
52
 
45
53
  metrics = build_test_metrics(:remove)
46
54
  expected = metrics_with_attributes(metrics)
@@ -49,7 +57,9 @@ module MongoOperationTests
49
57
  end
50
58
 
51
59
  def test_records_metrics_for_save
52
- @collection.save(@tribble)
60
+ in_transaction do
61
+ @collection.save(@tribble)
62
+ end
53
63
 
54
64
  metrics = build_test_metrics(:save)
55
65
  expected = metrics_with_attributes(metrics)
@@ -58,7 +68,9 @@ module MongoOperationTests
58
68
  end
59
69
 
60
70
  def test_save_does_not_record_insert
61
- @collection.save(@tribble)
71
+ in_transaction do
72
+ @collection.save(@tribble)
73
+ end
62
74
 
63
75
  metrics = build_test_metrics(:save)
64
76
  metrics_with_attributes(metrics)
@@ -70,7 +82,9 @@ module MongoOperationTests
70
82
  updated = @tribble.dup
71
83
  updated['name'] = 'codemonkey'
72
84
 
73
- @collection.update(@tribble, updated)
85
+ in_transaction do
86
+ @collection.update(@tribble, updated)
87
+ end
74
88
 
75
89
  metrics = build_test_metrics(:update)
76
90
  expected = metrics_with_attributes(metrics)
@@ -79,7 +93,9 @@ module MongoOperationTests
79
93
  end
80
94
 
81
95
  def test_records_metrics_for_distinct
82
- @collection.distinct('name')
96
+ in_transaction do
97
+ @collection.distinct('name')
98
+ end
83
99
 
84
100
  metrics = build_test_metrics(:distinct)
85
101
  expected = metrics_with_attributes(metrics)
@@ -88,7 +104,9 @@ module MongoOperationTests
88
104
  end
89
105
 
90
106
  def test_records_metrics_for_count
91
- @collection.count
107
+ in_transaction do
108
+ @collection.count
109
+ end
92
110
 
93
111
  metrics = build_test_metrics(:count)
94
112
  expected = metrics_with_attributes(metrics)
@@ -98,9 +116,11 @@ module MongoOperationTests
98
116
 
99
117
  def test_records_metrics_for_group
100
118
  begin
101
- @collection.group({:key => "name",
102
- :initial => {:count => 0},
103
- :reduce => "function(k,v) { v.count += 1; }" })
119
+ in_transaction do
120
+ @collection.group({:key => "name",
121
+ :initial => {:count => 0},
122
+ :reduce => "function(k,v) { v.count += 1; }" })
123
+ end
104
124
  rescue Mongo::OperationFailure
105
125
  # We get occasional group failures, but should still record metrics
106
126
  end
@@ -114,7 +134,10 @@ module MongoOperationTests
114
134
  def test_records_metrics_for_find_and_modify
115
135
  updated = @tribble.dup
116
136
  updated['name'] = 'codemonkey'
117
- @collection.find_and_modify(:query => @tribble, :update => updated)
137
+
138
+ in_transaction do
139
+ @collection.find_and_modify(:query => @tribble, :update => updated)
140
+ end
118
141
 
119
142
  metrics = build_test_metrics(:findAndModify)
120
143
  expected = metrics_with_attributes(metrics)
@@ -123,7 +146,9 @@ module MongoOperationTests
123
146
  end
124
147
 
125
148
  def test_records_metrics_for_find_and_remove
126
- @collection.find_and_modify(:query => @tribble, :remove =>true)
149
+ in_transaction do
150
+ @collection.find_and_modify(:query => @tribble, :remove =>true)
151
+ end
127
152
 
128
153
  metrics = build_test_metrics(:findAndRemove)
129
154
  expected = metrics_with_attributes(metrics)
@@ -132,7 +157,9 @@ module MongoOperationTests
132
157
  end
133
158
 
134
159
  def test_records_metrics_for_create_index
135
- @collection.create_index([[unique_field_name, Mongo::ASCENDING]])
160
+ in_transaction do
161
+ @collection.create_index([[unique_field_name, Mongo::ASCENDING]])
162
+ end
136
163
 
137
164
  # The createIndexes command was added to the mongo server in version 2.6.
138
165
  # As of version 1.10.0 of the Ruby driver, the driver will attempt to
@@ -163,7 +190,9 @@ module MongoOperationTests
163
190
  end
164
191
 
165
192
  def test_records_metrics_for_ensure_index
166
- @collection.ensure_index([[unique_field_name, Mongo::ASCENDING]])
193
+ in_transaction do
194
+ @collection.ensure_index([[unique_field_name, Mongo::ASCENDING]])
195
+ end
167
196
 
168
197
  metrics = build_test_metrics(:ensureIndex)
169
198
  expected = metrics_with_attributes(metrics)
@@ -172,7 +201,9 @@ module MongoOperationTests
172
201
  end
173
202
 
174
203
  def test_records_metrics_for_ensure_index_with_symbol
175
- @collection.ensure_index(unique_field_name.to_sym)
204
+ in_transaction do
205
+ @collection.ensure_index(unique_field_name.to_sym)
206
+ end
176
207
 
177
208
  metrics = build_test_metrics(:ensureIndex)
178
209
  expected = metrics_with_attributes(metrics)
@@ -181,7 +212,9 @@ module MongoOperationTests
181
212
  end
182
213
 
183
214
  def test_records_metrics_for_ensure_index_with_string
184
- @collection.ensure_index(unique_field_name)
215
+ in_transaction do
216
+ @collection.ensure_index(unique_field_name)
217
+ end
185
218
 
186
219
  metrics = build_test_metrics(:ensureIndex)
187
220
  expected = metrics_with_attributes(metrics)
@@ -190,23 +223,28 @@ module MongoOperationTests
190
223
  end
191
224
 
192
225
  def test_ensure_index_does_not_record_insert
193
- @collection.ensure_index([[unique_field_name, Mongo::ASCENDING]])
226
+ in_transaction do
227
+ @collection.ensure_index([[unique_field_name, Mongo::ASCENDING]])
228
+ end
194
229
 
195
230
  assert_metrics_not_recorded(['Datastore/operation/MongoDB/insert'])
196
231
  end
197
232
 
198
233
  def test_ensure_index_does_call_ensure_index
199
234
  options = [[unique_field_name, Mongo::ASCENDING]]
200
-
201
- @collection.expects(:ensure_index_without_new_relic_trace).with(options, any_parameters).once
202
- @collection.ensure_index(options)
235
+ in_transaction do
236
+ @collection.expects(:ensure_index_without_new_relic_trace).with(options, any_parameters).once
237
+ @collection.ensure_index(options)
238
+ end
203
239
  end
204
240
 
205
241
  def test_records_metrics_for_drop_index
206
242
  name = @collection.create_index([[unique_field_name, Mongo::ASCENDING]])
207
243
  NewRelic::Agent.drop_buffered_data
208
244
 
209
- @collection.drop_index(name)
245
+ in_transaction do
246
+ @collection.drop_index(name)
247
+ end
210
248
 
211
249
  metrics = build_test_metrics(:dropIndex)
212
250
  expected = metrics_with_attributes(metrics)
@@ -218,7 +256,9 @@ module MongoOperationTests
218
256
  @collection.create_index([[unique_field_name, Mongo::ASCENDING]])
219
257
  NewRelic::Agent.drop_buffered_data
220
258
 
221
- @collection.drop_indexes
259
+ in_transaction do
260
+ @collection.drop_indexes
261
+ end
222
262
 
223
263
  metrics = build_test_metrics(:dropIndexes)
224
264
  expected = metrics_with_attributes(metrics)
@@ -230,7 +270,9 @@ module MongoOperationTests
230
270
  @collection.create_index([[unique_field_name, Mongo::ASCENDING]])
231
271
  NewRelic::Agent.drop_buffered_data
232
272
 
233
- @database.command({ :reIndex => @collection_name })
273
+ in_transaction do
274
+ @database.command({ :reIndex => @collection_name })
275
+ end
234
276
 
235
277
  metrics = build_test_metrics(:reIndex)
236
278
  expected = metrics_with_attributes(metrics)
@@ -241,7 +283,9 @@ module MongoOperationTests
241
283
  def test_rename_collection
242
284
  ensure_collection_exists
243
285
 
244
- @collection.rename("renamed_#{@collection_name}")
286
+ in_transaction do
287
+ @collection.rename("renamed_#{@collection_name}")
288
+ end
245
289
 
246
290
  metrics = build_test_metrics(:renameCollection)
247
291
  expected = metrics_with_attributes(metrics)
@@ -254,7 +298,9 @@ module MongoOperationTests
254
298
  def test_rename_collection_via_db
255
299
  ensure_collection_exists
256
300
 
257
- @database.rename_collection(@collection_name, "renamed_#{@collection_name}")
301
+ in_transaction do
302
+ @database.rename_collection(@collection_name, "renamed_#{@collection_name}")
303
+ end
258
304
 
259
305
  metrics = build_test_metrics(:renameCollection)
260
306
  expected = metrics_with_attributes(metrics)
@@ -267,7 +313,9 @@ module MongoOperationTests
267
313
  def test_drop_collection
268
314
  ensure_collection_exists
269
315
 
270
- @database.drop_collection(@collection_name)
316
+ in_transaction do
317
+ @database.drop_collection(@collection_name)
318
+ end
271
319
 
272
320
  metrics = build_test_metrics(:drop)
273
321
  expected = metrics_with_attributes(metrics)
@@ -278,7 +326,10 @@ module MongoOperationTests
278
326
  def test_collstats
279
327
  @collection.insert(@tribble)
280
328
  NewRelic::Agent.drop_buffered_data
281
- @collection.stats
329
+
330
+ in_transaction do
331
+ @collection.stats
332
+ end
282
333
 
283
334
  metrics = build_test_metrics(:collstats)
284
335
  expected = metrics_with_attributes(metrics)
@@ -435,7 +486,9 @@ module MongoOperationTests
435
486
 
436
487
  def test_web_requests_record_all_web_metric
437
488
  NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(true)
438
- @collection.insert(@tribble)
489
+ in_web_transaction do
490
+ @collection.insert(@tribble)
491
+ end
439
492
 
440
493
  metrics = build_test_metrics(:insert)
441
494
  expected = metrics_with_attributes(metrics)
@@ -445,14 +498,20 @@ module MongoOperationTests
445
498
 
446
499
  def test_web_requests_do_not_record_all_other_metric
447
500
  NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(true)
448
- @collection.insert(@tribble)
501
+
502
+ in_web_transaction do
503
+ @collection.insert(@tribble)
504
+ end
449
505
 
450
506
  assert_metrics_not_recorded(['Datastore/allOther'])
451
507
  end
452
508
 
453
509
  def test_other_requests_record_all_other_metric
454
510
  NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(false)
455
- @collection.insert(@tribble)
511
+
512
+ in_background_transaction do
513
+ @collection.insert(@tribble)
514
+ end
456
515
 
457
516
  metrics = build_test_metrics(:insert)
458
517
  expected = metrics_with_attributes(metrics)
@@ -462,7 +521,10 @@ module MongoOperationTests
462
521
 
463
522
  def test_other_requests_do_not_record_all_web_metric
464
523
  NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(false)
465
- @collection.insert(@tribble)
524
+
525
+ in_background_transaction do
526
+ @collection.insert(@tribble)
527
+ end
466
528
 
467
529
  assert_metrics_not_recorded(['Datastore/allWeb'])
468
530
  end