appoptics_apm 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile_test +6 -7
  3. data/README.md +3 -3
  4. data/Rakefile +3 -2
  5. data/appoptics_apm.gemspec +2 -2
  6. data/docker-compose.yml +0 -22
  7. data/ext/oboe_metal/extconf.rb +4 -0
  8. data/lib/appoptics_apm/config.rb +11 -6
  9. data/lib/appoptics_apm/version.rb +1 -1
  10. metadata +3 -202
  11. data/gemfiles/delayed_job.gemfile +0 -36
  12. data/gemfiles/frameworks.gemfile +0 -44
  13. data/gemfiles/instrumentation_mocked.gemfile +0 -29
  14. data/gemfiles/libraries.gemfile +0 -85
  15. data/gemfiles/noop.gemfile +0 -17
  16. data/gemfiles/rails23.gemfile +0 -39
  17. data/gemfiles/rails30.gemfile +0 -42
  18. data/gemfiles/rails31.gemfile +0 -44
  19. data/gemfiles/rails32.gemfile +0 -54
  20. data/gemfiles/rails40.gemfile +0 -27
  21. data/gemfiles/rails41.gemfile +0 -27
  22. data/gemfiles/rails42.gemfile +0 -35
  23. data/gemfiles/rails50.gemfile +0 -44
  24. data/gemfiles/rails51.gemfile +0 -44
  25. data/test/benchmark/README.md +0 -65
  26. data/test/benchmark/logging_bench.rb +0 -54
  27. data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +0 -69
  28. data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +0 -43
  29. data/test/frameworks/apps/grape_nested.rb +0 -33
  30. data/test/frameworks/apps/grape_simple.rb +0 -80
  31. data/test/frameworks/apps/padrino_simple.rb +0 -80
  32. data/test/frameworks/apps/sinatra_simple.rb +0 -55
  33. data/test/frameworks/grape_test.rb +0 -286
  34. data/test/frameworks/padrino_test.rb +0 -222
  35. data/test/frameworks/rails3x_test.rb +0 -554
  36. data/test/frameworks/rails4x_test.rb +0 -570
  37. data/test/frameworks/rails5x_api_test.rb +0 -210
  38. data/test/frameworks/rails5x_test.rb +0 -376
  39. data/test/frameworks/rails_shared_tests.rb +0 -172
  40. data/test/frameworks/sinatra_test.rb +0 -140
  41. data/test/instrumentation/bunny_client_test.rb +0 -276
  42. data/test/instrumentation/bunny_consumer_test.rb +0 -204
  43. data/test/instrumentation/curb_test.rb +0 -398
  44. data/test/instrumentation/dalli_test.rb +0 -177
  45. data/test/instrumentation/em_http_request_test.rb +0 -89
  46. data/test/instrumentation/excon_test.rb +0 -231
  47. data/test/instrumentation/faraday_test.rb +0 -228
  48. data/test/instrumentation/http_test.rb +0 -143
  49. data/test/instrumentation/httpclient_test.rb +0 -304
  50. data/test/instrumentation/memcache_test.rb +0 -260
  51. data/test/instrumentation/memcached_test.rb +0 -229
  52. data/test/instrumentation/mongo_v1_test.rb +0 -479
  53. data/test/instrumentation/mongo_v2_index_test.rb +0 -124
  54. data/test/instrumentation/mongo_v2_test.rb +0 -584
  55. data/test/instrumentation/mongo_v2_view_test.rb +0 -435
  56. data/test/instrumentation/moped_test.rb +0 -517
  57. data/test/instrumentation/rack_test.rb +0 -165
  58. data/test/instrumentation/redis_hashes_test.rb +0 -268
  59. data/test/instrumentation/redis_keys_test.rb +0 -321
  60. data/test/instrumentation/redis_lists_test.rb +0 -310
  61. data/test/instrumentation/redis_misc_test.rb +0 -163
  62. data/test/instrumentation/redis_sets_test.rb +0 -296
  63. data/test/instrumentation/redis_sortedsets_test.rb +0 -328
  64. data/test/instrumentation/redis_strings_test.rb +0 -349
  65. data/test/instrumentation/resque_test.rb +0 -185
  66. data/test/instrumentation/rest-client_test.rb +0 -288
  67. data/test/instrumentation/sequel_mysql2_test.rb +0 -353
  68. data/test/instrumentation/sequel_mysql_test.rb +0 -334
  69. data/test/instrumentation/sequel_pg_test.rb +0 -336
  70. data/test/instrumentation/sidekiq-client_test.rb +0 -159
  71. data/test/instrumentation/sidekiq-worker_test.rb +0 -180
  72. data/test/instrumentation/twitter-cassandra_test.rb +0 -424
  73. data/test/instrumentation/typhoeus_test.rb +0 -284
  74. data/test/jobs/delayed_job/db_worker_job.rb +0 -29
  75. data/test/jobs/delayed_job/error_worker_job.rb +0 -10
  76. data/test/jobs/delayed_job/remote_call_worker_job.rb +0 -20
  77. data/test/jobs/resque/db_worker_job.rb +0 -29
  78. data/test/jobs/resque/error_worker_job.rb +0 -10
  79. data/test/jobs/resque/remote_call_worker_job.rb +0 -20
  80. data/test/jobs/sidekiq/db_worker_job.rb +0 -29
  81. data/test/jobs/sidekiq/error_worker_job.rb +0 -10
  82. data/test/jobs/sidekiq/remote_call_worker_job.rb +0 -20
  83. data/test/minitest_helper.rb +0 -277
  84. data/test/mocked/curb_mocked_test.rb +0 -324
  85. data/test/mocked/excon_mocked_test.rb +0 -174
  86. data/test/mocked/faraday_mocked_test.rb +0 -97
  87. data/test/mocked/http_mocked_test.rb +0 -135
  88. data/test/mocked/httpclient_mocked_test.rb +0 -258
  89. data/test/mocked/rest_client_mocked_test.rb +0 -109
  90. data/test/mocked/typhoeus_mocked_test.rb +0 -207
  91. data/test/models/widget.rb +0 -36
  92. data/test/noop/noop_test.rb +0 -145
  93. data/test/profiling/legacy_method_profiling_test.rb +0 -201
  94. data/test/profiling/method_profiling_test.rb +0 -631
  95. data/test/queues/delayed_job-client_test.rb +0 -95
  96. data/test/queues/delayed_job-worker_test.rb +0 -91
  97. data/test/reporter/reporter_test.rb +0 -14
  98. data/test/servers/delayed_job.rb +0 -107
  99. data/test/servers/rackapp_8101.rb +0 -29
  100. data/test/servers/rails3x_8140.rb +0 -96
  101. data/test/servers/rails4x_8140.rb +0 -96
  102. data/test/servers/rails5x_8140.rb +0 -95
  103. data/test/servers/rails5x_api_8150.rb +0 -78
  104. data/test/servers/sidekiq.rb +0 -29
  105. data/test/servers/sidekiq.yml +0 -7
  106. data/test/servers/sidekiq_initializer.rb +0 -25
  107. data/test/settings +0 -0
  108. data/test/support/auto_tracing_test.rb +0 -50
  109. data/test/support/backcompat_test.rb +0 -276
  110. data/test/support/config_test.rb +0 -149
  111. data/test/support/dnt_test.rb +0 -98
  112. data/test/support/init_report_test.rb +0 -25
  113. data/test/support/liboboe_settings_test.rb +0 -110
  114. data/test/support/logging_test.rb +0 -130
  115. data/test/support/sql_sanitize_test.rb +0 -55
  116. data/test/support/tracing_mode_test.rb +0 -33
  117. data/test/support/tvalias_test.rb +0 -15
  118. data/test/support/xtrace_test.rb +0 -41
@@ -1,554 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- require "minitest_helper"
5
-
6
- if defined?(::Rails)
7
-
8
- describe "Rails3x" do
9
- before do
10
- clear_all_traces
11
- AppOpticsAPM.config_lock.synchronize {
12
- @tm = AppOpticsAPM::Config[:tracing_mode]
13
- @collect_backtraces = AppOpticsAPM::Config[:action_controller][:collect_backtraces]
14
- @sample_rate = AppOpticsAPM::Config[:sample_rate]
15
- @sanitize_sql = AppOpticsAPM::Config[:sanitize_sql]
16
- }
17
- ENV['DBTYPE'] = "postgresql" unless ENV['DBTYPE']
18
- ENV['TEST_DB_URI'] ||= 'http://127.0.0.1:8140'
19
- end
20
-
21
- after do
22
- AppOpticsAPM.config_lock.synchronize {
23
- AppOpticsAPM::Config[:action_controller][:collect_backtraces] = @collect_backtraces
24
- AppOpticsAPM::Config[:tracing_mode] = @tm
25
- AppOpticsAPM::Config[:sample_rate] = @sample_rate
26
- AppOpticsAPM::Config[:sanitize_sql] = @sanitize_sql
27
- }
28
- end
29
-
30
- it "should trace a request to a rails stack" do
31
-
32
- uri = URI.parse("#{ENV['TEST_DB_URI']}/hello/world")
33
- r = Net::HTTP.get_response(uri)
34
-
35
- traces = get_all_traces
36
-
37
- traces.count.must_equal 8
38
- unless defined?(JRUBY_VERSION)
39
- # We don't test this under JRuby because the Java instrumentation
40
- # for the DB drivers doesn't use our test reporter hence we won't
41
- # see all trace events. :-( To be improved.
42
- valid_edges?(traces).must_equal true
43
- end
44
- validate_outer_layers(traces, 'rack')
45
-
46
- traces[0]['Layer'].must_equal "rack"
47
- traces[0]['Label'].must_equal "entry"
48
- traces[0]['URL'].must_equal "/hello/world"
49
-
50
- traces[1]['Layer'].must_equal "rack"
51
- traces[1]['Label'].must_equal "info"
52
-
53
- traces[2]['Layer'].must_equal "rails"
54
- traces[2]['Label'].must_equal "entry"
55
-
56
- traces[3]['Label'].must_equal "info"
57
- traces[3]['Controller'].must_equal "HelloController"
58
- traces[3]['Action'].must_equal "world"
59
-
60
- traces[4]['Layer'].must_equal "actionview"
61
- traces[4]['Label'].must_equal "entry"
62
-
63
- traces[5]['Layer'].must_equal "actionview"
64
- traces[5]['Label'].must_equal "exit"
65
-
66
- traces[6]['Layer'].must_equal "rails"
67
- traces[6]['Label'].must_equal "exit"
68
-
69
- traces[7]['Layer'].must_equal "rack"
70
- traces[7]['Label'].must_equal "exit"
71
-
72
- # Validate the existence of the response header
73
- r.header.key?('X-Trace').must_equal true
74
- r.header['X-Trace'].must_equal traces[7]['X-Trace']
75
- end
76
-
77
- it "should trace a request to a rails metal stack" do
78
-
79
- uri = URI.parse("#{ENV['TEST_DB_URI']}/hello/metal")
80
- r = Net::HTTP.get_response(uri)
81
-
82
- traces = get_all_traces
83
-
84
- traces.count.must_equal 5
85
- unless defined?(JRUBY_VERSION)
86
- # We don't test this under JRuby because the Java instrumentation
87
- # for the DB drivers doesn't use our test reporter hence we won't
88
- # see all trace events. :-( To be improved.
89
- valid_edges?(traces).must_equal true
90
- end
91
- validate_outer_layers(traces, 'rack')
92
-
93
- traces[0]['Layer'].must_equal "rack"
94
- traces[0]['Label'].must_equal "entry"
95
- traces[0]['URL'].must_equal "/hello/metal"
96
-
97
- traces[1]['Layer'].must_equal "rack"
98
- traces[1]['Label'].must_equal "info"
99
-
100
- traces[2]['Label'].must_equal "profile_entry"
101
- traces[2]['Language'].must_equal "ruby"
102
- traces[2]['ProfileName'].must_equal "world"
103
- traces[2]['Class'].must_equal "FerroController"
104
-
105
- traces[3]['Label'].must_equal "profile_exit"
106
- traces[3]['Language'].must_equal "ruby"
107
- traces[3]['ProfileName'].must_equal "world"
108
-
109
- traces[4]['Layer'].must_equal "rack"
110
- traces[4]['Label'].must_equal "exit"
111
-
112
- # Validate the existence of the response header
113
- r.header.key?('X-Trace').must_equal true
114
- r.header['X-Trace'].must_equal traces[4]['X-Trace']
115
- end
116
-
117
- # TODO: should we have this test for other rails versions as well?
118
- # TODO: review this test and why it fails (sometimes?)
119
- it "should trace rails postgresql db calls" do
120
- # Skip for JRuby since the java instrumentation
121
- # handles DB instrumentation for JRuby
122
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != "postgresql"
123
-
124
- uri = URI.parse('http://127.0.0.1:8140/hello/db')
125
- r = Net::HTTP.get_response(uri)
126
-
127
- traces = get_all_traces
128
-
129
- traces.count.must_equal 14
130
- valid_edges?(traces).must_equal true
131
- validate_outer_layers(traces, 'rack')
132
-
133
- traces[4]['Layer'].must_equal "activerecord"
134
- traces[4]['Label'].must_equal "entry"
135
- traces[4]['Flavor'].must_equal "postgresql"
136
-
137
- # Some versions of rails adds in another space before the ORDER keyword.
138
- # Make 2 or more consecutive spaces just 1
139
- sql = traces[4]['Query'].gsub(/\s{2,}/, ' ')
140
- sql.must_equal "INSERT INTO \"widgets\" (\"created_at\", \"description\", \"name\", \"updated_at\") VALUES ($?, $?, $?, $?) RETURNING \"id\""
141
-
142
- traces[4]['Name'].must_equal "SQL"
143
- traces[4].key?('Backtrace').must_equal true
144
-
145
- traces[5]['Layer'].must_equal "activerecord"
146
- traces[5]['Label'].must_equal "exit"
147
-
148
- traces[6]['Layer'].must_equal "activerecord"
149
- traces[6]['Label'].must_equal "entry"
150
- traces[6]['Flavor'].must_equal "postgresql"
151
- traces[6]['Query'].must_equal "SELECT \"widgets\".* FROM \"widgets\" WHERE \"widgets\".\"name\" = ? LIMIT ?"
152
- traces[6]['Name'].must_equal "Widget Load"
153
- traces[6].key?('Backtrace').must_equal true
154
- traces[6].key?('QueryArgs').must_equal false
155
-
156
- traces[7]['Layer'].must_equal "activerecord"
157
- traces[7]['Label'].must_equal "exit"
158
-
159
- traces[8]['Layer'].must_equal "activerecord"
160
- traces[8]['Label'].must_equal "entry"
161
- traces[8]['Flavor'].must_equal "postgresql"
162
-
163
- # Remove the widget id so we can test everything else
164
- sql = traces[8]['Query'].gsub(/\d+/, 'xxx')
165
- sql.must_equal "DELETE FROM \"widgets\" WHERE \"widgets\".\"id\" = ?"
166
-
167
- traces[8]['Name'].must_equal "SQL"
168
- traces[8].key?('Backtrace').must_equal true
169
- traces[8].key?('QueryArgs').must_equal false
170
-
171
- traces[9]['Layer'].must_equal "activerecord"
172
- traces[9]['Label'].must_equal "exit"
173
-
174
- # Validate the existence of the response header
175
- r['X-Trace'].must_equal traces[13]['X-Trace']
176
- end
177
-
178
- it "should trace rails mysql db calls" do
179
- # Skip for JRuby since the java instrumentation
180
- # handles DB instrumentation for JRuby
181
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != "mysql"
182
-
183
- AppOpticsAPM::Config[:sanitize_sql] = false
184
-
185
- uri = URI.parse("#{ENV['TEST_DB_URI']}/hello/db")
186
- r = Net::HTTP.get_response(uri)
187
-
188
- traces = get_all_traces
189
- traces.count.must_equal 18
190
- valid_edges?(traces).must_equal true
191
- validate_outer_layers(traces, 'rack')
192
-
193
- traces[4]['Layer'].must_equal "activerecord"
194
- traces[4]['Label'].must_equal "entry"
195
- traces[4]['Flavor'].must_equal "mysql"
196
- traces[4]['Query'].must_equal "BEGIN"
197
- traces[4].key?('Backtrace').must_equal true
198
-
199
- traces[5]['Layer'].must_equal "activerecord"
200
- traces[5]['Label'].must_equal "exit"
201
-
202
- traces[6]['Layer'].must_equal "activerecord"
203
- traces[6]['Label'].must_equal "entry"
204
- traces[6]['Flavor'].must_equal "mysql"
205
- traces[6]['Query'].must_equal "INSERT INTO `widgets` (`created_at`, `description`, `name`, `updated_at`) VALUES (?, ?, ?, ?)"
206
- traces[6]['Name'].must_equal "SQL"
207
- traces[6].key?('Backtrace').must_equal true
208
- traces[6].key?('QueryArgs').must_equal true
209
-
210
- traces[7]['Layer'].must_equal "activerecord"
211
- traces[7]['Label'].must_equal "exit"
212
-
213
- traces[8]['Layer'].must_equal "activerecord"
214
- traces[8]['Label'].must_equal "entry"
215
- traces[8]['Flavor'].must_equal "mysql"
216
- traces[8]['Query'].must_equal "COMMIT"
217
- traces[8].key?('Backtrace').must_equal true
218
-
219
- traces[9]['Layer'].must_equal "activerecord"
220
- traces[9]['Label'].must_equal "exit"
221
-
222
- traces[10]['Layer'].must_equal "activerecord"
223
- traces[10]['Label'].must_equal "entry"
224
- traces[10]['Flavor'].must_equal "mysql"
225
- traces[10]['Name'].must_equal "Widget Load"
226
- traces[10].key?('Backtrace').must_equal true
227
-
228
- # Some versions of rails adds in another space before the ORDER keyword.
229
- # Make 2 or more consecutive spaces just 1
230
- sql = traces[10]['Query'].gsub(/\s{2,}/, ' ')
231
- sql.must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = 'blah' LIMIT 1"
232
-
233
- traces[11]['Layer'].must_equal "activerecord"
234
- traces[11]['Label'].must_equal "exit"
235
-
236
- traces[12]['Layer'].must_equal "activerecord"
237
- traces[12]['Label'].must_equal "entry"
238
- traces[12]['Flavor'].must_equal "mysql"
239
- traces[12]['Name'].must_equal "SQL"
240
- traces[12].key?('Backtrace').must_equal true
241
- traces[12].key?('QueryArgs').must_equal false
242
-
243
- # Replace the datestamps with xxx to make testing easier
244
- sql = traces[12]['Query'].gsub(/\d+/, 'xxx')
245
- sql.must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = xxx"
246
-
247
- traces[13]['Layer'].must_equal "activerecord"
248
- traces[13]['Label'].must_equal "exit"
249
-
250
- traces[14]['Layer'].must_equal "actionview"
251
- traces[14]['Label'].must_equal "entry"
252
-
253
- # Validate the existence of the response header
254
- r['X-Trace'].must_equal traces[17]['X-Trace']
255
- end
256
-
257
- it "should trace rails mysql db calls with sanitize sql" do
258
- # Skip for JRuby since the java instrumentation
259
- # handles DB instrumentation for JRuby
260
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != "mysql"
261
-
262
- AppOpticsAPM::Config[:sanitize_sql] = true
263
-
264
- uri = URI.parse("#{ENV['TEST_DB_URI']}/hello/db")
265
- r = Net::HTTP.get_response(uri)
266
-
267
- traces = get_all_traces
268
- traces.count.must_equal 18
269
- valid_edges?(traces).must_equal true
270
- validate_outer_layers(traces, 'rack')
271
-
272
- traces[4]['Layer'].must_equal "activerecord"
273
- traces[4]['Label'].must_equal "entry"
274
- traces[4]['Flavor'].must_equal "mysql"
275
- traces[4]['Query'].must_equal "BEGIN"
276
- traces[4].key?('Backtrace').must_equal true
277
-
278
- traces[5]['Layer'].must_equal "activerecord"
279
- traces[5]['Label'].must_equal "exit"
280
-
281
- traces[6]['Layer'].must_equal "activerecord"
282
- traces[6]['Label'].must_equal "entry"
283
- traces[6]['Flavor'].must_equal "mysql"
284
- traces[6]['Query'].must_equal "INSERT INTO `widgets` (`created_at`, `description`, `name`, `updated_at`) VALUES (?, ?, ?, ?)"
285
- traces[6]['Name'].must_equal "SQL"
286
- traces[6].key?('Backtrace').must_equal true
287
- traces[6].key?('QueryArgs').must_equal false
288
-
289
- traces[7]['Layer'].must_equal "activerecord"
290
- traces[7]['Label'].must_equal "exit"
291
-
292
- traces[8]['Layer'].must_equal "activerecord"
293
- traces[8]['Label'].must_equal "entry"
294
- traces[8]['Flavor'].must_equal "mysql"
295
- traces[8]['Query'].must_equal "COMMIT"
296
- traces[8].key?('Backtrace').must_equal true
297
-
298
- traces[9]['Layer'].must_equal "activerecord"
299
- traces[9]['Label'].must_equal "exit"
300
-
301
- traces[10]['Layer'].must_equal "activerecord"
302
- traces[10]['Label'].must_equal "entry"
303
- traces[10]['Flavor'].must_equal "mysql"
304
- traces[10]['Name'].must_equal "Widget Load"
305
- traces[10].key?('Backtrace').must_equal true
306
- traces[10]['Query'].gsub!(/ /, ' ')
307
- traces[10]['Query'].must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = ? LIMIT ?"
308
-
309
- traces[11]['Layer'].must_equal "activerecord"
310
- traces[11]['Label'].must_equal "exit"
311
-
312
- traces[12]['Layer'].must_equal "activerecord"
313
- traces[12]['Label'].must_equal "entry"
314
- traces[12]['Flavor'].must_equal "mysql"
315
- traces[12]['Name'].must_equal "SQL"
316
- traces[12].key?('Backtrace').must_equal true
317
- traces[12].key?('QueryArgs').must_equal false
318
-
319
- # Replace the datestamps with xxx to make testing easier
320
- sql = traces[12]['Query'].gsub(/\d+/, 'xxx')
321
- sql.must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = ?"
322
-
323
- traces[13]['Layer'].must_equal "activerecord"
324
- traces[13]['Label'].must_equal "exit"
325
-
326
- traces[14]['Layer'].must_equal "actionview"
327
- traces[14]['Label'].must_equal "entry"
328
-
329
- # Validate the existence of the response header
330
- r['X-Trace'].must_equal traces[17]['X-Trace']
331
- end
332
-
333
- it "should trace rails mysql2 db calls" do
334
- # Skip for JRuby since the java instrumentation
335
- # handles DB instrumentation for JRuby
336
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != 'mysql2'
337
-
338
- AppOpticsAPM::Config[:sanitize_sql] = false
339
-
340
- uri = URI.parse("#{ENV['TEST_DB_URI']}/hello/db")
341
- r = Net::HTTP.get_response(uri)
342
-
343
- traces = get_all_traces
344
-
345
- traces.count.must_equal 14
346
- valid_edges?(traces).must_equal true
347
- validate_outer_layers(traces, 'rack')
348
-
349
- traces[4]['Layer'].must_equal "activerecord"
350
- traces[4]['Label'].must_equal "entry"
351
- traces[4]['Flavor'].must_equal "mysql"
352
-
353
- # Replace the datestamps with xxx to make testing easier
354
- traces[4]['Query'].gsub!(/\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d/, 'xxx')
355
- traces[4]['Query'].must_equal "INSERT INTO `widgets` (`created_at`, `description`, `name`, `updated_at`) VALUES ('xxx', 'This is an amazing widget.', 'blah', 'xxx')"
356
-
357
- traces[4]['Name'].must_equal "SQL"
358
- traces[4].key?('Backtrace').must_equal true
359
-
360
- traces[5]['Layer'].must_equal "activerecord"
361
- traces[5]['Label'].must_equal "exit"
362
-
363
- traces[6]['Layer'].must_equal "activerecord"
364
- traces[6]['Label'].must_equal "entry"
365
- traces[6]['Flavor'].must_equal "mysql"
366
- traces[6]['Query'].must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = 'blah' LIMIT 1"
367
- traces[6]['Name'].must_equal "Widget Load"
368
- traces[6].key?('Backtrace').must_equal true
369
-
370
- traces[7]['Layer'].must_equal "activerecord"
371
- traces[7]['Label'].must_equal "exit"
372
-
373
- traces[8]['Layer'].must_equal "activerecord"
374
- traces[8]['Label'].must_equal "entry"
375
- traces[8]['Flavor'].must_equal "mysql"
376
-
377
- # Replace the datestamps with xxx to make testing easier
378
- sql = traces[8]['Query'].gsub(/\d+/, 'xxx')
379
- sql.must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = xxx"
380
-
381
- traces[8]['Name'].must_equal "SQL"
382
- traces[8].key?('Backtrace').must_equal true
383
- traces[8].key?('QueryArgs').must_equal false
384
-
385
- traces[9]['Layer'].must_equal "activerecord"
386
- traces[9]['Label'].must_equal "exit"
387
-
388
- # Validate the existence of the response header
389
- r.header.key?('X-Trace').must_equal true
390
- r.header['X-Trace'].must_equal traces[13]['X-Trace']
391
- end
392
-
393
- it "should trace rails mysql2 db calls with sanitize sql" do
394
- # Skip for JRuby since the java instrumentation
395
- # handles DB instrumentation for JRuby
396
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != 'mysql2'
397
-
398
- AppOpticsAPM::Config[:sanitize_sql] = true
399
-
400
- uri = URI.parse("#{ENV['TEST_DB_URI']}/hello/db")
401
- r = Net::HTTP.get_response(uri)
402
-
403
- traces = get_all_traces
404
-
405
- traces.count.must_equal 14
406
- valid_edges?(traces).must_equal true
407
- validate_outer_layers(traces, 'rack')
408
-
409
- traces[4]['Layer'].must_equal "activerecord"
410
- traces[4]['Label'].must_equal "entry"
411
- traces[4]['Flavor'].must_equal "mysql"
412
-
413
- traces[4]['Query'].must_equal "INSERT INTO `widgets` (`created_at`, `description`, `name`, `updated_at`) VALUES (?, ?, ?, ?)"
414
-
415
- traces[4]['Name'].must_equal "SQL"
416
- traces[4].key?('Backtrace').must_equal true
417
-
418
- traces[5]['Layer'].must_equal "activerecord"
419
- traces[5]['Label'].must_equal "exit"
420
-
421
- traces[6]['Layer'].must_equal "activerecord"
422
- traces[6]['Label'].must_equal "entry"
423
- traces[6]['Flavor'].must_equal "mysql"
424
- traces[6]['Query'].must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = ? LIMIT ?"
425
- traces[6]['Name'].must_equal "Widget Load"
426
- traces[6].key?('Backtrace').must_equal true
427
- traces[6].key?('QueryArgs').must_equal false
428
-
429
- traces[7]['Layer'].must_equal "activerecord"
430
- traces[7]['Label'].must_equal "exit"
431
-
432
- traces[8]['Layer'].must_equal "activerecord"
433
- traces[8]['Label'].must_equal "entry"
434
- traces[8]['Flavor'].must_equal "mysql"
435
-
436
- # Replace the datestamps with xxx to make testing easier
437
- sql = traces[8]['Query'].gsub(/\d+/, 'xxx')
438
- sql.must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = ?"
439
-
440
- traces[8]['Name'].must_equal "SQL"
441
- traces[8].key?('Backtrace').must_equal true
442
- traces[8].key?('QueryArgs').must_equal false
443
-
444
- traces[9]['Layer'].must_equal "activerecord"
445
- traces[9]['Label'].must_equal "exit"
446
-
447
- # Validate the existence of the response header
448
- r.header.key?('X-Trace').must_equal true
449
- r.header['X-Trace'].must_equal traces[13]['X-Trace']
450
- end
451
-
452
- it "should collect backtraces when true" do
453
-
454
- AppOpticsAPM::Config[:action_controller][:collect_backtraces] = true
455
-
456
- uri = URI.join(ENV['TEST_DB_URI'], '/hello/world')
457
- r = Net::HTTP.get_response(uri)
458
-
459
- traces = get_all_traces
460
-
461
- traces.count.must_equal 8
462
- unless defined?(JRUBY_VERSION)
463
- # We don't test this under JRuby because the Java instrumentation
464
- # for the DB drivers doesn't use our test reporter hence we won't
465
- # see all trace events. :-( To be improved.
466
- valid_edges?(traces).must_equal true
467
- end
468
- validate_outer_layers(traces, 'rack')
469
-
470
- traces[0]['Layer'].must_equal "rack"
471
- traces[0]['Label'].must_equal "entry"
472
- traces[0]['URL'].must_equal "/hello/world"
473
-
474
- traces[1]['Layer'].must_equal "rack"
475
- traces[1]['Label'].must_equal "info"
476
-
477
- traces[2]['Layer'].must_equal "rails"
478
- traces[2]['Label'].must_equal "entry"
479
-
480
- traces[3]['Label'].must_equal "info"
481
- traces[3]['Controller'].must_equal "HelloController"
482
- traces[3]['Action'].must_equal "world"
483
- traces[3].key?('Backtrace').must_equal true
484
-
485
- traces[4]['Layer'].must_equal "actionview"
486
- traces[4]['Label'].must_equal "entry"
487
-
488
- traces[5]['Layer'].must_equal "actionview"
489
- traces[5]['Label'].must_equal "exit"
490
-
491
- traces[6]['Layer'].must_equal "rails"
492
- traces[6]['Label'].must_equal "exit"
493
-
494
- traces[7]['Layer'].must_equal "rack"
495
- traces[7]['Label'].must_equal "exit"
496
-
497
- # Validate the existence of the response header
498
- r.header.key?('X-Trace').must_equal true
499
- r.header['X-Trace'].must_equal traces[7]['X-Trace']
500
- end
501
-
502
- it "should NOT collect backtraces when false" do
503
-
504
- AppOpticsAPM::Config[:action_controller][:collect_backtraces] = false
505
-
506
- uri = URI.parse("#{ENV['TEST_DB_URI']}/hello/world")
507
- r = Net::HTTP.get_response(uri)
508
-
509
- traces = get_all_traces
510
-
511
- traces.count.must_equal 8
512
- unless defined?(JRUBY_VERSION)
513
- # We don't test this under JRuby because the Java instrumentation
514
- # for the DB drivers doesn't use our test reporter hence we won't
515
- # see all trace events. :-( To be improved.
516
- valid_edges?(traces).must_equal true
517
- end
518
- validate_outer_layers(traces, 'rack')
519
-
520
- traces[0]['Layer'].must_equal "rack"
521
- traces[0]['Label'].must_equal "entry"
522
- traces[0]['URL'].must_equal "/hello/world"
523
-
524
- traces[1]['Layer'].must_equal "rack"
525
- traces[1]['Label'].must_equal "info"
526
-
527
- traces[2]['Layer'].must_equal "rails"
528
- traces[2]['Label'].must_equal "entry"
529
-
530
- traces[3]['Label'].must_equal "info"
531
- traces[3]['Controller'].must_equal "HelloController"
532
- traces[3]['Action'].must_equal "world"
533
- traces[3].key?('Backtrace').must_equal false
534
-
535
- traces[4]['Layer'].must_equal "actionview"
536
- traces[4]['Label'].must_equal "entry"
537
-
538
- traces[5]['Layer'].must_equal "actionview"
539
- traces[5]['Label'].must_equal "exit"
540
-
541
- traces[6]['Layer'].must_equal "rails"
542
- traces[6]['Label'].must_equal "exit"
543
-
544
- traces[7]['Layer'].must_equal "rack"
545
- traces[7]['Label'].must_equal "exit"
546
-
547
- # Validate the existence of the response header
548
- r.header.key?('X-Trace').must_equal true
549
- r.header['X-Trace'].must_equal traces[7]['X-Trace']
550
- end
551
-
552
- require_relative "rails_shared_tests"
553
- end
554
- end