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,210 +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 "Rails5xAPI" 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_api][:collect_backtraces]
14
- @sample_rate = AppOpticsAPM::Config[:sample_rate]
15
- }
16
- ENV['DBTYPE'] = "postgresql" unless ENV['DBTYPE']
17
- end
18
-
19
- after do
20
- AppOpticsAPM.config_lock.synchronize {
21
- AppOpticsAPM::Config[:action_controller_api][:collect_backtraces] = @collect_backtraces
22
- AppOpticsAPM::Config[:tracing_mode] = @tm
23
- AppOpticsAPM::Config[:sample_rate] = @sample_rate
24
- }
25
- end
26
-
27
- it "should trace a request to a rails api stack" do
28
- uri = URI.parse('http://127.0.0.1:8150/monkey/hello')
29
- r = Net::HTTP.get_response(uri)
30
-
31
- traces = get_all_traces
32
-
33
- traces.count.must_equal 7
34
- unless defined?(JRUBY_VERSION)
35
- # We don't test this under JRuby because the Java instrumentation
36
- # for the DB drivers doesn't use our test reporter hence we won't
37
- # see all trace events. :-( To be improved.
38
- valid_edges?(traces).must_equal true
39
- end
40
- validate_outer_layers(traces, 'rack')
41
-
42
- traces[0]['Layer'].must_equal "rack"
43
- traces[0]['Label'].must_equal "entry"
44
- traces[0]['URL'].must_equal "/monkey/hello"
45
-
46
- traces[1]['Layer'].must_equal "rack"
47
- traces[1]['Label'].must_equal "info"
48
-
49
- traces[2]['Layer'].must_equal "rails-api"
50
- traces[2]['Label'].must_equal "entry"
51
- traces[2]['Controller'].must_equal "MonkeyController"
52
- traces[2]['Action'].must_equal "hello"
53
-
54
- traces[3]['Layer'].must_equal "actionview"
55
- traces[3]['Label'].must_equal "entry"
56
-
57
- traces[4]['Layer'].must_equal "actionview"
58
- traces[4]['Label'].must_equal "exit"
59
-
60
- traces[5]['Layer'].must_equal "rails-api"
61
- traces[5]['Label'].must_equal "exit"
62
-
63
- traces[6]['Layer'].must_equal "rack"
64
- traces[6]['Label'].must_equal "exit"
65
-
66
- # Validate the existence of the response header
67
- r.header.key?('X-Trace').must_equal true
68
- r.header['X-Trace'].must_equal traces[6]['X-Trace']
69
- end
70
-
71
- it "should capture errors" do
72
- uri = URI.parse('http://127.0.0.1:8150/monkey/error')
73
- r = Net::HTTP.get_response(uri)
74
-
75
- traces = get_all_traces
76
-
77
- traces.count.must_equal 6
78
- unless defined?(JRUBY_VERSION)
79
- # We don't test this under JRuby because the Java instrumentation
80
- # for the DB drivers doesn't use our test reporter hence we won't
81
- # see all trace events. :-( To be improved.
82
- valid_edges?(traces).must_equal true
83
- end
84
- validate_outer_layers(traces, 'rack')
85
-
86
- traces[0]['Layer'].must_equal "rack"
87
- traces[0]['Label'].must_equal "entry"
88
- traces[0]['URL'].must_equal "/monkey/error"
89
-
90
- traces[1]['Layer'].must_equal "rack"
91
- traces[1]['Label'].must_equal "info"
92
-
93
- traces[2]['Layer'].must_equal "rails-api"
94
- traces[2]['Label'].must_equal "entry"
95
- traces[2]['Controller'].must_equal "MonkeyController"
96
- traces[2]['Action'].must_equal "error"
97
-
98
- traces[3]['Label'].must_equal "error"
99
- traces[3]['ErrorClass'].must_equal "RuntimeError"
100
- traces[3]['ErrorMsg'].must_equal "Rails API fake error from controller"
101
- traces[3].key?('Backtrace').must_equal true
102
-
103
- traces[4]['Layer'].must_equal "rails-api"
104
- traces[4]['Label'].must_equal "exit"
105
-
106
- traces[5]['Layer'].must_equal "rack"
107
- traces[5]['Label'].must_equal "exit"
108
-
109
- # Validate the existence of the response header
110
- r.header.key?('X-Trace').must_equal true
111
- r.header['X-Trace'].must_equal traces[5]['X-Trace']
112
- end
113
-
114
- it "should collect backtraces when true" do
115
- AppOpticsAPM::Config[:action_controller_api][:collect_backtraces] = true
116
-
117
- uri = URI.parse('http://127.0.0.1:8150/monkey/hello')
118
- r = Net::HTTP.get_response(uri)
119
-
120
- traces = get_all_traces
121
-
122
- traces.count.must_equal 7
123
- unless defined?(JRUBY_VERSION)
124
- # We don't test this under JRuby because the Java instrumentation
125
- # for the DB drivers doesn't use our test reporter hence we won't
126
- # see all trace events. :-( To be improved.
127
- valid_edges?(traces).must_equal true
128
- end
129
- validate_outer_layers(traces, 'rack')
130
-
131
- traces[0]['Layer'].must_equal "rack"
132
- traces[0]['Label'].must_equal "entry"
133
- traces[0]['URL'].must_equal "/monkey/hello"
134
-
135
- traces[1]['Layer'].must_equal "rack"
136
- traces[1]['Label'].must_equal "info"
137
-
138
- traces[2]['Layer'].must_equal "rails-api"
139
- traces[2]['Label'].must_equal "entry"
140
- traces[2]['Controller'].must_equal "MonkeyController"
141
- traces[2]['Action'].must_equal "hello"
142
- traces[2].key?('Backtrace').must_equal true
143
-
144
- traces[3]['Layer'].must_equal "actionview"
145
- traces[3]['Label'].must_equal "entry"
146
-
147
- traces[4]['Layer'].must_equal "actionview"
148
- traces[4]['Label'].must_equal "exit"
149
-
150
- traces[5]['Layer'].must_equal "rails-api"
151
- traces[5]['Label'].must_equal "exit"
152
-
153
- traces[6]['Layer'].must_equal "rack"
154
- traces[6]['Label'].must_equal "exit"
155
-
156
- # Validate the existence of the response header
157
- r.header.key?('X-Trace').must_equal true
158
- r.header['X-Trace'].must_equal traces[6]['X-Trace']
159
- end
160
-
161
- it "should NOT collect backtraces when false" do
162
- AppOpticsAPM::Config[:action_controller_api][:collect_backtraces] = false
163
-
164
- uri = URI.parse('http://127.0.0.1:8150/monkey/hello')
165
- r = Net::HTTP.get_response(uri)
166
-
167
- traces = get_all_traces
168
-
169
- traces.count.must_equal 7
170
- unless defined?(JRUBY_VERSION)
171
- # We don't test this under JRuby because the Java instrumentation
172
- # for the DB drivers doesn't use our test reporter hence we won't
173
- # see all trace events. :-( To be improved.
174
- valid_edges?(traces).must_equal true
175
- end
176
- validate_outer_layers(traces, 'rack')
177
-
178
- traces[0]['Layer'].must_equal "rack"
179
- traces[0]['Label'].must_equal "entry"
180
- traces[0]['URL'].must_equal "/monkey/hello"
181
-
182
- traces[1]['Layer'].must_equal "rack"
183
- traces[1]['Label'].must_equal "info"
184
-
185
- traces[2]['Layer'].must_equal "rails-api"
186
- traces[2]['Label'].must_equal "entry"
187
- traces[2]['Controller'].must_equal "MonkeyController"
188
- traces[2]['Action'].must_equal "hello"
189
- traces[2].key?('Backtrace').must_equal false
190
-
191
- traces[3]['Layer'].must_equal "actionview"
192
- traces[3]['Label'].must_equal "entry"
193
-
194
- traces[4]['Layer'].must_equal "actionview"
195
- traces[4]['Label'].must_equal "exit"
196
-
197
- traces[5]['Layer'].must_equal "rails-api"
198
- traces[5]['Label'].must_equal "exit"
199
-
200
- traces[6]['Layer'].must_equal "rack"
201
- traces[6]['Label'].must_equal "exit"
202
-
203
- # Validate the existence of the response header
204
- r.header.key?('X-Trace').must_equal true
205
- r.header['X-Trace'].must_equal traces[6]['X-Trace']
206
- end
207
-
208
- require_relative "rails_shared_tests"
209
- end
210
- end
@@ -1,376 +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 "Rails5x" 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
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
31
- r = Net::HTTP.get_response(uri)
32
-
33
- traces = get_all_traces
34
-
35
- traces.count.must_equal 7
36
- unless defined?(JRUBY_VERSION)
37
- # We don't test this under JRuby because the Java instrumentation
38
- # for the DB drivers doesn't use our test reporter hence we won't
39
- # see all trace events. :-( To be improved.
40
- valid_edges?(traces).must_equal true
41
- end
42
- validate_outer_layers(traces, 'rack')
43
-
44
- traces[0]['Layer'].must_equal "rack"
45
- traces[0]['Label'].must_equal "entry"
46
- traces[0]['URL'].must_equal "/hello/world"
47
-
48
- traces[1]['Layer'].must_equal "rack"
49
- traces[1]['Label'].must_equal "info"
50
-
51
- traces[2]['Layer'].must_equal "rails"
52
- traces[2]['Label'].must_equal "entry"
53
- traces[2]['Controller'].must_equal "HelloController"
54
- traces[2]['Action'].must_equal "world"
55
-
56
- traces[3]['Layer'].must_equal "actionview"
57
- traces[3]['Label'].must_equal "entry"
58
-
59
- traces[4]['Layer'].must_equal "actionview"
60
- traces[4]['Label'].must_equal "exit"
61
-
62
- traces[5]['Layer'].must_equal "rails"
63
- traces[5]['Label'].must_equal "exit"
64
-
65
- traces[6]['Layer'].must_equal "rack"
66
- traces[6]['Label'].must_equal "exit"
67
-
68
- # Validate the existence of the response header
69
- r.header.key?('X-Trace').must_equal true
70
- r.header['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]['Query'].must_equal "INSERT INTO \"widgets\" (\"name\", \"description\", \"created_at\", \"updated_at\") VALUES ($?, $?, $?, $?) RETURNING \"id\""
91
- traces[3]['Name'].must_equal "SQL"
92
- traces[3].key?('Backtrace').must_equal true
93
-
94
- traces[4]['Layer'].must_equal "activerecord"
95
- traces[4]['Label'].must_equal "exit"
96
-
97
- traces[5]['Layer'].must_equal "activerecord"
98
- traces[5]['Label'].must_equal "entry"
99
- traces[5]['Flavor'].must_equal "postgresql"
100
- traces[5]['Query'].must_equal "SELECT \"widgets\".* FROM \"widgets\" WHERE \"widgets\".\"name\" = $? ORDER BY \"widgets\".\"id\" ASC LIMIT $?"
101
- traces[5]['Name'].must_equal "Widget Load"
102
- traces[5].key?('Backtrace').must_equal true
103
- traces[5].key?('QueryArgs').must_equal false
104
-
105
- traces[6]['Layer'].must_equal "activerecord"
106
- traces[6]['Label'].must_equal "exit"
107
-
108
- traces[7]['Layer'].must_equal "activerecord"
109
- traces[7]['Label'].must_equal "entry"
110
- traces[7]['Flavor'].must_equal "postgresql"
111
- traces[7]['Query'].must_equal "DELETE FROM \"widgets\" WHERE \"widgets\".\"id\" = $?"
112
- traces[7]['Name'].must_equal "SQL"
113
- traces[7].key?('Backtrace').must_equal true
114
- traces[7].key?('QueryArgs').must_equal false
115
-
116
- traces[8]['Layer'].must_equal "activerecord"
117
- traces[8]['Label'].must_equal "exit"
118
-
119
- # Validate the existence of the response header
120
- r.header.key?('X-Trace').must_equal true
121
- r.header['X-Trace'].must_equal traces[12]['X-Trace']
122
- end
123
-
124
- it "should trace rails mysql2 db calls" do
125
- # Skip for JRuby since the java instrumentation
126
- # handles DB instrumentation for JRuby
127
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != 'mysql2'
128
-
129
- AppOpticsAPM::Config[:sanitize_sql] = false
130
-
131
- uri = URI.parse('http://127.0.0.1:8140/hello/db')
132
- r = Net::HTTP.get_response(uri)
133
-
134
- traces = get_all_traces
135
-
136
- traces.count.must_equal 15
137
- valid_edges?(traces).must_equal true
138
- validate_outer_layers(traces, 'rack')
139
-
140
- entry_traces = traces.select { |tr| tr['Label'] == 'entry' }
141
- entry_traces.count.must_equal 7
142
-
143
- exit_traces = traces.select { |tr| tr['Label'] == 'exit' }
144
- exit_traces.count.must_equal 7
145
-
146
- entry_traces[2]['Layer'].must_equal "activerecord"
147
- entry_traces[2]['Flavor'].must_equal "mysql"
148
- entry_traces[2]['Query'].gsub!(/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/, 'the_date')
149
- entry_traces[2]['Query'].must_equal "INSERT INTO `widgets` (`name`, `description`, `created_at`, `updated_at`) VALUES ('blah', 'This is an amazing widget.', 'the_date', 'the_date')"
150
- entry_traces[2]['Name'].must_equal "SQL"
151
- entry_traces[2].key?('Backtrace').must_equal true
152
- entry_traces[2].key?('QueryArgs').must_equal true
153
-
154
- entry_traces[3]['Layer'].must_equal "activerecord"
155
- entry_traces[3]['Flavor'].must_equal "mysql"
156
- entry_traces[3]['Query'].gsub!(/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/, 'the_date')
157
- entry_traces[3]['Query'].must_equal "INSERT INTO `widgets` (`name`, `description`, `created_at`, `updated_at`) VALUES ('blah', 'This is an amazing widget.', 'the_date', 'the_date')"
158
- entry_traces[3]['Name'].must_equal "SQL"
159
- entry_traces[3].key?('Backtrace').must_equal true
160
- entry_traces[3].key?('QueryArgs').must_equal true
161
-
162
- entry_traces[4]['Layer'].must_equal "activerecord"
163
- entry_traces[4]['Flavor'].must_equal "mysql"
164
- entry_traces[4]['Query'].must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = 'blah' ORDER BY `widgets`.`id` ASC LIMIT 1"
165
- entry_traces[4]['Name'].must_equal "Widget Load"
166
- entry_traces[4].key?('Backtrace').must_equal true
167
- entry_traces[4].key?('QueryArgs').must_equal true
168
-
169
- entry_traces[5]['Layer'].must_equal "activerecord"
170
- entry_traces[5]['Flavor'].must_equal "mysql"
171
- entry_traces[5]['Query'].gsub!(/\d+/, 'ID')
172
- entry_traces[5]['Query'].must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = ID"
173
- entry_traces[5]['Name'].must_equal "SQL"
174
- entry_traces[5].key?('Backtrace').must_equal true
175
- entry_traces[5].key?('QueryArgs').must_equal true
176
-
177
- # Validate the existence of the response header
178
- r.header.key?('X-Trace').must_equal true
179
- r.header['X-Trace'].must_equal traces[14]['X-Trace']
180
- end
181
-
182
- it "should trace rails mysql2 db calls with sanitize sql" do
183
- # Skip for JRuby since the java instrumentation
184
- # handles DB instrumentation for JRuby
185
- skip if defined?(JRUBY_VERSION) || ENV['DBTYPE'] != 'mysql2'
186
-
187
- AppOpticsAPM::Config[:sanitize_sql] = true
188
-
189
- uri = URI.parse('http://127.0.0.1:8140/hello/db')
190
- r = Net::HTTP.get_response(uri)
191
-
192
- traces = get_all_traces
193
-
194
- traces.count.must_equal 15
195
- valid_edges?(traces).must_equal true
196
- validate_outer_layers(traces, 'rack')
197
-
198
- entry_traces = traces.select { |tr| tr['Label'] == 'entry' }
199
- entry_traces.count.must_equal 7
200
-
201
- exit_traces = traces.select { |tr| tr['Label'] == 'exit' }
202
- exit_traces.count.must_equal 7
203
-
204
- entry_traces[2]['Layer'].must_equal "activerecord"
205
- entry_traces[2]['Flavor'].must_equal "mysql"
206
- entry_traces[2]['Query'].must_equal "INSERT INTO `widgets` (`name`, `description`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?)"
207
- entry_traces[2]['Name'].must_equal "SQL"
208
- entry_traces[2].key?('Backtrace').must_equal true
209
- entry_traces[2].key?('QueryArgs').must_equal false
210
-
211
- entry_traces[3]['Layer'].must_equal "activerecord"
212
- entry_traces[3]['Flavor'].must_equal "mysql"
213
- entry_traces[3]['Query'].must_equal "INSERT INTO `widgets` (`name`, `description`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?)"
214
- entry_traces[3]['Name'].must_equal "SQL"
215
- entry_traces[3].key?('Backtrace').must_equal true
216
- entry_traces[3].key?('QueryArgs').must_equal false
217
-
218
- entry_traces[4]['Layer'].must_equal "activerecord"
219
- entry_traces[4]['Flavor'].must_equal "mysql"
220
- entry_traces[4]['Query'].must_equal "SELECT `widgets`.* FROM `widgets` WHERE `widgets`.`name` = ? ORDER BY `widgets`.`id` ASC LIMIT ?"
221
- entry_traces[4]['Name'].must_equal "Widget Load"
222
- entry_traces[4].key?('Backtrace').must_equal true
223
- entry_traces[4].key?('QueryArgs').must_equal false
224
-
225
- entry_traces[5]['Layer'].must_equal "activerecord"
226
- entry_traces[5]['Flavor'].must_equal "mysql"
227
- entry_traces[5]['Query'].must_equal "DELETE FROM `widgets` WHERE `widgets`.`id` = ?"
228
- entry_traces[5]['Name'].must_equal "SQL"
229
- entry_traces[5].key?('Backtrace').must_equal true
230
- entry_traces[5].key?('QueryArgs').must_equal false
231
-
232
- # Validate the existence of the response header
233
- r.header.key?('X-Trace').must_equal true
234
- r.header['X-Trace'].must_equal traces[14]['X-Trace']
235
- end
236
-
237
- it "should trace a request to a rails metal stack" do
238
-
239
- uri = URI.parse('http://127.0.0.1:8140/hello/metal')
240
- r = Net::HTTP.get_response(uri)
241
-
242
- traces = get_all_traces
243
-
244
- traces.count.must_equal 5
245
- unless defined?(JRUBY_VERSION)
246
- # We don't test this under JRuby because the Java instrumentation
247
- # for the DB drivers doesn't use our test reporter hence we won't
248
- # see all trace events. :-( To be improved.
249
- valid_edges?(traces).must_equal true
250
- end
251
- validate_outer_layers(traces, 'rack')
252
-
253
- traces[0]['Layer'].must_equal "rack"
254
- traces[0]['Label'].must_equal "entry"
255
- traces[0]['URL'].must_equal "/hello/metal"
256
-
257
- traces[1]['Layer'].must_equal "rack"
258
- traces[1]['Label'].must_equal "info"
259
-
260
- traces[2]['Label'].must_equal "profile_entry"
261
- traces[2]['Language'].must_equal "ruby"
262
- traces[2]['ProfileName'].must_equal "world"
263
- traces[2]['MethodName'].must_equal "world"
264
- traces[2]['Class'].must_equal "FerroController"
265
- traces[2]['Controller'].must_equal "FerroController"
266
- traces[2]['Action'].must_equal "world"
267
-
268
- traces[3]['Label'].must_equal "profile_exit"
269
- traces[3]['Language'].must_equal "ruby"
270
- traces[3]['ProfileName'].must_equal "world"
271
-
272
- traces[4]['Layer'].must_equal "rack"
273
- traces[4]['Label'].must_equal "exit"
274
-
275
- # Validate the existence of the response header
276
- r.header.key?('X-Trace').must_equal true
277
- r.header['X-Trace'].must_equal traces[4]['X-Trace']
278
- end
279
-
280
- it "should collect backtraces when true" do
281
- AppOpticsAPM::Config[:action_controller][:collect_backtraces] = true
282
-
283
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
284
- r = Net::HTTP.get_response(uri)
285
-
286
- traces = get_all_traces
287
-
288
- traces.count.must_equal 7
289
- unless defined?(JRUBY_VERSION)
290
- # We don't test this under JRuby because the Java instrumentation
291
- # for the DB drivers doesn't use our test reporter hence we won't
292
- # see all trace events. :-( To be improved.
293
- valid_edges?(traces).must_equal true
294
- end
295
- validate_outer_layers(traces, 'rack')
296
-
297
- traces[0]['Layer'].must_equal "rack"
298
- traces[0]['Label'].must_equal "entry"
299
- traces[0]['URL'].must_equal "/hello/world"
300
-
301
- traces[1]['Layer'].must_equal "rack"
302
- traces[1]['Label'].must_equal "info"
303
-
304
- traces[2]['Layer'].must_equal "rails"
305
- traces[2]['Label'].must_equal "entry"
306
- traces[2]['Controller'].must_equal "HelloController"
307
- traces[2]['Action'].must_equal "world"
308
- traces[2].key?('Backtrace').must_equal true
309
-
310
- traces[3]['Layer'].must_equal "actionview"
311
- traces[3]['Label'].must_equal "entry"
312
-
313
- traces[4]['Layer'].must_equal "actionview"
314
- traces[4]['Label'].must_equal "exit"
315
-
316
- traces[5]['Layer'].must_equal "rails"
317
- traces[5]['Label'].must_equal "exit"
318
-
319
- traces[6]['Layer'].must_equal "rack"
320
- traces[6]['Label'].must_equal "exit"
321
-
322
- # Validate the existence of the response header
323
- r.header.key?('X-Trace').must_equal true
324
- r.header['X-Trace'].must_equal traces[6]['X-Trace']
325
- end
326
-
327
- it "should NOT collect backtraces when false" do
328
- AppOpticsAPM::Config[:action_controller][:collect_backtraces] = false
329
-
330
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
331
- r = Net::HTTP.get_response(uri)
332
-
333
- traces = get_all_traces
334
-
335
- traces.count.must_equal 7
336
- unless defined?(JRUBY_VERSION)
337
- # We don't test this under JRuby because the Java instrumentation
338
- # for the DB drivers doesn't use our test reporter hence we won't
339
- # see all trace events. :-( To be improved.
340
- valid_edges?(traces).must_equal true
341
- end
342
- validate_outer_layers(traces, 'rack')
343
-
344
- traces[0]['Layer'].must_equal "rack"
345
- traces[0]['Label'].must_equal "entry"
346
- traces[0]['URL'].must_equal "/hello/world"
347
-
348
- traces[1]['Layer'].must_equal "rack"
349
- traces[1]['Label'].must_equal "info"
350
-
351
- traces[2]['Layer'].must_equal "rails"
352
- traces[2]['Label'].must_equal "entry"
353
- traces[2]['Controller'].must_equal "HelloController"
354
- traces[2]['Action'].must_equal "world"
355
- traces[2].key?('Backtrace').must_equal false
356
-
357
- traces[3]['Layer'].must_equal "actionview"
358
- traces[3]['Label'].must_equal "entry"
359
-
360
- traces[4]['Layer'].must_equal "actionview"
361
- traces[4]['Label'].must_equal "exit"
362
-
363
- traces[5]['Layer'].must_equal "rails"
364
- traces[5]['Label'].must_equal "exit"
365
-
366
- traces[6]['Layer'].must_equal "rack"
367
- traces[6]['Label'].must_equal "exit"
368
-
369
- # Validate the existence of the response header
370
- r.header.key?('X-Trace').must_equal true
371
- r.header['X-Trace'].must_equal traces[6]['X-Trace']
372
- end
373
-
374
- require_relative "rails_shared_tests"
375
- end
376
- end