appoptics_apm 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/Dockerfile_test +7 -6
  4. data/Rakefile +2 -0
  5. data/docker-compose.yml +22 -0
  6. data/gemfiles/noop.gemfile +17 -0
  7. data/lib/appoptics_apm.rb +2 -2
  8. data/lib/appoptics_apm/api.rb +1 -2
  9. data/lib/appoptics_apm/api/layerinit.rb +3 -1
  10. data/lib/appoptics_apm/api/logging.rb +25 -25
  11. data/lib/appoptics_apm/api/memcache.rb +3 -1
  12. data/lib/appoptics_apm/api/profiling.rb +39 -33
  13. data/lib/appoptics_apm/api/tracing.rb +23 -13
  14. data/lib/appoptics_apm/api/util.rb +1 -1
  15. data/lib/appoptics_apm/base.rb +1 -0
  16. data/lib/appoptics_apm/frameworks/sinatra/templates.rb +1 -1
  17. data/lib/appoptics_apm/inst/rack.rb +135 -111
  18. data/lib/appoptics_apm/instrumentation.rb +1 -1
  19. data/lib/appoptics_apm/version.rb +1 -1
  20. data/test/instrumentation/httpclient_test.rb +4 -20
  21. data/test/instrumentation/mongo_v1_test.rb +1 -1
  22. data/test/instrumentation/rack_test.rb +1 -1
  23. data/test/instrumentation/sequel_mysql2_test.rb +1 -1
  24. data/test/instrumentation/sequel_mysql_test.rb +1 -1
  25. data/test/instrumentation/sequel_pg_test.rb +1 -1
  26. data/test/instrumentation/twitter-cassandra_test.rb +1 -1
  27. data/test/minitest_helper.rb +1 -0
  28. data/test/mocked/curb_mocked_test.rb +14 -1
  29. data/test/mocked/excon_mocked_test.rb +12 -4
  30. data/test/mocked/faraday_mocked_test.rb +5 -1
  31. data/test/mocked/http_mocked_test.rb +6 -0
  32. data/test/mocked/httpclient_mocked_test.rb +14 -1
  33. data/test/mocked/rest_client_mocked_test.rb +7 -1
  34. data/test/mocked/typhoeus_mocked_test.rb +15 -0
  35. data/test/noop/noop_test.rb +145 -0
  36. metadata +5 -4
  37. data/test/support/noop_test.rb +0 -88
@@ -325,7 +325,7 @@ if defined?(::Sequel) && !defined?(JRUBY_VERSION) && (RUBY_VERSION < "2.4")
325
325
 
326
326
  validate_event_keys(traces[1], @entry_kvs)
327
327
  traces[1]['Query'].must_equal "select_by_name"
328
- traces[1]['QueryArgs'].must_equal nil
328
+ traces[1]['QueryArgs'].must_be_nil
329
329
  traces[1]['IsPreparedStatement'].must_equal "true"
330
330
  traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:sequel][:collect_backtraces]
331
331
  validate_event_keys(traces[2], @exit_kvs)
@@ -327,7 +327,7 @@ if defined?(::Sequel) && !defined?(JRUBY_VERSION)
327
327
 
328
328
  validate_event_keys(traces[1], @entry_kvs)
329
329
  traces[1]['Query'].must_equal "select_by_name"
330
- traces[1]['QueryArgs'].must_equal nil
330
+ traces[1]['QueryArgs'].must_be_nil
331
331
  traces[1]['IsPreparedStatement'].must_equal "true"
332
332
  traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:sequel][:collect_backtraces]
333
333
  validate_event_keys(traces[2], @exit_kvs)
@@ -100,7 +100,7 @@ if defined?(::Cassandra) and !defined?(JRUBY_VERSION)
100
100
  # My crappy way to detect and fail if an exception
101
101
  # was raised. I swear there was a Minitest assertion for
102
102
  # this but can't find it.
103
- e.must_equal nil, "broken when NOT tracing"
103
+ e.must_be_nil 'broken when NOT tracing'
104
104
  raise
105
105
  end
106
106
  end
@@ -74,6 +74,7 @@ when /rails3/
74
74
 
75
75
  when /frameworks/
76
76
  when /libraries/
77
+ require 'rack/test'
77
78
  if RUBY_VERSION >= '2.0'
78
79
  # Load Sidekiq if TEST isn't defined or if it is, it calls
79
80
  # out the sidekiq tests
@@ -6,12 +6,13 @@ if !defined?(JRUBY_VERSION)
6
6
  require 'minitest_helper'
7
7
  require 'webmock/minitest'
8
8
  require 'mocha/mini_test'
9
- WebMock.allow_net_connect!
10
9
 
11
10
  class CurbMockedTest < Minitest::Test
12
11
 
13
12
  def setup
13
+ AppOpticsAPM::Context.clear
14
14
  WebMock.enable!
15
+ WebMock.reset!
15
16
  WebMock.disable_net_connect!
16
17
  AppOpticsAPM.config_lock.synchronize {
17
18
  @tm = AppOpticsAPM::Config[:tracing_mode]
@@ -39,6 +40,7 @@ if !defined?(JRUBY_VERSION)
39
40
 
40
41
  assert_requested :get, "http://127.0.0.9:8101/", times: 1
41
42
  assert_requested :get, "http://127.0.0.9:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*01$/}, times: 1
43
+ refute AppOpticsAPM::Context.isValid
42
44
  end
43
45
 
44
46
  def test_xtrace_sample_rate_0
@@ -54,6 +56,7 @@ if !defined?(JRUBY_VERSION)
54
56
  assert_requested :get, "http://127.0.0.4:8101/", times: 1
55
57
  assert_requested :get, "http://127.0.0.4:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*00$/}, times: 1
56
58
  assert_not_requested :get, "http://127.0.0.4:8101/", headers: {'X-Trace'=>/^2B0*$/}
59
+ refute AppOpticsAPM::Context.isValid
57
60
  end
58
61
 
59
62
  def test_xtrace_no_trace
@@ -77,6 +80,7 @@ if !defined?(JRUBY_VERSION)
77
80
 
78
81
  assert_requested :get, "http://127.0.0.2:8101/", times: 1
79
82
  assert_not_requested :get, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^.*/}
83
+ refute AppOpticsAPM::Context.isValid
80
84
  end
81
85
 
82
86
  def test_multi_get_no_trace
@@ -99,6 +103,7 @@ if !defined?(JRUBY_VERSION)
99
103
  urls << "http://127.0.0.7:8101/?three=3"
100
104
 
101
105
  Curl::Multi.get(urls, easy_options, multi_options)
106
+ refute AppOpticsAPM::Context.isValid
102
107
  end
103
108
 
104
109
  def test_multi_get_tracing
@@ -127,6 +132,7 @@ if !defined?(JRUBY_VERSION)
127
132
  AppOpticsAPM::API.start_trace('curb_tests') do
128
133
  Curl::Multi.get(urls, easy_options, multi_options)
129
134
  end
135
+ refute AppOpticsAPM::Context.isValid
130
136
  end
131
137
 
132
138
  def test_multi_get_tracing_not_sampling
@@ -156,6 +162,7 @@ if !defined?(JRUBY_VERSION)
156
162
  Curl::Multi.get(urls, easy_options, multi_options)
157
163
  end
158
164
  end
165
+ refute AppOpticsAPM::Context.isValid
159
166
  end
160
167
 
161
168
  def test_multi_perform_no_trace
@@ -207,6 +214,7 @@ if !defined?(JRUBY_VERSION)
207
214
  end
208
215
  end
209
216
  end
217
+ refute AppOpticsAPM::Context.isValid
210
218
  end
211
219
 
212
220
  def test_multi_perform_tracing_not_sampling
@@ -237,6 +245,7 @@ if !defined?(JRUBY_VERSION)
237
245
  end
238
246
  end
239
247
  end
248
+ refute AppOpticsAPM::Context.isValid
240
249
  end
241
250
 
242
251
  # preserve custom headers
@@ -252,6 +261,7 @@ if !defined?(JRUBY_VERSION)
252
261
  end
253
262
 
254
263
  assert_requested :get, "http://127.0.0.6:8101/", headers: {'Custom'=>'specialvalue'}, times: 1
264
+ refute AppOpticsAPM::Context.isValid
255
265
  end
256
266
 
257
267
  # The following test can't use WebMock because it interferes with our instrumentation
@@ -270,6 +280,7 @@ if !defined?(JRUBY_VERSION)
270
280
  assert curl.headers['Custom']
271
281
  assert_match /^2B[0-9,A-F]*01$/, curl.headers['X-Trace']
272
282
  assert_match /specialvalue4/, curl.headers['Custom']
283
+ refute AppOpticsAPM::Context.isValid
273
284
  end
274
285
 
275
286
  def test_preserves_custom_headers_on_http_post
@@ -287,6 +298,7 @@ if !defined?(JRUBY_VERSION)
287
298
  assert curl.headers['Custom']
288
299
  assert_match /^2B[0-9,A-F]*01$/, curl.headers['X-Trace']
289
300
  assert_match /specialvalue4/, curl.headers['Custom']
301
+ refute AppOpticsAPM::Context.isValid
290
302
  end
291
303
 
292
304
  def test_preserves_custom_headers_on_perform
@@ -304,6 +316,7 @@ if !defined?(JRUBY_VERSION)
304
316
  assert curl.headers['Custom']
305
317
  assert_match /^2B[0-9,A-F]*01$/, curl.headers['X-Trace']
306
318
  assert_match /specialvalue4/, curl.headers['Custom']
319
+ refute AppOpticsAPM::Context.isValid
307
320
  end
308
321
 
309
322
  end
@@ -6,12 +6,13 @@ if !defined?(JRUBY_VERSION)
6
6
  require 'minitest_helper'
7
7
  require 'webmock/minitest'
8
8
  require 'mocha/mini_test'
9
- WebMock.allow_net_connect!
10
9
 
11
10
  class ExconTest < Minitest::Test
12
11
 
13
12
  def setup
13
+ AppOpticsAPM::Context.clear
14
14
  WebMock.enable!
15
+ WebMock.reset!
15
16
  WebMock.disable_net_connect!
16
17
  AppOpticsAPM.config_lock.synchronize {
17
18
  @sample_rate = AppOpticsAPM::Config[:sample_rate]
@@ -52,6 +53,7 @@ if !defined?(JRUBY_VERSION)
52
53
 
53
54
  assert_requested :get, "http://127.0.0.7:8101/", times: 1
54
55
  assert_requested :get, "http://127.0.0.7:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]{56}01/}, times: 1
56
+ refute AppOpticsAPM::Context.isValid
55
57
  end
56
58
 
57
59
  def test_xtrace_tracing_not_sampling
@@ -67,6 +69,7 @@ if !defined?(JRUBY_VERSION)
67
69
  assert_requested :get, "http://127.0.0.4:8101/", times: 1
68
70
  assert_requested :get, "http://127.0.0.4:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*00$/}, times: 1
69
71
  assert_not_requested :get, "http://127.0.0.4:8101/", headers: {'X-Trace'=>/^2B0*$/}
72
+ refute AppOpticsAPM::Context.isValid
70
73
  end
71
74
 
72
75
  def test_xtrace_tracing_blacklisted
@@ -81,6 +84,7 @@ if !defined?(JRUBY_VERSION)
81
84
 
82
85
  assert_requested :get, "http://127.0.0.3:8101/", times: 1
83
86
  assert_not_requested :get, "http://127.0.0.3:8101/", headers: {'X-Trace'=>/.*/}
87
+ refute AppOpticsAPM::Context.isValid
84
88
  end
85
89
 
86
90
  # ========== excon pipelined =================================
@@ -98,6 +102,7 @@ if !defined?(JRUBY_VERSION)
98
102
  assert_requested :put, "http://127.0.0.5:8101/", times: 1
99
103
  assert_requested :get, "http://127.0.0.5:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*01$/}, times: 1
100
104
  assert_requested :put, "http://127.0.0.5:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*01$/}, times: 1
105
+ refute AppOpticsAPM::Context.isValid
101
106
  end
102
107
 
103
108
  def test_xtrace_pipelined_tracing_not_sampling
@@ -118,6 +123,7 @@ if !defined?(JRUBY_VERSION)
118
123
  assert_requested :put, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*00$/}, times: 1
119
124
  assert_not_requested :get, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^2B0*$/}
120
125
  assert_not_requested :put, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^2B0*$/}
126
+ refute AppOpticsAPM::Context.isValid
121
127
  end
122
128
 
123
129
  def test_xtrace_pipelined_no_trace
@@ -149,17 +155,19 @@ if !defined?(JRUBY_VERSION)
149
155
  assert_requested :put, "http://127.0.0.9:8101/", times: 1
150
156
  assert_not_requested :get, "http://127.9.0.8:8101/", headers: {'X-Trace'=>/^.*$/}
151
157
  assert_not_requested :put, "http://127.9.0.8:8101/", headers: {'X-Trace'=>/^.*$/}
158
+ refute AppOpticsAPM::Context.isValid
152
159
  end
153
160
 
154
161
  # ========== excon make sure headers are preserved =============================
155
162
  def test_preserves_custom_headers
156
- stub_request(:get, "http://127.0.0.6:8101/").to_return(status: 200, body: "", headers: {})
163
+ stub_request(:get, "http://127.0.0.10:8101/").to_return(status: 200, body: "", headers: {})
157
164
 
158
165
  AppOpticsAPM::API.start_trace('excon_tests') do
159
- Excon.get('http://127.0.0.6:8101', headers: { 'Custom' => 'specialvalue' })
166
+ Excon.get('http://127.0.0.10:8101', headers: { 'Custom' => 'specialvalue' })
160
167
  end
161
168
 
162
- assert_requested :get, "http://127.0.0.6:8101/", headers: {'Custom'=>'specialvalue'}, times: 1
169
+ assert_requested :get, "http://127.0.0.10:8101/", headers: {'Custom'=>'specialvalue'}, times: 1
170
+ refute AppOpticsAPM::Context.isValid
163
171
  end
164
172
  end
165
173
  end
@@ -6,12 +6,13 @@ if !defined?(JRUBY_VERSION)
6
6
  require 'minitest_helper'
7
7
  require 'webmock/minitest'
8
8
  require 'mocha/mini_test'
9
- WebMock.allow_net_connect!
10
9
 
11
10
  class FaradayMockedTest < Minitest::Test
12
11
 
13
12
  def setup
13
+ AppOpticsAPM::Context.clear
14
14
  WebMock.enable!
15
+ WebMock.reset!
15
16
  WebMock.disable_net_connect!
16
17
  AppOpticsAPM.config_lock.synchronize {
17
18
  @sample_rate = AppOpticsAPM::Config[:sample_rate]
@@ -40,6 +41,7 @@ if !defined?(JRUBY_VERSION)
40
41
 
41
42
  assert_requested :get, "http://127.0.0.1:8101/", times: 1
42
43
  assert_requested :get, "http://127.0.0.1:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*01$/}, times: 1
44
+ refute AppOpticsAPM::Context.isValid
43
45
  end
44
46
 
45
47
  def test_tracing_not_sampling
@@ -58,6 +60,7 @@ if !defined?(JRUBY_VERSION)
58
60
  assert_requested :get, "http://127.0.0.12:8101/", times: 1
59
61
  assert_requested :get, "http://127.0.0.12:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*00$/}, times: 1
60
62
  assert_not_requested :get, "http://127.0.0.12:8101/", headers: {'X-Trace'=>/^2B0*$/}
63
+ refute AppOpticsAPM::Context.isValid
61
64
  end
62
65
 
63
66
  def test_no_xtrace
@@ -87,6 +90,7 @@ if !defined?(JRUBY_VERSION)
87
90
 
88
91
  assert_requested :get, "http://127.0.0.4:8101/", times: 1
89
92
  assert_not_requested :get, "http://127.0.0.4:8101/", headers: {'X-Trace'=>/^.*$/}
93
+ refute AppOpticsAPM::Context.isValid
90
94
  end
91
95
 
92
96
  end
@@ -14,6 +14,7 @@ unless defined?(JRUBY_VERSION)
14
14
  end
15
15
 
16
16
  def setup
17
+ AppOpticsAPM::Context.clear
17
18
  AppOpticsAPM.config_lock.synchronize do
18
19
  @sample_rate = AppOpticsAPM::Config[:sample_rate]
19
20
  end
@@ -41,6 +42,7 @@ unless defined?(JRUBY_VERSION)
41
42
  http.request(request)
42
43
  end
43
44
  end
45
+ refute AppOpticsAPM::Context.isValid
44
46
  end
45
47
 
46
48
  def test_tracing_not_sampling
@@ -60,6 +62,7 @@ unless defined?(JRUBY_VERSION)
60
62
  end
61
63
  end
62
64
  end
65
+ refute AppOpticsAPM::Context.isValid
63
66
  end
64
67
 
65
68
  def test_no_xtrace
@@ -89,6 +92,7 @@ unless defined?(JRUBY_VERSION)
89
92
  end
90
93
  end
91
94
  end
95
+ refute AppOpticsAPM::Context.isValid
92
96
  end
93
97
 
94
98
  def test_not_sampling_blacklisted
@@ -107,6 +111,7 @@ unless defined?(JRUBY_VERSION)
107
111
  end
108
112
  end
109
113
  end
114
+ refute AppOpticsAPM::Context.isValid
110
115
  end
111
116
 
112
117
  # ========== make sure headers are preserved =============================
@@ -124,6 +129,7 @@ unless defined?(JRUBY_VERSION)
124
129
  http.request(request) # Net::HTTPResponse object
125
130
  end
126
131
  end
132
+ refute AppOpticsAPM::Context.isValid
127
133
  end
128
134
  end
129
135
  end
@@ -5,12 +5,13 @@ unless defined?(JRUBY_VERSION)
5
5
  require 'minitest_helper'
6
6
  require 'webmock/minitest'
7
7
  require 'mocha/mini_test'
8
- WebMock.allow_net_connect!
9
8
 
10
9
  class HTTPClientMockedTest < Minitest::Test
11
10
 
12
11
  def setup
12
+ AppOpticsAPM::Context.clear
13
13
  WebMock.enable!
14
+ WebMock.reset!
14
15
  WebMock.disable_net_connect!
15
16
  AppOpticsAPM.config_lock.synchronize do
16
17
  @sample_rate = AppOpticsAPM::Config[:sample_rate]
@@ -38,6 +39,7 @@ unless defined?(JRUBY_VERSION)
38
39
 
39
40
  assert_requested :get, "http://127.0.0.1:8101/", times: 1
40
41
  assert_requested :get, "http://127.0.0.1:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*01$/}, times: 1
42
+ refute AppOpticsAPM::Context.isValid
41
43
  end
42
44
 
43
45
  def test_do_request_tracing_sampling_hash_headers
@@ -49,6 +51,7 @@ unless defined?(JRUBY_VERSION)
49
51
 
50
52
  assert_requested :get, "http://127.0.0.6:8101/", times: 1
51
53
  assert_requested :get, "http://127.0.0.6:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*01$/}, times: 1
54
+ refute AppOpticsAPM::Context.isValid
52
55
  end
53
56
 
54
57
  def test_do_request_tracing_not_sampling
@@ -64,6 +67,7 @@ unless defined?(JRUBY_VERSION)
64
67
  assert_requested :get, "http://127.0.0.2:8101/", times: 1
65
68
  assert_requested :get, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*00$/}, times: 1
66
69
  assert_not_requested :get, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^2B0*$/}
70
+ refute AppOpticsAPM::Context.isValid
67
71
  end
68
72
 
69
73
  def test_do_request_no_xtrace
@@ -88,6 +92,7 @@ unless defined?(JRUBY_VERSION)
88
92
 
89
93
  assert_requested :get, "http://127.0.0.4:8101/"
90
94
  assert_not_requested :get, "http://127.0.0.4:8101/", headers: {'X-Trace'=>/^.*$/}
95
+ refute AppOpticsAPM::Context.isValid
91
96
  end
92
97
 
93
98
  def test_do_request_not_sampling_blacklisted
@@ -104,6 +109,7 @@ unless defined?(JRUBY_VERSION)
104
109
 
105
110
  assert_requested :get, "http://127.0.0.5:8101/"
106
111
  assert_not_requested :get, "http://127.0.0.5:8101/", headers: {'X-Trace'=>/^.*$/}
112
+ refute AppOpticsAPM::Context.isValid
107
113
  end
108
114
 
109
115
  #====== ASYNC REQUEST ================================================
@@ -123,6 +129,7 @@ unless defined?(JRUBY_VERSION)
123
129
  clnt = HTTPClient.new
124
130
  clnt.get_async('http://127.0.0.11:8101/', nil, [['some_header', 'some_value'], ['some_header2', 'some_value2']])
125
131
  end
132
+ refute AppOpticsAPM::Context.isValid
126
133
  end
127
134
 
128
135
  def test_async_tracing_sampling_hash_headers
@@ -139,6 +146,7 @@ unless defined?(JRUBY_VERSION)
139
146
  clnt = HTTPClient.new
140
147
  clnt.get_async('http://127.0.0.16:8101/', nil, { 'some_header' => 'some_value', 'some_header2' => 'some_value2' })
141
148
  end
149
+ refute AppOpticsAPM::Context.isValid
142
150
  end
143
151
 
144
152
  def test_async_tracing_not_sampling
@@ -159,6 +167,7 @@ unless defined?(JRUBY_VERSION)
159
167
  clnt.get_async('http://127.0.0.12:8101/')
160
168
  end
161
169
  end
170
+ refute AppOpticsAPM::Context.isValid
162
171
  end
163
172
 
164
173
  def test_async_no_xtrace
@@ -192,6 +201,7 @@ unless defined?(JRUBY_VERSION)
192
201
  clnt.get_async('http://127.0.0.14:8101/')
193
202
  end
194
203
  end
204
+ refute AppOpticsAPM::Context.isValid
195
205
  end
196
206
 
197
207
  def test_async_not_sampling_blacklisted
@@ -212,6 +222,7 @@ unless defined?(JRUBY_VERSION)
212
222
  clnt.get_async('http://127.0.0.15:8101/')
213
223
  end
214
224
  end
225
+ refute AppOpticsAPM::Context.isValid
215
226
  end
216
227
 
217
228
  # ========== make sure headers are preserved =============================
@@ -224,6 +235,7 @@ unless defined?(JRUBY_VERSION)
224
235
  end
225
236
 
226
237
  assert_requested :get, "http://127.0.0.6:8101/", headers: {'Custom'=>'specialvalue'}, times: 1
238
+ refute AppOpticsAPM::Context.isValid
227
239
  end
228
240
 
229
241
  def test_async_preserves_custom_headers
@@ -240,6 +252,7 @@ unless defined?(JRUBY_VERSION)
240
252
  clnt = HTTPClient.new
241
253
  clnt.get_async('http://127.0.0.6:8101/', nil, [['Custom', 'specialvalue'], ['some_header2', 'some_value2']])
242
254
  end
255
+ refute AppOpticsAPM::Context.isValid
243
256
  end
244
257
  end
245
258
  end
@@ -5,12 +5,13 @@ unless defined?(JRUBY_VERSION)
5
5
  require 'minitest_helper'
6
6
  require 'webmock/minitest'
7
7
  require 'mocha/mini_test'
8
- WebMock.allow_net_connect!
9
8
 
10
9
  class RestClientMockedTest < Minitest::Test
11
10
 
12
11
  def setup
12
+ AppOpticsAPM::Context.clear
13
13
  WebMock.enable!
14
+ WebMock.reset!
14
15
  WebMock.disable_net_connect!
15
16
  AppOpticsAPM.config_lock.synchronize do
16
17
  @sample_rate = AppOpticsAPM::Config[:sample_rate]
@@ -35,6 +36,7 @@ unless defined?(JRUBY_VERSION)
35
36
  end
36
37
 
37
38
  assert_requested :get, "http://127.0.0.1:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*01$/}, times: 1
39
+ refute AppOpticsAPM::Context.isValid
38
40
  end
39
41
 
40
42
  def test_tracing_not_sampling
@@ -49,6 +51,7 @@ unless defined?(JRUBY_VERSION)
49
51
 
50
52
  assert_requested :get, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*00$/}, times: 1
51
53
  assert_not_requested :get, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^2B0*$/}
54
+ refute AppOpticsAPM::Context.isValid
52
55
  end
53
56
 
54
57
  def test_no_xtrace
@@ -72,6 +75,7 @@ unless defined?(JRUBY_VERSION)
72
75
 
73
76
  assert_requested :get, "http://127.0.0.4:8101/", times: 1
74
77
  assert_not_requested :get, "http://127.0.0.4:8101/", headers: {'X-Trace'=>/^.*$/}
78
+ refute AppOpticsAPM::Context.isValid
75
79
  end
76
80
 
77
81
  def test_not_sampling_blacklisted
@@ -87,6 +91,7 @@ unless defined?(JRUBY_VERSION)
87
91
 
88
92
  assert_requested :get, "http://127.0.0.5:8101/", times: 1
89
93
  assert_not_requested :get, "http://127.0.0.5:8101/", headers: {'X-Trace'=>/^.*$/}
94
+ refute AppOpticsAPM::Context.isValid
90
95
  end
91
96
 
92
97
  def test_preserves_custom_headers
@@ -97,6 +102,7 @@ unless defined?(JRUBY_VERSION)
97
102
  end
98
103
 
99
104
  assert_requested :get, "http://127.0.0.6:8101/", headers: {'Custom'=>'specialvalue'}, times: 1
105
+ refute AppOpticsAPM::Context.isValid
100
106
  end
101
107
 
102
108
  end