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.
- checksums.yaml +4 -4
- data/Dockerfile_test +6 -7
- data/README.md +3 -3
- data/Rakefile +3 -2
- data/appoptics_apm.gemspec +2 -2
- data/docker-compose.yml +0 -22
- data/ext/oboe_metal/extconf.rb +4 -0
- data/lib/appoptics_apm/config.rb +11 -6
- data/lib/appoptics_apm/version.rb +1 -1
- metadata +3 -202
- data/gemfiles/delayed_job.gemfile +0 -36
- data/gemfiles/frameworks.gemfile +0 -44
- data/gemfiles/instrumentation_mocked.gemfile +0 -29
- data/gemfiles/libraries.gemfile +0 -85
- data/gemfiles/noop.gemfile +0 -17
- data/gemfiles/rails23.gemfile +0 -39
- data/gemfiles/rails30.gemfile +0 -42
- data/gemfiles/rails31.gemfile +0 -44
- data/gemfiles/rails32.gemfile +0 -54
- data/gemfiles/rails40.gemfile +0 -27
- data/gemfiles/rails41.gemfile +0 -27
- data/gemfiles/rails42.gemfile +0 -35
- data/gemfiles/rails50.gemfile +0 -44
- data/gemfiles/rails51.gemfile +0 -44
- data/test/benchmark/README.md +0 -65
- data/test/benchmark/logging_bench.rb +0 -54
- data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +0 -69
- data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +0 -43
- data/test/frameworks/apps/grape_nested.rb +0 -33
- data/test/frameworks/apps/grape_simple.rb +0 -80
- data/test/frameworks/apps/padrino_simple.rb +0 -80
- data/test/frameworks/apps/sinatra_simple.rb +0 -55
- data/test/frameworks/grape_test.rb +0 -286
- data/test/frameworks/padrino_test.rb +0 -222
- data/test/frameworks/rails3x_test.rb +0 -554
- data/test/frameworks/rails4x_test.rb +0 -570
- data/test/frameworks/rails5x_api_test.rb +0 -210
- data/test/frameworks/rails5x_test.rb +0 -376
- data/test/frameworks/rails_shared_tests.rb +0 -172
- data/test/frameworks/sinatra_test.rb +0 -140
- data/test/instrumentation/bunny_client_test.rb +0 -276
- data/test/instrumentation/bunny_consumer_test.rb +0 -204
- data/test/instrumentation/curb_test.rb +0 -398
- data/test/instrumentation/dalli_test.rb +0 -177
- data/test/instrumentation/em_http_request_test.rb +0 -89
- data/test/instrumentation/excon_test.rb +0 -231
- data/test/instrumentation/faraday_test.rb +0 -228
- data/test/instrumentation/http_test.rb +0 -143
- data/test/instrumentation/httpclient_test.rb +0 -304
- data/test/instrumentation/memcache_test.rb +0 -260
- data/test/instrumentation/memcached_test.rb +0 -229
- data/test/instrumentation/mongo_v1_test.rb +0 -479
- data/test/instrumentation/mongo_v2_index_test.rb +0 -124
- data/test/instrumentation/mongo_v2_test.rb +0 -584
- data/test/instrumentation/mongo_v2_view_test.rb +0 -435
- data/test/instrumentation/moped_test.rb +0 -517
- data/test/instrumentation/rack_test.rb +0 -165
- data/test/instrumentation/redis_hashes_test.rb +0 -268
- data/test/instrumentation/redis_keys_test.rb +0 -321
- data/test/instrumentation/redis_lists_test.rb +0 -310
- data/test/instrumentation/redis_misc_test.rb +0 -163
- data/test/instrumentation/redis_sets_test.rb +0 -296
- data/test/instrumentation/redis_sortedsets_test.rb +0 -328
- data/test/instrumentation/redis_strings_test.rb +0 -349
- data/test/instrumentation/resque_test.rb +0 -185
- data/test/instrumentation/rest-client_test.rb +0 -288
- data/test/instrumentation/sequel_mysql2_test.rb +0 -353
- data/test/instrumentation/sequel_mysql_test.rb +0 -334
- data/test/instrumentation/sequel_pg_test.rb +0 -336
- data/test/instrumentation/sidekiq-client_test.rb +0 -159
- data/test/instrumentation/sidekiq-worker_test.rb +0 -180
- data/test/instrumentation/twitter-cassandra_test.rb +0 -424
- data/test/instrumentation/typhoeus_test.rb +0 -284
- data/test/jobs/delayed_job/db_worker_job.rb +0 -29
- data/test/jobs/delayed_job/error_worker_job.rb +0 -10
- data/test/jobs/delayed_job/remote_call_worker_job.rb +0 -20
- data/test/jobs/resque/db_worker_job.rb +0 -29
- data/test/jobs/resque/error_worker_job.rb +0 -10
- data/test/jobs/resque/remote_call_worker_job.rb +0 -20
- data/test/jobs/sidekiq/db_worker_job.rb +0 -29
- data/test/jobs/sidekiq/error_worker_job.rb +0 -10
- data/test/jobs/sidekiq/remote_call_worker_job.rb +0 -20
- data/test/minitest_helper.rb +0 -277
- data/test/mocked/curb_mocked_test.rb +0 -324
- data/test/mocked/excon_mocked_test.rb +0 -174
- data/test/mocked/faraday_mocked_test.rb +0 -97
- data/test/mocked/http_mocked_test.rb +0 -135
- data/test/mocked/httpclient_mocked_test.rb +0 -258
- data/test/mocked/rest_client_mocked_test.rb +0 -109
- data/test/mocked/typhoeus_mocked_test.rb +0 -207
- data/test/models/widget.rb +0 -36
- data/test/noop/noop_test.rb +0 -145
- data/test/profiling/legacy_method_profiling_test.rb +0 -201
- data/test/profiling/method_profiling_test.rb +0 -631
- data/test/queues/delayed_job-client_test.rb +0 -95
- data/test/queues/delayed_job-worker_test.rb +0 -91
- data/test/reporter/reporter_test.rb +0 -14
- data/test/servers/delayed_job.rb +0 -107
- data/test/servers/rackapp_8101.rb +0 -29
- data/test/servers/rails3x_8140.rb +0 -96
- data/test/servers/rails4x_8140.rb +0 -96
- data/test/servers/rails5x_8140.rb +0 -95
- data/test/servers/rails5x_api_8150.rb +0 -78
- data/test/servers/sidekiq.rb +0 -29
- data/test/servers/sidekiq.yml +0 -7
- data/test/servers/sidekiq_initializer.rb +0 -25
- data/test/settings +0 -0
- data/test/support/auto_tracing_test.rb +0 -50
- data/test/support/backcompat_test.rb +0 -276
- data/test/support/config_test.rb +0 -149
- data/test/support/dnt_test.rb +0 -98
- data/test/support/init_report_test.rb +0 -25
- data/test/support/liboboe_settings_test.rb +0 -110
- data/test/support/logging_test.rb +0 -130
- data/test/support/sql_sanitize_test.rb +0 -55
- data/test/support/tracing_mode_test.rb +0 -33
- data/test/support/tvalias_test.rb +0 -15
- data/test/support/xtrace_test.rb +0 -41
@@ -1,228 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'minitest_helper'
|
5
|
-
|
6
|
-
describe "Faraday" do
|
7
|
-
before do
|
8
|
-
clear_all_traces
|
9
|
-
@collect_backtraces = AppOpticsAPM::Config[:faraday][:collect_backtraces]
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
AppOpticsAPM::Config[:faraday][:collect_backtraces] = @collect_backtraces
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'Faraday should be defined and ready' do
|
17
|
-
defined?(::Faraday).wont_match nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'Faraday should have appoptics_apm methods defined' do
|
21
|
-
[ :run_request_with_appoptics ].each do |m|
|
22
|
-
::Faraday::Connection.method_defined?(m).must_equal true
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should trace cross-app request" do
|
27
|
-
AppOpticsAPM::API.start_trace('faraday_test') do
|
28
|
-
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
29
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
30
|
-
end
|
31
|
-
response = conn.get '/games?q=1'
|
32
|
-
response.headers["x-trace"].wont_match nil
|
33
|
-
end
|
34
|
-
|
35
|
-
traces = get_all_traces
|
36
|
-
traces.count.must_equal 11
|
37
|
-
|
38
|
-
validate_outer_layers(traces, 'faraday_test')
|
39
|
-
|
40
|
-
traces[1]['Layer'].must_equal 'faraday'
|
41
|
-
traces[1].key?('Backtrace').must_equal AppOpticsAPM::Config[:faraday][:collect_backtraces]
|
42
|
-
|
43
|
-
traces[6]['Layer'].must_equal 'net-http'
|
44
|
-
traces[6]['IsService'].must_equal 1
|
45
|
-
traces[6]['RemoteProtocol'].must_equal 'HTTP'
|
46
|
-
traces[6]['RemoteHost'].must_equal '127.0.0.1:8101'
|
47
|
-
traces[6]['ServiceArg'].must_equal '/games?q=1'
|
48
|
-
traces[6]['HTTPMethod'].must_equal 'GET'
|
49
|
-
traces[6]['HTTPStatus'].must_equal '200'
|
50
|
-
|
51
|
-
traces[7]['Layer'].must_equal 'net-http'
|
52
|
-
traces[7]['Label'].must_equal 'exit'
|
53
|
-
|
54
|
-
traces[8]['Layer'].must_equal 'faraday'
|
55
|
-
traces[9]['Label'].must_equal 'exit'
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should trace a Faraday request' do
|
59
|
-
AppOpticsAPM::API.start_trace('faraday_test') do
|
60
|
-
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
61
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
62
|
-
end
|
63
|
-
conn.get '/?q=ruby_test_suite'
|
64
|
-
end
|
65
|
-
|
66
|
-
traces = get_all_traces
|
67
|
-
traces.count.must_equal 11
|
68
|
-
|
69
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
70
|
-
validate_outer_layers(traces, 'faraday_test')
|
71
|
-
|
72
|
-
traces[1]['Layer'].must_equal 'faraday'
|
73
|
-
traces[1].key?('Backtrace').must_equal AppOpticsAPM::Config[:faraday][:collect_backtraces]
|
74
|
-
|
75
|
-
traces[6]['Layer'].must_equal 'net-http'
|
76
|
-
traces[6]['Label'].must_equal 'info'
|
77
|
-
traces[6]['IsService'].must_equal 1
|
78
|
-
traces[6]['RemoteProtocol'].must_equal 'HTTP'
|
79
|
-
traces[6]['RemoteHost'].must_equal '127.0.0.1:8101'
|
80
|
-
traces[6]['ServiceArg'].must_equal '/?q=ruby_test_suite'
|
81
|
-
traces[6]['HTTPMethod'].must_equal 'GET'
|
82
|
-
traces[6]['HTTPStatus'].must_equal '200'
|
83
|
-
|
84
|
-
traces[7]['Layer'].must_equal 'net-http'
|
85
|
-
traces[7]['Label'].must_equal 'exit'
|
86
|
-
|
87
|
-
traces[8]['Layer'].must_equal 'faraday'
|
88
|
-
traces[8]['Label'].must_equal 'info'
|
89
|
-
|
90
|
-
traces[9]['Layer'].must_equal 'faraday'
|
91
|
-
traces[9]['Label'].must_equal 'exit'
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'should trace a Faraday class style request' do
|
95
|
-
AppOpticsAPM::API.start_trace('faraday_test') do
|
96
|
-
Faraday.get('http://127.0.0.1:8101/', {:a => 1})
|
97
|
-
end
|
98
|
-
|
99
|
-
traces = get_all_traces
|
100
|
-
traces.count.must_equal 11
|
101
|
-
|
102
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
103
|
-
validate_outer_layers(traces, 'faraday_test')
|
104
|
-
|
105
|
-
traces[1]['Layer'].must_equal 'faraday'
|
106
|
-
traces[1].key?('Backtrace').must_equal AppOpticsAPM::Config[:faraday][:collect_backtraces]
|
107
|
-
|
108
|
-
traces[6]['Layer'].must_equal 'net-http'
|
109
|
-
traces[6]['Label'].must_equal 'info'
|
110
|
-
traces[6]['IsService'].must_equal 1
|
111
|
-
traces[6]['RemoteProtocol'].must_equal 'HTTP'
|
112
|
-
traces[6]['RemoteHost'].must_equal '127.0.0.1:8101'
|
113
|
-
traces[6]['ServiceArg'].must_equal '/?a=1'
|
114
|
-
traces[6]['HTTPMethod'].must_equal 'GET'
|
115
|
-
traces[6]['HTTPStatus'].must_equal '200'
|
116
|
-
|
117
|
-
traces[7]['Layer'].must_equal 'net-http'
|
118
|
-
traces[7]['Label'].must_equal 'exit'
|
119
|
-
|
120
|
-
traces[8]['Layer'].must_equal 'faraday'
|
121
|
-
traces[8]['Label'].must_equal 'info'
|
122
|
-
|
123
|
-
traces[9]['Layer'].must_equal 'faraday'
|
124
|
-
traces[9]['Label'].must_equal 'exit'
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'should trace a Faraday with the excon adapter' do
|
128
|
-
AppOpticsAPM::API.start_trace('faraday_test') do
|
129
|
-
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
130
|
-
faraday.adapter :excon
|
131
|
-
end
|
132
|
-
conn.get '/?q=1'
|
133
|
-
end
|
134
|
-
|
135
|
-
traces = get_all_traces
|
136
|
-
traces.count.must_equal 10
|
137
|
-
|
138
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
139
|
-
validate_outer_layers(traces, 'faraday_test')
|
140
|
-
|
141
|
-
traces[1]['Layer'].must_equal 'faraday'
|
142
|
-
traces[1].key?('Backtrace').must_equal AppOpticsAPM::Config[:faraday][:collect_backtraces]
|
143
|
-
|
144
|
-
traces[2]['Layer'].must_equal 'excon'
|
145
|
-
traces[2]['Label'].must_equal 'entry'
|
146
|
-
traces[2]['IsService'].must_equal 1
|
147
|
-
traces[2]['RemoteProtocol'].must_equal 'HTTP'
|
148
|
-
traces[2]['RemoteHost'].must_equal '127.0.0.1'
|
149
|
-
traces[2]['ServiceArg'].must_equal '/?q=1'
|
150
|
-
traces[2]['HTTPMethod'].must_equal 'GET'
|
151
|
-
|
152
|
-
traces[6]['Layer'].must_equal 'excon'
|
153
|
-
traces[6]['Label'].must_equal 'exit'
|
154
|
-
traces[6]['HTTPStatus'].must_equal 200
|
155
|
-
|
156
|
-
traces[7]['Layer'].must_equal 'faraday'
|
157
|
-
traces[7]['Label'].must_equal 'info'
|
158
|
-
traces[7]['Middleware'].must_equal '[Faraday::Adapter::Excon]'
|
159
|
-
|
160
|
-
traces[8]['Layer'].must_equal 'faraday'
|
161
|
-
traces[8]['Label'].must_equal 'exit'
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'should trace a Faraday with the httpclient adapter' do
|
165
|
-
AppOpticsAPM::API.start_trace('faraday_test') do
|
166
|
-
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
167
|
-
faraday.adapter :httpclient
|
168
|
-
end
|
169
|
-
conn.get '/?q=1'
|
170
|
-
end
|
171
|
-
|
172
|
-
traces = get_all_traces
|
173
|
-
traces.count.must_equal 10
|
174
|
-
|
175
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
176
|
-
validate_outer_layers(traces, 'faraday_test')
|
177
|
-
|
178
|
-
traces[1]['Layer'].must_equal 'faraday'
|
179
|
-
traces[1].key?('Backtrace').must_equal AppOpticsAPM::Config[:faraday][:collect_backtraces]
|
180
|
-
|
181
|
-
traces[2]['Layer'].must_equal 'httpclient'
|
182
|
-
traces[2]['Label'].must_equal 'entry'
|
183
|
-
traces[2]['IsService'].must_equal 1
|
184
|
-
traces[2]['RemoteProtocol'].must_equal 'HTTP'
|
185
|
-
traces[2]['RemoteHost'].must_equal '127.0.0.1:8101'
|
186
|
-
traces[2]['ServiceArg'].must_equal '/?q=1'
|
187
|
-
traces[2]['HTTPMethod'].must_equal 'GET'
|
188
|
-
|
189
|
-
traces[6]['Layer'].must_equal 'httpclient'
|
190
|
-
traces[6]['Label'].must_equal 'exit'
|
191
|
-
traces[6]['HTTPStatus'].must_equal 200
|
192
|
-
|
193
|
-
traces[7]['Layer'].must_equal 'faraday'
|
194
|
-
traces[7]['Label'].must_equal 'info'
|
195
|
-
traces[7]['Middleware'].must_equal '[Faraday::Adapter::HTTPClient]'
|
196
|
-
|
197
|
-
traces[8]['Layer'].must_equal 'faraday'
|
198
|
-
traces[8]['Label'].must_equal 'exit'
|
199
|
-
end
|
200
|
-
|
201
|
-
it 'should obey :collect_backtraces setting when true' do
|
202
|
-
AppOpticsAPM::Config[:faraday][:collect_backtraces] = true
|
203
|
-
|
204
|
-
AppOpticsAPM::API.start_trace('faraday_test') do
|
205
|
-
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
206
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
207
|
-
end
|
208
|
-
conn.get '/?q=ruby_test_suite'
|
209
|
-
end
|
210
|
-
|
211
|
-
traces = get_all_traces
|
212
|
-
layer_has_key(traces, 'faraday', 'Backtrace')
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'should obey :collect_backtraces setting when false' do
|
216
|
-
AppOpticsAPM::Config[:faraday][:collect_backtraces] = false
|
217
|
-
|
218
|
-
AppOpticsAPM::API.start_trace('faraday_test') do
|
219
|
-
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
220
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
221
|
-
end
|
222
|
-
conn.get '/?q=ruby_test_suite'
|
223
|
-
end
|
224
|
-
|
225
|
-
traces = get_all_traces
|
226
|
-
layer_doesnt_have_key(traces, 'faraday', 'Backtrace')
|
227
|
-
end
|
228
|
-
end
|
@@ -1,143 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'minitest_helper'
|
5
|
-
require 'net/http'
|
6
|
-
|
7
|
-
describe "Net::HTTP" do
|
8
|
-
before do
|
9
|
-
clear_all_traces
|
10
|
-
@collect_backtraces = AppOpticsAPM::Config[:nethttp][:collect_backtraces]
|
11
|
-
@log_args = AppOpticsAPM::Config[:nethttp][:log_args]
|
12
|
-
end
|
13
|
-
|
14
|
-
after do
|
15
|
-
AppOpticsAPM::Config[:nethttp][:collect_backtraces] = @collect_backtraces
|
16
|
-
AppOpticsAPM::Config[:nethttp][:log_args] = @log_args
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'Net::HTTP should be defined and ready' do
|
20
|
-
defined?(::Net::HTTP).wont_match nil
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'Net::HTTP should have appoptics_apm methods defined' do
|
24
|
-
[ :request_with_appoptics ].each do |m|
|
25
|
-
::Net::HTTP.method_defined?(m).must_equal true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should trace a Net::HTTP request to an instr'd app" do
|
30
|
-
AppOpticsAPM::API.start_trace('net-http_test', '', {}) do
|
31
|
-
uri = URI('http://127.0.0.1:8101/?q=1')
|
32
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
33
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
34
|
-
response = http.request(request)
|
35
|
-
# The HTTP response should have an X-Trace header inside of it
|
36
|
-
response["x-trace"].wont_match nil
|
37
|
-
end
|
38
|
-
|
39
|
-
traces = get_all_traces
|
40
|
-
traces.count.must_equal 8
|
41
|
-
valid_edges?(traces).must_equal true
|
42
|
-
validate_outer_layers(traces, 'net-http_test')
|
43
|
-
|
44
|
-
traces[1]['Layer'].must_equal 'net-http'
|
45
|
-
traces[1]['Label'].must_equal 'entry'
|
46
|
-
|
47
|
-
traces[2]['Layer'].must_equal 'rack'
|
48
|
-
traces[2]['Label'].must_equal 'entry'
|
49
|
-
|
50
|
-
traces[3]['Layer'].must_equal 'rack'
|
51
|
-
traces[3]['Label'].must_equal 'info'
|
52
|
-
|
53
|
-
traces[4]['Layer'].must_equal 'rack'
|
54
|
-
traces[4]['Label'].must_equal 'exit'
|
55
|
-
|
56
|
-
traces[5]['IsService'].must_equal 1
|
57
|
-
traces[5]['RemoteProtocol'].must_equal "HTTP"
|
58
|
-
traces[5]['RemoteHost'].must_equal "127.0.0.1:8101"
|
59
|
-
traces[5]['ServiceArg'].must_equal "/?q=1"
|
60
|
-
traces[5]['HTTPMethod'].must_equal "GET"
|
61
|
-
traces[5]['HTTPStatus'].must_equal "200"
|
62
|
-
traces[5].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:nethttp][:collect_backtraces]
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should trace a GET request" do
|
66
|
-
AppOpticsAPM::API.start_trace('net-http_test', '', {}) do
|
67
|
-
uri = URI('http://127.0.0.1:8101/')
|
68
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
69
|
-
http.get('/?q=1').read_body
|
70
|
-
end
|
71
|
-
|
72
|
-
traces = get_all_traces
|
73
|
-
traces.count.must_equal 8
|
74
|
-
valid_edges?(traces).must_equal true
|
75
|
-
|
76
|
-
validate_outer_layers(traces, 'net-http_test')
|
77
|
-
|
78
|
-
traces[1]['Layer'].must_equal 'net-http'
|
79
|
-
traces[5]['IsService'].must_equal 1
|
80
|
-
traces[5]['RemoteProtocol'].must_equal "HTTP"
|
81
|
-
traces[5]['RemoteHost'].must_equal "127.0.0.1:8101"
|
82
|
-
traces[5]['ServiceArg'].must_equal "/?q=1"
|
83
|
-
traces[5]['HTTPMethod'].must_equal "GET"
|
84
|
-
traces[5]['HTTPStatus'].must_equal "200"
|
85
|
-
traces[5].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:nethttp][:collect_backtraces]
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should obey :log_args setting when true" do
|
89
|
-
AppOpticsAPM::Config[:nethttp][:log_args] = true
|
90
|
-
|
91
|
-
AppOpticsAPM::API.start_trace('nethttp_test', '', {}) do
|
92
|
-
uri = URI('http://127.0.0.1:8101/')
|
93
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
94
|
-
http.use_ssl = false
|
95
|
-
http.get('/?q=ruby_test_suite').read_body
|
96
|
-
end
|
97
|
-
|
98
|
-
traces = get_all_traces
|
99
|
-
traces[5]['ServiceArg'].must_equal '/?q=ruby_test_suite'
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should obey :log_args setting when false" do
|
103
|
-
AppOpticsAPM::Config[:nethttp][:log_args] = false
|
104
|
-
|
105
|
-
AppOpticsAPM::API.start_trace('nethttp_test', '', {}) do
|
106
|
-
uri = URI('http://127.0.0.1:8101/')
|
107
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
108
|
-
http.use_ssl = false
|
109
|
-
http.get('/?q=ruby_test_suite').read_body
|
110
|
-
end
|
111
|
-
|
112
|
-
traces = get_all_traces
|
113
|
-
traces[5]['ServiceArg'].must_equal '/'
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should obey :collect_backtraces setting when true" do
|
117
|
-
AppOpticsAPM::Config[:nethttp][:collect_backtraces] = true
|
118
|
-
|
119
|
-
AppOpticsAPM::API.start_trace('nethttp_test', '', {}) do
|
120
|
-
uri = URI('http://127.0.0.1:8101/')
|
121
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
122
|
-
http.use_ssl = false
|
123
|
-
http.get('/?q=ruby_test_suite').read_body
|
124
|
-
end
|
125
|
-
|
126
|
-
traces = get_all_traces
|
127
|
-
layer_has_key(traces, 'net-http', 'Backtrace')
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should obey :collect_backtraces setting when false" do
|
131
|
-
AppOpticsAPM::Config[:nethttp][:collect_backtraces] = false
|
132
|
-
|
133
|
-
AppOpticsAPM::API.start_trace('nethttp_test', '', {}) do
|
134
|
-
uri = URI('http://127.0.0.1:8101/')
|
135
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
136
|
-
http.use_ssl = false
|
137
|
-
http.get('/?q=ruby_test_suite').read_body
|
138
|
-
end
|
139
|
-
|
140
|
-
traces = get_all_traces
|
141
|
-
layer_doesnt_have_key(traces, 'net-http', 'Backtrace')
|
142
|
-
end
|
143
|
-
end
|
@@ -1,304 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
unless defined?(JRUBY_VERSION)
|
5
|
-
require 'minitest_helper'
|
6
|
-
require 'appoptics_apm/inst/rack'
|
7
|
-
require File.expand_path(File.dirname(__FILE__) + '../../frameworks/apps/sinatra_simple')
|
8
|
-
|
9
|
-
class HTTPClientTest < Minitest::Test
|
10
|
-
include Rack::Test::Methods
|
11
|
-
|
12
|
-
def app
|
13
|
-
SinatraSimple
|
14
|
-
end
|
15
|
-
|
16
|
-
def setup
|
17
|
-
clear_all_traces
|
18
|
-
AppOpticsAPM::Config[:tracing_mode] = :always
|
19
|
-
end
|
20
|
-
|
21
|
-
def teardown
|
22
|
-
clear_all_traces
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_reports_version_init
|
26
|
-
init_kvs = ::AppOpticsAPM::Util.build_init_report
|
27
|
-
assert init_kvs.key?('Ruby.httpclient.Version')
|
28
|
-
assert_equal ::HTTPClient::VERSION, init_kvs['Ruby.httpclient.Version']
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_get_request
|
32
|
-
response = nil
|
33
|
-
|
34
|
-
AppOpticsAPM::API.start_trace('httpclient_tests') do
|
35
|
-
clnt = HTTPClient.new
|
36
|
-
response = clnt.get('http://127.0.0.1:8101/', :query => { :keyword => 'ruby', :lang => 'en' })
|
37
|
-
end
|
38
|
-
|
39
|
-
traces = get_all_traces
|
40
|
-
|
41
|
-
# Validate returned xtrace
|
42
|
-
assert response.headers.key?("X-Trace")
|
43
|
-
assert AppOpticsAPM::XTrace.valid?(response.headers["X-Trace"])
|
44
|
-
|
45
|
-
assert_equal traces.count, 7
|
46
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
47
|
-
validate_outer_layers(traces, "httpclient_tests")
|
48
|
-
|
49
|
-
assert_equal traces[1]['IsService'], 1
|
50
|
-
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/?keyword=ruby&lang=en'
|
51
|
-
assert_equal traces[1]['HTTPMethod'], 'GET'
|
52
|
-
assert traces[1].key?('Backtrace')
|
53
|
-
|
54
|
-
assert_equal traces[5]['Layer'], 'httpclient'
|
55
|
-
assert_equal traces[5]['Label'], 'exit'
|
56
|
-
assert_equal traces[5]['HTTPStatus'], 200
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_get_with_header_hash
|
60
|
-
response = nil
|
61
|
-
|
62
|
-
AppOpticsAPM::API.start_trace('httpclient_tests') do
|
63
|
-
clnt = HTTPClient.new
|
64
|
-
response = clnt.get('http://127.0.0.1:8101/', nil, { "SOAPAction" => "HelloWorld" })
|
65
|
-
end
|
66
|
-
|
67
|
-
traces = get_all_traces
|
68
|
-
|
69
|
-
xtrace = response.headers['X-Trace']
|
70
|
-
assert xtrace
|
71
|
-
assert AppOpticsAPM::XTrace.valid?(xtrace)
|
72
|
-
|
73
|
-
assert_equal traces.count, 7
|
74
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
75
|
-
validate_outer_layers(traces, "httpclient_tests")
|
76
|
-
|
77
|
-
assert_equal traces[1]['IsService'], 1
|
78
|
-
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/'
|
79
|
-
assert_equal traces[1]['HTTPMethod'], 'GET'
|
80
|
-
assert traces[1].key?('Backtrace')
|
81
|
-
|
82
|
-
assert_equal traces[5]['Layer'], 'httpclient'
|
83
|
-
assert_equal traces[5]['Label'], 'exit'
|
84
|
-
assert_equal traces[5]['HTTPStatus'], 200
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_get_with_header_array
|
88
|
-
response = nil
|
89
|
-
|
90
|
-
AppOpticsAPM::API.start_trace('httpclient_tests') do
|
91
|
-
clnt = HTTPClient.new
|
92
|
-
response = clnt.get('http://127.0.0.1:8101/', nil, [["Accept", "text/plain"], ["Accept", "text/html"]])
|
93
|
-
end
|
94
|
-
|
95
|
-
traces = get_all_traces
|
96
|
-
|
97
|
-
xtrace = response.headers['X-Trace']
|
98
|
-
assert xtrace
|
99
|
-
assert AppOpticsAPM::XTrace.valid?(xtrace)
|
100
|
-
|
101
|
-
assert_equal traces.count, 7
|
102
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
103
|
-
validate_outer_layers(traces, "httpclient_tests")
|
104
|
-
|
105
|
-
assert_equal traces[1]['IsService'], 1
|
106
|
-
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/'
|
107
|
-
assert_equal traces[1]['HTTPMethod'], 'GET'
|
108
|
-
assert traces[1].key?('Backtrace')
|
109
|
-
|
110
|
-
assert_equal traces[5]['Layer'], 'httpclient'
|
111
|
-
assert_equal traces[5]['Label'], 'exit'
|
112
|
-
assert_equal traces[5]['HTTPStatus'], 200
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_post_request
|
116
|
-
response = nil
|
117
|
-
|
118
|
-
AppOpticsAPM::API.start_trace('httpclient_tests') do
|
119
|
-
clnt = HTTPClient.new
|
120
|
-
response = clnt.post('http://127.0.0.1:8101/')
|
121
|
-
end
|
122
|
-
|
123
|
-
traces = get_all_traces
|
124
|
-
|
125
|
-
xtrace = response.headers['X-Trace']
|
126
|
-
assert xtrace
|
127
|
-
assert AppOpticsAPM::XTrace.valid?(xtrace)
|
128
|
-
|
129
|
-
assert_equal traces.count, 7
|
130
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
131
|
-
validate_outer_layers(traces, "httpclient_tests")
|
132
|
-
|
133
|
-
assert_equal traces[1]['IsService'], 1
|
134
|
-
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/'
|
135
|
-
assert_equal traces[1]['HTTPMethod'], 'POST'
|
136
|
-
assert traces[1].key?('Backtrace')
|
137
|
-
|
138
|
-
assert_equal traces[5]['Layer'], 'httpclient'
|
139
|
-
assert_equal traces[5]['Label'], 'exit'
|
140
|
-
assert_equal traces[5]['HTTPStatus'], 200
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_async_get
|
144
|
-
conn = nil
|
145
|
-
|
146
|
-
AppOpticsAPM::API.start_trace('httpclient_tests') do
|
147
|
-
clnt = HTTPClient.new
|
148
|
-
conn = clnt.get_async('http://127.0.0.1:8101/?blah=1')
|
149
|
-
end
|
150
|
-
|
151
|
-
# Allow async request to finish
|
152
|
-
Thread.pass until conn.finished?
|
153
|
-
|
154
|
-
traces = get_all_traces
|
155
|
-
|
156
|
-
assert_equal traces.count, 7
|
157
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
158
|
-
|
159
|
-
# In the case of async the layers are not always ordered the same
|
160
|
-
# validate_outer_layers is not applicable, so we make sure we get the pair for 'httpclient_tests'
|
161
|
-
assert_equal 2, traces.select { |trace| trace['Layer'] == 'httpclient_tests' }.size
|
162
|
-
|
163
|
-
# because of possible different ordering of traces we can't rely on an index and need to use find
|
164
|
-
async_entry = traces.find { |trace| trace['Layer'] == 'httpclient' && trace['Label'] == 'entry' }
|
165
|
-
assert_equal 1, async_entry['Async']
|
166
|
-
assert_equal 1, async_entry['IsService']
|
167
|
-
assert_equal 'http://127.0.0.1:8101/?blah=1', async_entry['RemoteURL']
|
168
|
-
assert_equal 'GET', async_entry['HTTPMethod']
|
169
|
-
assert async_entry.key?('Backtrace')
|
170
|
-
|
171
|
-
assert_equal 'httpclient', traces[6]['Layer']
|
172
|
-
assert_equal 'exit', traces[6]['Label']
|
173
|
-
assert_equal 200, traces[6]['HTTPStatus']
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_cross_app_tracing
|
177
|
-
response = nil
|
178
|
-
|
179
|
-
AppOpticsAPM::API.start_trace('httpclient_tests') do
|
180
|
-
clnt = HTTPClient.new
|
181
|
-
response = clnt.get('http://127.0.0.1:8101/', :query => { :keyword => 'ruby', :lang => 'en' })
|
182
|
-
end
|
183
|
-
|
184
|
-
xtrace = response.headers['X-Trace']
|
185
|
-
assert xtrace
|
186
|
-
assert AppOpticsAPM::XTrace.valid?(xtrace)
|
187
|
-
|
188
|
-
traces = get_all_traces
|
189
|
-
|
190
|
-
assert_equal traces.count, 7
|
191
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
192
|
-
validate_outer_layers(traces, "httpclient_tests")
|
193
|
-
|
194
|
-
assert_equal 1, traces[1]['IsService']
|
195
|
-
assert_equal 'http://127.0.0.1:8101/?keyword=ruby&lang=en', traces[1]['RemoteURL']
|
196
|
-
assert_equal 'GET', traces[1]['HTTPMethod']
|
197
|
-
assert traces[1].key?('Backtrace')
|
198
|
-
|
199
|
-
assert_equal 'rack', traces[2]['Layer']
|
200
|
-
assert_equal 'entry', traces[2]['Label']
|
201
|
-
assert_equal 'rack', traces[3]['Layer']
|
202
|
-
assert_equal 'info', traces[3]['Label']
|
203
|
-
assert_equal 'rack', traces[4]['Layer']
|
204
|
-
assert_equal 'exit', traces[4]['Label']
|
205
|
-
|
206
|
-
assert_equal 'httpclient', traces[5]['Layer']
|
207
|
-
assert_equal 'exit', traces[5]['Label']
|
208
|
-
assert_equal 200, traces[5]['HTTPStatus']
|
209
|
-
end
|
210
|
-
|
211
|
-
def test_requests_with_errors
|
212
|
-
result = nil
|
213
|
-
begin
|
214
|
-
AppOpticsAPM::API.start_trace('httpclient_tests') do
|
215
|
-
clnt = HTTPClient.new
|
216
|
-
result = clnt.get('http://asfjalkfjlajfljkaljf/')
|
217
|
-
end
|
218
|
-
rescue
|
219
|
-
end
|
220
|
-
|
221
|
-
traces = get_all_traces
|
222
|
-
assert_equal 5, traces.count
|
223
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
224
|
-
validate_outer_layers(traces, "httpclient_tests")
|
225
|
-
|
226
|
-
assert_equal 1, traces[1]['IsService']
|
227
|
-
assert_equal 'http://asfjalkfjlajfljkaljf/', traces[1]['RemoteURL']
|
228
|
-
assert_equal 'GET', traces[1]['HTTPMethod']
|
229
|
-
assert traces[1].key?('Backtrace')
|
230
|
-
|
231
|
-
assert_equal 'httpclient', traces[2]['Layer']
|
232
|
-
assert_equal 'error', traces[2]['Label']
|
233
|
-
assert_equal "SocketError", traces[2]['ErrorClass']
|
234
|
-
assert traces[2].key?('ErrorMsg')
|
235
|
-
assert traces[2].key?('Backtrace')
|
236
|
-
|
237
|
-
assert_equal 'httpclient', traces[3]['Layer']
|
238
|
-
assert_equal 'exit', traces[3]['Label']
|
239
|
-
end
|
240
|
-
|
241
|
-
def test_log_args_when_true
|
242
|
-
@log_args = AppOpticsAPM::Config[:httpclient][:log_args]
|
243
|
-
AppOpticsAPM::Config[:httpclient][:log_args] = true
|
244
|
-
|
245
|
-
response = nil
|
246
|
-
|
247
|
-
AppOpticsAPM::API.start_trace('httpclient_tests') do
|
248
|
-
clnt = HTTPClient.new
|
249
|
-
response = clnt.get('http://127.0.0.1:8101/', :query => { :keyword => 'ruby', :lang => 'en' })
|
250
|
-
end
|
251
|
-
|
252
|
-
traces = get_all_traces
|
253
|
-
|
254
|
-
xtrace = response.headers['X-Trace']
|
255
|
-
assert xtrace
|
256
|
-
assert AppOpticsAPM::XTrace.valid?(xtrace)
|
257
|
-
|
258
|
-
assert_equal 7, traces.count
|
259
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
260
|
-
|
261
|
-
assert_equal 'http://127.0.0.1:8101/?keyword=ruby&lang=en', traces[1]['RemoteURL']
|
262
|
-
|
263
|
-
AppOpticsAPM::Config[:httpclient][:log_args] = @log_args
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_log_args_when_false
|
267
|
-
@log_args = AppOpticsAPM::Config[:httpclient][:log_args]
|
268
|
-
AppOpticsAPM::Config[:httpclient][:log_args] = false
|
269
|
-
|
270
|
-
response = nil
|
271
|
-
|
272
|
-
AppOpticsAPM::API.start_trace('httpclient_tests') do
|
273
|
-
clnt = HTTPClient.new
|
274
|
-
response = clnt.get('http://127.0.0.1:8101/', :query => { :keyword => 'ruby', :lang => 'en' })
|
275
|
-
end
|
276
|
-
|
277
|
-
traces = get_all_traces
|
278
|
-
|
279
|
-
xtrace = response.headers['X-Trace']
|
280
|
-
assert xtrace
|
281
|
-
assert AppOpticsAPM::XTrace.valid?(xtrace)
|
282
|
-
|
283
|
-
assert_equal 7, traces.count
|
284
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
285
|
-
|
286
|
-
assert_equal 'http://127.0.0.1:8101/', traces[1]['RemoteURL']
|
287
|
-
|
288
|
-
AppOpticsAPM::Config[:httpclient][:log_args] = @log_args
|
289
|
-
end
|
290
|
-
|
291
|
-
def test_without_tracing
|
292
|
-
clnt = HTTPClient.new
|
293
|
-
clnt.get('http://127.0.0.1:8101/', :query => { :keyword => 'ruby', :lang => 'en' })
|
294
|
-
|
295
|
-
traces = get_all_traces
|
296
|
-
# we only get traces from rack
|
297
|
-
assert_equal 3, traces.count
|
298
|
-
traces.each do |trace|
|
299
|
-
assert_equal 'rack', trace["Layer"]
|
300
|
-
end
|
301
|
-
|
302
|
-
end
|
303
|
-
end
|
304
|
-
end
|