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,570 +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 "Rails4x" 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
- end
19
-
20
- after do
21
- AppOpticsAPM.config_lock.synchronize {
22
- AppOpticsAPM::Config[:action_controller][:collect_backtraces] = @collect_backtraces
23
- AppOpticsAPM::Config[:tracing_mode] = @tm
24
- AppOpticsAPM::Config[:sample_rate] = @sample_rate
25
- AppOpticsAPM::Config[:sanitize_sql] = @sanitize_sql
26
- }
27
- end
28
-
29
- it "should trace a request to a rails stack" do
30
-
31
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
32
- r = Net::HTTP.get_response(uri)
33
-
34
- traces = get_all_traces
35
-
36
- traces.count.must_equal 7
37
- unless defined?(JRUBY_VERSION)
38
- # We don't test this under JRuby because the Java instrumentation
39
- # for the DB drivers doesn't use our test reporter hence we won't
40
- # see all trace events. :-( To be improved.
41
- valid_edges?(traces).must_equal true
42
- end
43
- validate_outer_layers(traces, 'rack')
44
-
45
- traces[0]['Layer'].must_equal "rack"
46
- traces[0]['Label'].must_equal "entry"
47
- traces[0]['URL'].must_equal "/hello/world"
48
-
49
- traces[1]['Layer'].must_equal "rack"
50
- traces[1]['Label'].must_equal "info"
51
-
52
- traces[2]['Layer'].must_equal "rails"
53
- traces[2]['Label'].must_equal "entry"
54
- traces[2]['Controller'].must_equal "HelloController"
55
- traces[2]['Action'].must_equal "world"
56
-
57
- traces[3]['Layer'].must_equal "actionview"
58
- traces[3]['Label'].must_equal "entry"
59
-
60
- traces[4]['Layer'].must_equal "actionview"
61
- traces[4]['Label'].must_equal "exit"
62
-
63
- traces[5]['Layer'].must_equal "rails"
64
- traces[5]['Label'].must_equal "exit"
65
-
66
- traces[6]['Layer'].must_equal "rack"
67
- traces[6]['Label'].must_equal "exit"
68
-
69
- # Validate the existence of the response header
70
- r['X-Trace'].must_equal traces[6]['X-Trace']
71
- end
72
-
73
- it "should trace rails postgres db calls" do
74
- # Skip for JRuby since the java instrumentation
75
- # handles DB instrumentation for JRuby
76
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != 'postgresql'
77
-
78
- uri = URI.parse('http://127.0.0.1:8140/hello/db')
79
- r = Net::HTTP.get_response(uri)
80
-
81
- traces = get_all_traces
82
-
83
- traces.count.must_equal 13
84
- valid_edges?(traces).must_equal true
85
- validate_outer_layers(traces, 'rack')
86
-
87
- traces[3]['Layer'].must_equal "activerecord"
88
- traces[3]['Label'].must_equal "entry"
89
- traces[3]['Flavor'].must_equal "postgresql"
90
- traces[3]['Name'].must_equal "SQL"
91
- traces[3].key?('Backtrace').must_equal true
92
-
93
- # Use a regular expression to test the SQL string since field order varies between
94
- # Rails versions
95
- match_data = traces[3]['Query']
96
- match_data.must_equal("INSERT INTO \"widgets\" (\"name\", \"description\", \"created_at\", \"updated_at\") VALUES ($?, $?, $?, $?) RETURNING \"id\"")
97
-
98
- traces[4]['Layer'].must_equal "activerecord"
99
- traces[4]['Label'].must_equal "exit"
100
-
101
- traces[5]['Layer'].must_equal "activerecord"
102
- traces[5]['Label'].must_equal "entry"
103
- traces[5]['Flavor'].must_equal "postgresql"
104
-
105
- # Some versions of rails adds in another space before the ORDER keyword.
106
- # Make 2 or more consecutive spaces just 1
107
- sql = traces[5]['Query'].gsub(/\s{2,}/, ' ')
108
- sql.must_equal "SELECT \"widgets\".* FROM \"widgets\" WHERE \"widgets\".\"name\" = $? ORDER BY \"widgets\".\"id\" ASC LIMIT ?"
109
-
110
- traces[5]['Name'].must_equal "Widget Load"
111
- traces[5].key?('Backtrace').must_equal true
112
- traces[5].key?('QueryArgs').must_equal false
113
-
114
- traces[6]['Layer'].must_equal "activerecord"
115
- traces[6]['Label'].must_equal "exit"
116
-
117
- traces[7]['Layer'].must_equal "activerecord"
118
- traces[7]['Label'].must_equal "entry"
119
- traces[7]['Flavor'].must_equal "postgresql"
120
- traces[7]['Query'].must_equal "DELETE FROM \"widgets\" WHERE \"widgets\".\"id\" = $?"
121
- traces[7]['Name'].must_equal "SQL"
122
- traces[7].key?('Backtrace').must_equal true
123
- traces[7].key?('QueryArgs').must_equal false
124
-
125
- traces[8]['Layer'].must_equal "activerecord"
126
- traces[8]['Label'].must_equal "exit"
127
-
128
- # Validate the existence of the response header
129
- r.header.key?('X-Trace').must_equal true
130
- r.header['X-Trace'].must_equal traces[12]['X-Trace']
131
- end
132
-
133
- it "should trace rails mysql db calls" do
134
- # Skip for JRuby since the java instrumentation
135
- # handles DB instrumentation for JRuby
136
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != "mysql"
137
-
138
- AppOpticsAPM::Config[:sanitize_sql] = false
139
-
140
- uri = URI.parse('http://127.0.0.1:8140/hello/db')
141
- r = Net::HTTP.get_response(uri)
142
-
143
- traces = get_all_traces
144
-
145
- traces.count.must_equal 17
146
- valid_edges?(traces).must_equal true
147
- validate_outer_layers(traces, 'rack')
148
-
149
- traces[3]['Layer'].must_equal "activerecord"
150
- traces[3]['Label'].must_equal "entry"
151
- traces[3]['Flavor'].must_equal "mysql"
152
- traces[3]['Query'].must_equal "BEGIN"
153
- traces[3].key?('Backtrace').must_equal true
154
-
155
- traces[4]['Layer'].must_equal "activerecord"
156
- traces[4]['Label'].must_equal "exit"
157
-
158
- traces[5]['Layer'].must_equal "activerecord"
159
- traces[5]['Label'].must_equal "entry"
160
- traces[5]['Flavor'].must_equal "mysql"
161
- traces[5]['Query'].must_equal "INSERT INTO `widgets` (`name`, `description`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?)"
162
- traces[5]['Name'].must_equal "SQL"
163
- traces[5].key?('Backtrace').must_equal true
164
- traces[5].key?('QueryArgs').must_equal true
165
-
166
- traces[6]['Layer'].must_equal "activerecord"
167
- traces[6]['Label'].must_equal "exit"
168
-
169
- traces[7]['Layer'].must_equal "activerecord"
170
- traces[7]['Label'].must_equal "entry"
171
- traces[7]['Flavor'].must_equal "mysql"
172
- traces[7]['Query'].must_equal "COMMIT"
173
- traces[7].key?('Backtrace').must_equal true
174
-
175
- traces[8]['Layer'].must_equal "activerecord"
176
- traces[8]['Label'].must_equal "exit"
177
-
178
- traces[9]['Layer'].must_equal "activerecord"
179
- traces[9]['Label'].must_equal "entry"
180
- traces[9]['Flavor'].must_equal "mysql"
181
- traces[9]['Name'].must_equal "Widget Load"
182
- traces[9].key?('Backtrace').must_equal true
183
-
184
- # Some versions of rails adds in another space before the ORDER keyword.
185
- # Make 2 or more consecutive spaces just 1
186
- sql = traces[9]['Query'].gsub(/\s{2,}/, ' ')
187
- sql.must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = ? ORDER BY `widgets`.`id` ASC LIMIT 1"
188
-
189
- traces[10]['Layer'].must_equal "activerecord"
190
- traces[10]['Label'].must_equal "exit"
191
-
192
- traces[11]['Layer'].must_equal "activerecord"
193
- traces[11]['Label'].must_equal "entry"
194
- traces[11]['Flavor'].must_equal "mysql"
195
- traces[11]['Name'].must_equal "SQL"
196
- traces[11].key?('Backtrace').must_equal true
197
- traces[11].key?('QueryArgs').must_equal true
198
- traces[11]['Query'].must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = ?"
199
-
200
- traces[12]['Layer'].must_equal "activerecord"
201
- traces[12]['Label'].must_equal "exit"
202
-
203
- traces[13]['Layer'].must_equal "actionview"
204
- traces[13]['Label'].must_equal "entry"
205
-
206
- # Validate the existence of the response header
207
- r['X-Trace'].must_equal traces[16]['X-Trace']
208
- end
209
-
210
- it "should trace rails mysql db calls with sanitize sql" do
211
- # Skip for JRuby since the java instrumentation
212
- # handles DB instrumentation for JRuby
213
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != "mysql"
214
-
215
- AppOpticsAPM::Config[:sanitize_sql] = true
216
-
217
- uri = URI.parse('http://127.0.0.1:8140/hello/db')
218
- r = Net::HTTP.get_response(uri)
219
-
220
- traces = get_all_traces
221
-
222
- traces.count.must_equal 17
223
- valid_edges?(traces).must_equal true
224
- validate_outer_layers(traces, 'rack')
225
-
226
- traces[3]['Layer'].must_equal "activerecord"
227
- traces[3]['Label'].must_equal "entry"
228
- traces[3]['Flavor'].must_equal "mysql"
229
- traces[3]['Query'].must_equal "BEGIN"
230
- traces[3].key?('Backtrace').must_equal true
231
-
232
- traces[4]['Layer'].must_equal "activerecord"
233
- traces[4]['Label'].must_equal "exit"
234
-
235
- traces[5]['Layer'].must_equal "activerecord"
236
- traces[5]['Label'].must_equal "entry"
237
- traces[5]['Flavor'].must_equal "mysql"
238
- traces[5]['Query'].must_equal "INSERT INTO `widgets` (`name`, `description`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?)"
239
- traces[5]['Name'].must_equal "SQL"
240
- traces[5].key?('Backtrace').must_equal true
241
- traces[5].key?('QueryArgs').must_equal false
242
-
243
- traces[6]['Layer'].must_equal "activerecord"
244
- traces[6]['Label'].must_equal "exit"
245
-
246
- traces[7]['Layer'].must_equal "activerecord"
247
- traces[7]['Label'].must_equal "entry"
248
- traces[7]['Flavor'].must_equal "mysql"
249
- traces[7]['Query'].must_equal "COMMIT"
250
- traces[7].key?('Backtrace').must_equal true
251
-
252
- traces[8]['Layer'].must_equal "activerecord"
253
- traces[8]['Label'].must_equal "exit"
254
-
255
- traces[9]['Layer'].must_equal "activerecord"
256
- traces[9]['Label'].must_equal "entry"
257
- traces[9]['Flavor'].must_equal "mysql"
258
- traces[9]['Name'].must_equal "Widget Load"
259
- traces[9].key?('Backtrace').must_equal true
260
-
261
- # Some versions of rails adds in another space before the ORDER keyword.
262
- # Make 2 or more consecutive spaces just 1
263
- sql = traces[9]['Query'].gsub(/\s{2,}/, ' ')
264
- sql.must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = ? ORDER BY `widgets`.`id` ASC LIMIT ?"
265
-
266
- traces[10]['Layer'].must_equal "activerecord"
267
- traces[10]['Label'].must_equal "exit"
268
-
269
- traces[11]['Layer'].must_equal "activerecord"
270
- traces[11]['Label'].must_equal "entry"
271
- traces[11]['Flavor'].must_equal "mysql"
272
- traces[11]['Name'].must_equal "SQL"
273
- traces[11].key?('Backtrace').must_equal true
274
- traces[11].key?('QueryArgs').must_equal false
275
- traces[11]['Query'].must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = ?"
276
-
277
- traces[12]['Layer'].must_equal "activerecord"
278
- traces[12]['Label'].must_equal "exit"
279
-
280
- traces[13]['Layer'].must_equal "actionview"
281
- traces[13]['Label'].must_equal "entry"
282
-
283
- # Validate the existence of the response header
284
- r['X-Trace'].must_equal traces[16]['X-Trace']
285
- end
286
-
287
- it "should trace rails mysql2 db calls" do
288
- # Skip for JRuby since the java instrumentation
289
- # handles DB instrumentation for JRuby
290
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != "mysql2"
291
-
292
- AppOpticsAPM::Config[:sanitize_sql] = false
293
-
294
- uri = URI.parse('http://127.0.0.1:8140/hello/db')
295
- r = Net::HTTP.get_response(uri)
296
-
297
- traces = get_all_traces
298
-
299
- traces.count.must_equal 13
300
- valid_edges?(traces).must_equal true
301
- validate_outer_layers(traces, 'rack')
302
-
303
- traces[3]['Layer'].must_equal "activerecord"
304
- traces[3]['Label'].must_equal "entry"
305
- traces[3]['Flavor'].must_equal "mysql"
306
-
307
- # Replace the datestamps with xxx to make testing easier
308
- traces[3]['Query'].gsub!(/\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d/, 'xxx')
309
- traces[3]['Query'].must_equal "INSERT INTO `widgets` (`name`, `description`, `created_at`, `updated_at`) VALUES ('blah', 'This is an amazing widget.', 'xxx', 'xxx')"
310
-
311
- traces[3]['Name'].must_equal "SQL"
312
- traces[3].key?('Backtrace').must_equal true
313
- traces[3].key?('QueryArgs').must_equal true
314
-
315
- traces[4]['Layer'].must_equal "activerecord"
316
- traces[4]['Label'].must_equal "exit"
317
-
318
- traces[5]['Layer'].must_equal "activerecord"
319
- traces[5]['Label'].must_equal "entry"
320
- traces[5]['Flavor'].must_equal "mysql"
321
- traces[5]['Query'].must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = 'blah' ORDER BY `widgets`.`id` ASC LIMIT 1"
322
- traces[5]['Name'].must_equal "Widget Load"
323
- traces[5].key?('Backtrace').must_equal true
324
- traces[5].key?('QueryArgs').must_equal true
325
-
326
- traces[6]['Layer'].must_equal "activerecord"
327
- traces[6]['Label'].must_equal "exit"
328
-
329
- traces[7]['Layer'].must_equal "activerecord"
330
- traces[7]['Label'].must_equal "entry"
331
- traces[7]['Flavor'].must_equal "mysql"
332
- traces[7]['Name'].must_equal "SQL"
333
- traces[7].key?('Backtrace').must_equal true
334
-
335
- sql = traces[7]['Query'].gsub(/\d+/, 'xxx')
336
- sql.must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = xxx"
337
-
338
- traces[8]['Layer'].must_equal "activerecord"
339
- traces[8]['Label'].must_equal "exit"
340
-
341
- # Validate the existence of the response header
342
- r['X-Trace'].must_equal traces[12]['X-Trace']
343
- end
344
-
345
- it "should trace rails mysql2 db calls with santize sql" do
346
- # Skip for JRuby since the java instrumentation
347
- # handles DB instrumentation for JRuby
348
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != "mysql2"
349
-
350
- AppOpticsAPM::Config[:sanitize_sql] = true
351
-
352
- uri = URI.parse('http://127.0.0.1:8140/hello/db')
353
- r = Net::HTTP.get_response(uri)
354
-
355
- traces = get_all_traces
356
-
357
- traces.count.must_equal 13
358
- valid_edges?(traces).must_equal true
359
- validate_outer_layers(traces, 'rack')
360
-
361
- traces[3]['Layer'].must_equal "activerecord"
362
- traces[3]['Label'].must_equal "entry"
363
- traces[3]['Flavor'].must_equal "mysql"
364
-
365
- # Replace the datestamps with xxx to make testing easier
366
- traces[3]['Query'].must_equal "INSERT INTO `widgets` (`name`, `description`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?)"
367
-
368
- traces[3]['Name'].must_equal "SQL"
369
- traces[3].key?('Backtrace').must_equal true
370
- traces[3].key?('QueryArgs').must_equal false
371
-
372
- traces[4]['Layer'].must_equal "activerecord"
373
- traces[4]['Label'].must_equal "exit"
374
-
375
- traces[5]['Layer'].must_equal "activerecord"
376
- traces[5]['Label'].must_equal "entry"
377
- traces[5]['Flavor'].must_equal "mysql"
378
- traces[5]['Query'].must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = ? ORDER BY `widgets`.`id` ASC LIMIT ?"
379
- traces[5]['Name'].must_equal "Widget Load"
380
- traces[5].key?('Backtrace').must_equal true
381
- traces[5].key?('QueryArgs').must_equal false
382
-
383
- traces[6]['Layer'].must_equal "activerecord"
384
- traces[6]['Label'].must_equal "exit"
385
-
386
- traces[7]['Layer'].must_equal "activerecord"
387
- traces[7]['Label'].must_equal "entry"
388
- traces[7]['Flavor'].must_equal "mysql"
389
- traces[7]['Name'].must_equal "SQL"
390
- traces[7].key?('Backtrace').must_equal true
391
-
392
- traces[7]['Query'].must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = ?"
393
-
394
- traces[8]['Layer'].must_equal "activerecord"
395
- traces[8]['Label'].must_equal "exit"
396
-
397
- # Validate the existence of the response header
398
- r['X-Trace'].must_equal traces[12]['X-Trace']
399
- end
400
-
401
- it "should trace a request to a rails metal stack" do
402
- uri = URI.parse('http://127.0.0.1:8140/hello/metal')
403
- r = Net::HTTP.get_response(uri)
404
-
405
- traces = get_all_traces
406
-
407
- traces.count.must_equal 5
408
- unless defined?(JRUBY_VERSION)
409
- # We don't test this under JRuby because the Java instrumentation
410
- # for the DB drivers doesn't use our test reporter hence we won't
411
- # see all trace events. :-( To be improved.
412
- valid_edges?(traces).must_equal true
413
- end
414
- validate_outer_layers(traces, 'rack')
415
-
416
- traces[0]['Layer'].must_equal "rack"
417
- traces[0]['Label'].must_equal "entry"
418
- traces[0]['URL'].must_equal "/hello/metal"
419
-
420
- traces[1]['Layer'].must_equal "rack"
421
- traces[1]['Label'].must_equal "info"
422
-
423
- traces[2]['Label'].must_equal "profile_entry"
424
- traces[2]['Language'].must_equal "ruby"
425
- traces[2]['ProfileName'].must_equal "world"
426
- traces[2]['MethodName'].must_equal "world"
427
- traces[2]['Class'].must_equal "FerroController"
428
- traces[2]['Controller'].must_equal "FerroController"
429
- traces[2]['Action'].must_equal "world"
430
-
431
- traces[3]['Label'].must_equal "profile_exit"
432
- traces[3]['Language'].must_equal "ruby"
433
- traces[3]['ProfileName'].must_equal "world"
434
-
435
- traces[4]['Layer'].must_equal "rack"
436
- traces[4]['Label'].must_equal "exit"
437
-
438
- # Validate the existence of the response header
439
- r['X-Trace'].must_equal traces[4]['X-Trace']
440
- end
441
-
442
- it "should collect backtraces when true" do
443
- AppOpticsAPM::Config[:action_controller][:collect_backtraces] = true
444
-
445
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
446
- r = Net::HTTP.get_response(uri)
447
-
448
- traces = get_all_traces
449
-
450
- traces.count.must_equal 7
451
- unless defined?(JRUBY_VERSION)
452
- # We don't test this under JRuby because the Java instrumentation
453
- # for the DB drivers doesn't use our test reporter hence we won't
454
- # see all trace events. :-( To be improved.
455
- valid_edges?(traces).must_equal true
456
- end
457
- validate_outer_layers(traces, 'rack')
458
-
459
- traces[0]['Layer'].must_equal "rack"
460
- traces[0]['Label'].must_equal "entry"
461
- traces[0]['URL'].must_equal "/hello/world"
462
-
463
- traces[1]['Layer'].must_equal "rack"
464
- traces[1]['Label'].must_equal "info"
465
-
466
- traces[2]['Layer'].must_equal "rails"
467
- traces[2]['Label'].must_equal "entry"
468
- traces[2]['Controller'].must_equal "HelloController"
469
- traces[2]['Action'].must_equal "world"
470
- traces[2].key?('Backtrace').must_equal true
471
-
472
- traces[3]['Layer'].must_equal "actionview"
473
- traces[3]['Label'].must_equal "entry"
474
-
475
- traces[4]['Layer'].must_equal "actionview"
476
- traces[4]['Label'].must_equal "exit"
477
-
478
- traces[5]['Layer'].must_equal "rails"
479
- traces[5]['Label'].must_equal "exit"
480
-
481
- traces[6]['Layer'].must_equal "rack"
482
- traces[6]['Label'].must_equal "exit"
483
-
484
- # Validate the existence of the response header
485
- r['X-Trace'].must_equal traces[6]['X-Trace']
486
- end
487
-
488
- it "should NOT collect backtraces when false" do
489
- AppOpticsAPM::Config[:action_controller][:collect_backtraces] = false
490
-
491
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
492
- r = Net::HTTP.get_response(uri)
493
-
494
- traces = get_all_traces
495
-
496
- traces.count.must_equal 7
497
- unless defined?(JRUBY_VERSION)
498
- # We don't test this under JRuby because the Java instrumentation
499
- # for the DB drivers doesn't use our test reporter hence we won't
500
- # see all trace events. :-( To be improved.
501
- valid_edges?(traces).must_equal true
502
- end
503
- validate_outer_layers(traces, 'rack')
504
-
505
- traces[0]['Layer'].must_equal "rack"
506
- traces[0]['Label'].must_equal "entry"
507
- traces[0]['URL'].must_equal "/hello/world"
508
-
509
- traces[1]['Layer'].must_equal "rack"
510
- traces[1]['Label'].must_equal "info"
511
-
512
- traces[2]['Layer'].must_equal "rails"
513
- traces[2]['Label'].must_equal "entry"
514
- traces[2]['Controller'].must_equal "HelloController"
515
- traces[2]['Action'].must_equal "world"
516
- traces[2].key?('Backtrace').must_equal false
517
-
518
- traces[3]['Layer'].must_equal "actionview"
519
- traces[3]['Label'].must_equal "entry"
520
-
521
- traces[4]['Layer'].must_equal "actionview"
522
- traces[4]['Label'].must_equal "exit"
523
-
524
- traces[5]['Layer'].must_equal "rails"
525
- traces[5]['Label'].must_equal "exit"
526
-
527
- traces[6]['Layer'].must_equal "rack"
528
- traces[6]['Label'].must_equal "exit"
529
-
530
- # Validate the existence of the response header
531
- r['X-Trace'].must_equal traces[6]['X-Trace']
532
- end
533
-
534
- it "should NOT trace when tracing is set to :never" do
535
- AppOpticsAPM.config_lock.synchronize do
536
- AppOpticsAPM::Config[:tracing_mode] = :never
537
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
538
- r = Net::HTTP.get_response(uri)
539
-
540
- traces = get_all_traces
541
- traces.count.must_equal 0
542
- end
543
- end
544
-
545
- it "should NOT trace when sample_rate is 0" do
546
- AppOpticsAPM.config_lock.synchronize do
547
- AppOpticsAPM::Config[:sample_rate] = 0
548
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
549
- r = Net::HTTP.get_response(uri)
550
-
551
- traces = get_all_traces
552
- traces.count.must_equal 0
553
- end
554
- end
555
-
556
- it "should NOT trace when there is no context" do
557
- response_headers = HelloController.action("world").call(
558
- "REQUEST_METHOD" => "GET",
559
- "rack.input" => -> {}
560
- )[1]
561
-
562
- response_headers['X-Trace'].must_be_nil
563
-
564
- traces = get_all_traces
565
- traces.count.must_equal 0
566
- end
567
-
568
- require_relative "rails_shared_tests"
569
- end
570
- end