traceview 3.0.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +5 -0
- data/.travis.yml +58 -0
- data/Appraisals +10 -0
- data/CHANGELOG.md +490 -0
- data/CONFIG.md +16 -0
- data/Gemfile +95 -0
- data/LICENSE +199 -0
- data/README.md +380 -0
- data/Rakefile +109 -0
- data/examples/DNT.md +35 -0
- data/examples/carrying_context.rb +225 -0
- data/examples/instrumenting_metal_controller.rb +8 -0
- data/examples/puma_on_heroku_config.rb +17 -0
- data/examples/tracing_async_threads.rb +125 -0
- data/examples/tracing_background_jobs.rb +52 -0
- data/examples/tracing_forked_processes.rb +100 -0
- data/examples/unicorn_on_heroku_config.rb +28 -0
- data/ext/oboe_metal/extconf.rb +61 -0
- data/ext/oboe_metal/noop/noop.c +7 -0
- data/ext/oboe_metal/src/bson/bson.h +221 -0
- data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
- data/ext/oboe_metal/src/oboe.h +275 -0
- data/ext/oboe_metal/src/oboe.hpp +352 -0
- data/ext/oboe_metal/src/oboe_wrap.cxx +3886 -0
- data/ext/oboe_metal/tests/test.rb +11 -0
- data/gemfiles/mongo.gemfile +33 -0
- data/gemfiles/moped.gemfile +33 -0
- data/get_version.rb +5 -0
- data/init.rb +4 -0
- data/lib/joboe_metal.rb +206 -0
- data/lib/oboe/README +2 -0
- data/lib/oboe/backward_compatibility.rb +59 -0
- data/lib/oboe/inst/rack.rb +11 -0
- data/lib/oboe.rb +7 -0
- data/lib/oboe_metal.rb +151 -0
- data/lib/rails/generators/traceview/install_generator.rb +76 -0
- data/lib/rails/generators/traceview/templates/traceview_initializer.rb +159 -0
- data/lib/traceview/api/layerinit.rb +51 -0
- data/lib/traceview/api/logging.rb +209 -0
- data/lib/traceview/api/memcache.rb +31 -0
- data/lib/traceview/api/profiling.rb +50 -0
- data/lib/traceview/api/tracing.rb +135 -0
- data/lib/traceview/api/util.rb +121 -0
- data/lib/traceview/api.rb +18 -0
- data/lib/traceview/base.rb +225 -0
- data/lib/traceview/config.rb +238 -0
- data/lib/traceview/frameworks/grape.rb +97 -0
- data/lib/traceview/frameworks/padrino/templates.rb +58 -0
- data/lib/traceview/frameworks/padrino.rb +64 -0
- data/lib/traceview/frameworks/rails/helpers/rum/rum_ajax_header.js.erb +5 -0
- data/lib/traceview/frameworks/rails/helpers/rum/rum_footer.js.erb +1 -0
- data/lib/traceview/frameworks/rails/helpers/rum/rum_header.js.erb +3 -0
- data/lib/traceview/frameworks/rails/inst/action_controller.rb +216 -0
- data/lib/traceview/frameworks/rails/inst/action_view.rb +56 -0
- data/lib/traceview/frameworks/rails/inst/action_view_2x.rb +54 -0
- data/lib/traceview/frameworks/rails/inst/action_view_30.rb +48 -0
- data/lib/traceview/frameworks/rails/inst/active_record.rb +24 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/mysql.rb +43 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/mysql2.rb +28 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/oracle.rb +18 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/postgresql.rb +30 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/utils.rb +117 -0
- data/lib/traceview/frameworks/rails.rb +145 -0
- data/lib/traceview/frameworks/sinatra/templates.rb +56 -0
- data/lib/traceview/frameworks/sinatra.rb +95 -0
- data/lib/traceview/inst/cassandra.rb +279 -0
- data/lib/traceview/inst/dalli.rb +86 -0
- data/lib/traceview/inst/em-http-request.rb +99 -0
- data/lib/traceview/inst/excon.rb +111 -0
- data/lib/traceview/inst/faraday.rb +73 -0
- data/lib/traceview/inst/http.rb +87 -0
- data/lib/traceview/inst/httpclient.rb +173 -0
- data/lib/traceview/inst/memcache.rb +102 -0
- data/lib/traceview/inst/memcached.rb +94 -0
- data/lib/traceview/inst/mongo.rb +238 -0
- data/lib/traceview/inst/moped.rb +474 -0
- data/lib/traceview/inst/rack.rb +122 -0
- data/lib/traceview/inst/redis.rb +271 -0
- data/lib/traceview/inst/resque.rb +192 -0
- data/lib/traceview/inst/rest-client.rb +38 -0
- data/lib/traceview/inst/sequel.rb +162 -0
- data/lib/traceview/inst/typhoeus.rb +102 -0
- data/lib/traceview/instrumentation.rb +21 -0
- data/lib/traceview/loading.rb +94 -0
- data/lib/traceview/logger.rb +41 -0
- data/lib/traceview/method_profiling.rb +84 -0
- data/lib/traceview/ruby.rb +36 -0
- data/lib/traceview/support.rb +113 -0
- data/lib/traceview/thread_local.rb +26 -0
- data/lib/traceview/util.rb +250 -0
- data/lib/traceview/version.rb +16 -0
- data/lib/traceview/xtrace.rb +90 -0
- data/lib/traceview.rb +62 -0
- data/test/frameworks/apps/grape_nested.rb +30 -0
- data/test/frameworks/apps/grape_simple.rb +24 -0
- data/test/frameworks/apps/padrino_simple.rb +45 -0
- data/test/frameworks/apps/sinatra_simple.rb +24 -0
- data/test/frameworks/grape_test.rb +142 -0
- data/test/frameworks/padrino_test.rb +30 -0
- data/test/frameworks/sinatra_test.rb +30 -0
- data/test/instrumentation/cassandra_test.rb +380 -0
- data/test/instrumentation/dalli_test.rb +171 -0
- data/test/instrumentation/em_http_request_test.rb +86 -0
- data/test/instrumentation/excon_test.rb +207 -0
- data/test/instrumentation/faraday_test.rb +235 -0
- data/test/instrumentation/http_test.rb +140 -0
- data/test/instrumentation/httpclient_test.rb +296 -0
- data/test/instrumentation/memcache_test.rb +251 -0
- data/test/instrumentation/memcached_test.rb +226 -0
- data/test/instrumentation/mongo_test.rb +462 -0
- data/test/instrumentation/moped_test.rb +496 -0
- data/test/instrumentation/rack_test.rb +116 -0
- data/test/instrumentation/redis_hashes_test.rb +265 -0
- data/test/instrumentation/redis_keys_test.rb +318 -0
- data/test/instrumentation/redis_lists_test.rb +310 -0
- data/test/instrumentation/redis_misc_test.rb +160 -0
- data/test/instrumentation/redis_sets_test.rb +293 -0
- data/test/instrumentation/redis_sortedsets_test.rb +325 -0
- data/test/instrumentation/redis_strings_test.rb +333 -0
- data/test/instrumentation/resque_test.rb +62 -0
- data/test/instrumentation/rest-client_test.rb +294 -0
- data/test/instrumentation/sequel_mysql2_test.rb +326 -0
- data/test/instrumentation/sequel_mysql_test.rb +326 -0
- data/test/instrumentation/sequel_pg_test.rb +330 -0
- data/test/instrumentation/typhoeus_test.rb +285 -0
- data/test/minitest_helper.rb +187 -0
- data/test/profiling/method_test.rb +198 -0
- data/test/servers/rackapp_8101.rb +22 -0
- data/test/support/backcompat_test.rb +269 -0
- data/test/support/config_test.rb +128 -0
- data/test/support/dnt_test.rb +73 -0
- data/test/support/liboboe_settings_test.rb +104 -0
- data/test/support/xtrace_test.rb +35 -0
- data/traceview.gemspec +29 -0
- metadata +248 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
require 'minitest_helper'
|
|
2
|
+
require 'traceview/inst/rack'
|
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '../../frameworks/apps/sinatra_simple')
|
|
4
|
+
|
|
5
|
+
class ExconTest < Minitest::Test
|
|
6
|
+
include Rack::Test::Methods
|
|
7
|
+
|
|
8
|
+
def app
|
|
9
|
+
SinatraSimple
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_must_return_xtrace_header
|
|
13
|
+
clear_all_traces
|
|
14
|
+
get "/"
|
|
15
|
+
xtrace = last_response['X-Trace']
|
|
16
|
+
assert xtrace
|
|
17
|
+
assert TraceView::XTrace.valid?(xtrace)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_reports_version_init
|
|
21
|
+
init_kvs = ::TraceView::Util.build_init_report
|
|
22
|
+
assert init_kvs.key?('Ruby.Excon.Version')
|
|
23
|
+
assert_equal init_kvs['Ruby.Excon.Version'], "Excon-#{::Excon::VERSION}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_class_get_request
|
|
27
|
+
clear_all_traces
|
|
28
|
+
|
|
29
|
+
TraceView::API.start_trace('excon_tests') do
|
|
30
|
+
Excon.get('http://127.0.0.1:8101/')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
traces = get_all_traces
|
|
34
|
+
assert_equal traces.count, 7
|
|
35
|
+
validate_outer_layers(traces, "excon_tests")
|
|
36
|
+
valid_edges?(traces)
|
|
37
|
+
|
|
38
|
+
assert_equal traces[1]['IsService'], 1
|
|
39
|
+
assert_equal traces[1]['RemoteHost'], '127.0.0.1'
|
|
40
|
+
assert_equal traces[1]['RemoteProtocol'], 'HTTP'
|
|
41
|
+
assert_equal traces[1]['ServiceArg'], '/'
|
|
42
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
|
43
|
+
assert traces[1].key?('Backtrace')
|
|
44
|
+
|
|
45
|
+
assert_equal traces[5]['Layer'], 'excon'
|
|
46
|
+
assert_equal traces[5]['Label'], 'exit'
|
|
47
|
+
assert_equal traces[5]['HTTPStatus'], 200
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_cross_app_tracing
|
|
51
|
+
clear_all_traces
|
|
52
|
+
|
|
53
|
+
TraceView::API.start_trace('excon_tests') do
|
|
54
|
+
response = Excon.get('http://127.0.0.1:8101/?blah=1')
|
|
55
|
+
xtrace = response.headers['X-Trace']
|
|
56
|
+
assert xtrace
|
|
57
|
+
assert TraceView::XTrace.valid?(xtrace)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
traces = get_all_traces
|
|
61
|
+
assert_equal traces.count, 7
|
|
62
|
+
validate_outer_layers(traces, "excon_tests")
|
|
63
|
+
valid_edges?(traces)
|
|
64
|
+
|
|
65
|
+
assert_equal traces[1]['IsService'], 1
|
|
66
|
+
assert_equal traces[1]['RemoteHost'], '127.0.0.1'
|
|
67
|
+
assert_equal traces[1]['RemoteProtocol'], 'HTTP'
|
|
68
|
+
assert_equal traces[1]['ServiceArg'], '/?blah=1'
|
|
69
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
|
70
|
+
assert traces[1].key?('Backtrace')
|
|
71
|
+
assert_equal traces[5]['HTTPStatus'], 200
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_persistent_requests
|
|
75
|
+
# Persistence was adding in 0.31.0
|
|
76
|
+
skip if Excon::VERSION < '0.31.0'
|
|
77
|
+
|
|
78
|
+
clear_all_traces
|
|
79
|
+
|
|
80
|
+
TraceView::API.start_trace('excon_tests') do
|
|
81
|
+
connection = Excon.new('http://127.0.0.1:8101/') # non-persistent by default
|
|
82
|
+
connection.get # socket established, then closed
|
|
83
|
+
connection.get(:persistent => true) # socket established, left open
|
|
84
|
+
connection.get # socket reused, then closed
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
traces = get_all_traces
|
|
88
|
+
assert_equal traces.count, 17
|
|
89
|
+
validate_outer_layers(traces, "excon_tests")
|
|
90
|
+
valid_edges?(traces)
|
|
91
|
+
|
|
92
|
+
assert_equal traces[1]['IsService'], 1
|
|
93
|
+
assert_equal traces[1]['RemoteHost'], '127.0.0.1'
|
|
94
|
+
assert_equal traces[1]['RemoteProtocol'], 'HTTP'
|
|
95
|
+
assert_equal traces[1]['ServiceArg'], '/'
|
|
96
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
|
97
|
+
assert traces[1].key?('Backtrace')
|
|
98
|
+
assert_equal traces[5]['HTTPStatus'], 200
|
|
99
|
+
|
|
100
|
+
assert_equal traces[6]['IsService'], 1
|
|
101
|
+
assert_equal traces[6]['RemoteHost'], '127.0.0.1'
|
|
102
|
+
assert_equal traces[6]['RemoteProtocol'], 'HTTP'
|
|
103
|
+
assert_equal traces[6]['ServiceArg'], '/'
|
|
104
|
+
assert_equal traces[6]['HTTPMethod'], 'GET'
|
|
105
|
+
assert traces[6].key?('Backtrace')
|
|
106
|
+
assert_equal traces[10]['HTTPStatus'], 200
|
|
107
|
+
|
|
108
|
+
assert_equal traces[11]['IsService'], 1
|
|
109
|
+
assert_equal traces[11]['RemoteHost'], '127.0.0.1'
|
|
110
|
+
assert_equal traces[11]['RemoteProtocol'], 'HTTP'
|
|
111
|
+
assert_equal traces[11]['ServiceArg'], '/'
|
|
112
|
+
assert_equal traces[11]['HTTPMethod'], 'GET'
|
|
113
|
+
assert traces[11].key?('Backtrace')
|
|
114
|
+
assert_equal traces[15]['HTTPStatus'], 200
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_pipelined_requests
|
|
118
|
+
skip if Excon::VERSION <= '0.17.0'
|
|
119
|
+
|
|
120
|
+
clear_all_traces
|
|
121
|
+
|
|
122
|
+
TraceView::API.start_trace('excon_tests') do
|
|
123
|
+
connection = Excon.new('http://127.0.0.1:8101/')
|
|
124
|
+
connection.requests([{:method => :get}, {:method => :put}])
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
traces = get_all_traces
|
|
128
|
+
assert_equal traces.count, 10
|
|
129
|
+
validate_outer_layers(traces, "excon_tests")
|
|
130
|
+
valid_edges?(traces)
|
|
131
|
+
|
|
132
|
+
assert_equal traces[1]['IsService'], 1
|
|
133
|
+
assert_equal traces[1]['RemoteHost'], '127.0.0.1'
|
|
134
|
+
assert_equal traces[1]['RemoteProtocol'], 'HTTP'
|
|
135
|
+
assert_equal traces[1]['ServiceArg'], '/'
|
|
136
|
+
assert_equal traces[1]['Pipeline'], 'true'
|
|
137
|
+
assert_equal traces[1]['HTTPMethods'], 'GET, PUT'
|
|
138
|
+
assert traces[1].key?('Backtrace')
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def test_requests_with_errors
|
|
142
|
+
clear_all_traces
|
|
143
|
+
|
|
144
|
+
begin
|
|
145
|
+
TraceView::API.start_trace('excon_tests') do
|
|
146
|
+
Excon.get('http://asfjalkfjlajfljkaljf/')
|
|
147
|
+
end
|
|
148
|
+
rescue
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
traces = get_all_traces
|
|
152
|
+
assert_equal traces.count, 5
|
|
153
|
+
validate_outer_layers(traces, "excon_tests")
|
|
154
|
+
valid_edges?(traces)
|
|
155
|
+
|
|
156
|
+
assert_equal traces[1]['IsService'], 1
|
|
157
|
+
assert_equal traces[1]['RemoteHost'], 'asfjalkfjlajfljkaljf'
|
|
158
|
+
assert_equal traces[1]['RemoteProtocol'], 'HTTP'
|
|
159
|
+
assert_equal traces[1]['ServiceArg'], '/'
|
|
160
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
|
161
|
+
assert traces[1].key?('Backtrace')
|
|
162
|
+
|
|
163
|
+
assert_equal traces[2]['Layer'], 'excon'
|
|
164
|
+
assert_equal traces[2]['Label'], 'error'
|
|
165
|
+
assert_equal traces[2]['ErrorClass'], "Excon::Errors::SocketError"
|
|
166
|
+
assert traces[2].key?('ErrorMsg')
|
|
167
|
+
assert traces[2].key?('Backtrace')
|
|
168
|
+
|
|
169
|
+
assert_equal traces[3]['Layer'], 'excon'
|
|
170
|
+
assert_equal traces[3]['Label'], 'exit'
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def test_obey_log_args_when_false
|
|
174
|
+
@log_args = TraceView::Config[:excon][:log_args]
|
|
175
|
+
clear_all_traces
|
|
176
|
+
|
|
177
|
+
TraceView::Config[:excon][:log_args] = false
|
|
178
|
+
|
|
179
|
+
TraceView::API.start_trace('excon_tests') do
|
|
180
|
+
Excon.get('http://127.0.0.1:8101/?blah=1')
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
traces = get_all_traces
|
|
184
|
+
assert_equal traces.count, 7
|
|
185
|
+
assert_equal traces[1]['ServiceArg'], '/'
|
|
186
|
+
|
|
187
|
+
TraceView::Config[:excon][:log_args] = @log_args
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def test_obey_log_args_when_true
|
|
191
|
+
@log_args = TraceView::Config[:excon][:log_args]
|
|
192
|
+
clear_all_traces
|
|
193
|
+
|
|
194
|
+
TraceView::Config[:excon][:log_args] = true
|
|
195
|
+
|
|
196
|
+
TraceView::API.start_trace('excon_tests') do
|
|
197
|
+
Excon.get('http://127.0.0.1:8101/?blah=1')
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
traces = get_all_traces
|
|
201
|
+
assert_equal traces.count, 7
|
|
202
|
+
assert_equal traces[1]['ServiceArg'], '/?blah=1'
|
|
203
|
+
|
|
204
|
+
TraceView::Config[:excon][:log_args] = @log_args
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
require 'minitest_helper'
|
|
2
|
+
|
|
3
|
+
describe "Faraday" do
|
|
4
|
+
before do
|
|
5
|
+
clear_all_traces
|
|
6
|
+
@collect_backtraces = TraceView::Config[:faraday][:collect_backtraces]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
after do
|
|
10
|
+
TraceView::Config[:faraday][:collect_backtraces] = @collect_backtraces
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'Faraday should be defined and ready' do
|
|
14
|
+
defined?(::Faraday).wont_match nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'Faraday should have traceview methods defined' do
|
|
18
|
+
[ :run_request_with_traceview ].each do |m|
|
|
19
|
+
::Faraday::Connection.method_defined?(m).must_equal true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should trace cross-app request" do
|
|
24
|
+
TraceView::API.start_trace('faraday_test') do
|
|
25
|
+
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
|
26
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
|
27
|
+
end
|
|
28
|
+
response = conn.get '/games?q=1'
|
|
29
|
+
response.headers["x-trace"].wont_match nil
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
traces = get_all_traces
|
|
33
|
+
traces.count.must_equal 11
|
|
34
|
+
|
|
35
|
+
validate_outer_layers(traces, 'faraday_test')
|
|
36
|
+
|
|
37
|
+
traces[1]['Layer'].must_equal 'faraday'
|
|
38
|
+
traces[1].key?('Backtrace').must_equal TraceView::Config[:faraday][:collect_backtraces]
|
|
39
|
+
|
|
40
|
+
traces[6]['Layer'].must_equal 'net-http'
|
|
41
|
+
traces[6]['IsService'].must_equal 1
|
|
42
|
+
traces[6]['RemoteProtocol'].must_equal 'HTTP'
|
|
43
|
+
traces[6]['RemoteHost'].must_equal '127.0.0.1:8101'
|
|
44
|
+
traces[6]['ServiceArg'].must_equal '/games?q=1'
|
|
45
|
+
traces[6]['HTTPMethod'].must_equal 'GET'
|
|
46
|
+
traces[6]['HTTPStatus'].must_equal '200'
|
|
47
|
+
|
|
48
|
+
traces[7]['Layer'].must_equal 'net-http'
|
|
49
|
+
traces[7]['Label'].must_equal 'exit'
|
|
50
|
+
|
|
51
|
+
traces[8]['Layer'].must_equal 'faraday'
|
|
52
|
+
traces[9]['Label'].must_equal 'exit'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'should trace a Faraday request' do
|
|
56
|
+
TraceView::API.start_trace('faraday_test') do
|
|
57
|
+
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
|
58
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
|
59
|
+
end
|
|
60
|
+
conn.get '/?q=ruby_test_suite'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
traces = get_all_traces
|
|
64
|
+
traces.count.must_equal 11
|
|
65
|
+
|
|
66
|
+
valid_edges?(traces)
|
|
67
|
+
validate_outer_layers(traces, 'faraday_test')
|
|
68
|
+
|
|
69
|
+
traces[1]['Layer'].must_equal 'faraday'
|
|
70
|
+
traces[1].key?('Backtrace').must_equal TraceView::Config[:faraday][:collect_backtraces]
|
|
71
|
+
|
|
72
|
+
traces[6]['Layer'].must_equal 'net-http'
|
|
73
|
+
traces[6]['Label'].must_equal 'info'
|
|
74
|
+
traces[6]['IsService'].must_equal 1
|
|
75
|
+
traces[6]['RemoteProtocol'].must_equal 'HTTP'
|
|
76
|
+
traces[6]['RemoteHost'].must_equal '127.0.0.1:8101'
|
|
77
|
+
traces[6]['ServiceArg'].must_equal '/?q=ruby_test_suite'
|
|
78
|
+
traces[6]['HTTPMethod'].must_equal 'GET'
|
|
79
|
+
traces[6]['HTTPStatus'].must_equal '200'
|
|
80
|
+
|
|
81
|
+
traces[7]['Layer'].must_equal 'net-http'
|
|
82
|
+
traces[7]['Label'].must_equal 'exit'
|
|
83
|
+
|
|
84
|
+
traces[8]['Layer'].must_equal 'faraday'
|
|
85
|
+
traces[8]['Label'].must_equal 'info'
|
|
86
|
+
|
|
87
|
+
traces[9]['Layer'].must_equal 'faraday'
|
|
88
|
+
traces[9]['Label'].must_equal 'exit'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'should trace a Faraday class style request' do
|
|
92
|
+
TraceView::API.start_trace('faraday_test') do
|
|
93
|
+
Faraday.get('http://127.0.0.1:8101/', {:a => 1})
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
traces = get_all_traces
|
|
97
|
+
traces.count.must_equal 11
|
|
98
|
+
|
|
99
|
+
valid_edges?(traces)
|
|
100
|
+
validate_outer_layers(traces, 'faraday_test')
|
|
101
|
+
|
|
102
|
+
traces[1]['Layer'].must_equal 'faraday'
|
|
103
|
+
traces[1].key?('Backtrace').must_equal TraceView::Config[:faraday][:collect_backtraces]
|
|
104
|
+
|
|
105
|
+
traces[6]['Layer'].must_equal 'net-http'
|
|
106
|
+
traces[6]['Label'].must_equal 'info'
|
|
107
|
+
traces[6]['IsService'].must_equal 1
|
|
108
|
+
traces[6]['RemoteProtocol'].must_equal 'HTTP'
|
|
109
|
+
traces[6]['RemoteHost'].must_equal '127.0.0.1:8101'
|
|
110
|
+
traces[6]['ServiceArg'].must_equal '/?a=1'
|
|
111
|
+
traces[6]['HTTPMethod'].must_equal 'GET'
|
|
112
|
+
traces[6]['HTTPStatus'].must_equal '200'
|
|
113
|
+
|
|
114
|
+
traces[7]['Layer'].must_equal 'net-http'
|
|
115
|
+
traces[7]['Label'].must_equal 'exit'
|
|
116
|
+
|
|
117
|
+
traces[8]['Layer'].must_equal 'faraday'
|
|
118
|
+
traces[8]['Label'].must_equal 'info'
|
|
119
|
+
|
|
120
|
+
traces[9]['Layer'].must_equal 'faraday'
|
|
121
|
+
traces[9]['Label'].must_equal 'exit'
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'should trace a Faraday with the excon adapter' do
|
|
125
|
+
TraceView::API.start_trace('faraday_test') do
|
|
126
|
+
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
|
127
|
+
faraday.adapter :excon
|
|
128
|
+
end
|
|
129
|
+
conn.get '/?q=1'
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
traces = get_all_traces
|
|
133
|
+
traces.count.must_equal 10
|
|
134
|
+
|
|
135
|
+
valid_edges?(traces)
|
|
136
|
+
validate_outer_layers(traces, 'faraday_test')
|
|
137
|
+
|
|
138
|
+
traces[1]['Layer'].must_equal 'faraday'
|
|
139
|
+
traces[1].key?('Backtrace').must_equal TraceView::Config[:faraday][:collect_backtraces]
|
|
140
|
+
|
|
141
|
+
traces[2]['Layer'].must_equal 'excon'
|
|
142
|
+
traces[2]['Label'].must_equal 'entry'
|
|
143
|
+
traces[2]['IsService'].must_equal 1
|
|
144
|
+
traces[2]['RemoteProtocol'].must_equal 'HTTP'
|
|
145
|
+
traces[2]['RemoteHost'].must_equal '127.0.0.1'
|
|
146
|
+
traces[2]['ServiceArg'].must_equal '/?q=1'
|
|
147
|
+
traces[2]['HTTPMethod'].must_equal 'GET'
|
|
148
|
+
|
|
149
|
+
traces[6]['Layer'].must_equal 'excon'
|
|
150
|
+
traces[6]['Label'].must_equal 'exit'
|
|
151
|
+
traces[6]['HTTPStatus'].must_equal 200
|
|
152
|
+
|
|
153
|
+
traces[7]['Layer'].must_equal 'faraday'
|
|
154
|
+
traces[7]['Label'].must_equal 'info'
|
|
155
|
+
unless RUBY_VERSION < '1.9.3'
|
|
156
|
+
# FIXME: Ruby 1.8 is reporting an object instance instead of
|
|
157
|
+
# an array
|
|
158
|
+
traces[7]['Middleware'].must_equal '[Faraday::Adapter::Excon]'
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
traces[8]['Layer'].must_equal 'faraday'
|
|
162
|
+
traces[8]['Label'].must_equal 'exit'
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it 'should trace a Faraday with the httpclient adapter' do
|
|
166
|
+
skip "FIXME: once HTTPClient instrumentation is done"
|
|
167
|
+
|
|
168
|
+
TraceView::API.start_trace('faraday_test') do
|
|
169
|
+
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
|
170
|
+
faraday.adapter :httpclient
|
|
171
|
+
end
|
|
172
|
+
conn.get '/?q=1'
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
traces = get_all_traces
|
|
176
|
+
traces.count.must_equal 10
|
|
177
|
+
|
|
178
|
+
valid_edges?(traces)
|
|
179
|
+
validate_outer_layers(traces, 'faraday_test')
|
|
180
|
+
|
|
181
|
+
traces[1]['Layer'].must_equal 'faraday'
|
|
182
|
+
traces[1].key?('Backtrace').must_equal TraceView::Config[:faraday][:collect_backtraces]
|
|
183
|
+
|
|
184
|
+
traces[2]['Layer'].must_equal 'excon'
|
|
185
|
+
traces[2]['Label'].must_equal 'entry'
|
|
186
|
+
traces[2]['IsService'].must_equal 1
|
|
187
|
+
traces[2]['RemoteProtocol'].must_equal 'HTTP'
|
|
188
|
+
traces[2]['RemoteHost'].must_equal '127.0.0.1'
|
|
189
|
+
traces[2]['ServiceArg'].must_equal '/?q=1'
|
|
190
|
+
traces[2]['HTTPMethod'].must_equal 'GET'
|
|
191
|
+
|
|
192
|
+
traces[6]['Layer'].must_equal 'excon'
|
|
193
|
+
traces[6]['Label'].must_equal 'exit'
|
|
194
|
+
traces[6]['HTTPStatus'].must_equal 200
|
|
195
|
+
|
|
196
|
+
traces[7]['Layer'].must_equal 'faraday'
|
|
197
|
+
traces[7]['Label'].must_equal 'info'
|
|
198
|
+
unless RUBY_VERSION < '1.9.3'
|
|
199
|
+
# FIXME: Ruby 1.8 is reporting an object instance instead of
|
|
200
|
+
# an array
|
|
201
|
+
traces[7]['Middleware'].must_equal '[Faraday::Adapter::Excon]'
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
traces[8]['Layer'].must_equal 'faraday'
|
|
205
|
+
traces[8]['Label'].must_equal 'exit'
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it 'should obey :collect_backtraces setting when true' do
|
|
209
|
+
TraceView::Config[:faraday][:collect_backtraces] = true
|
|
210
|
+
|
|
211
|
+
TraceView::API.start_trace('faraday_test') do
|
|
212
|
+
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
|
213
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
|
214
|
+
end
|
|
215
|
+
conn.get '/?q=ruby_test_suite'
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
traces = get_all_traces
|
|
219
|
+
layer_has_key(traces, 'faraday', 'Backtrace')
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it 'should obey :collect_backtraces setting when false' do
|
|
223
|
+
TraceView::Config[:faraday][:collect_backtraces] = false
|
|
224
|
+
|
|
225
|
+
TraceView::API.start_trace('faraday_test') do
|
|
226
|
+
conn = Faraday.new(:url => 'http://127.0.0.1:8101') do |faraday|
|
|
227
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
|
228
|
+
end
|
|
229
|
+
conn.get '/?q=ruby_test_suite'
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
traces = get_all_traces
|
|
233
|
+
layer_doesnt_have_key(traces, 'faraday', 'Backtrace')
|
|
234
|
+
end
|
|
235
|
+
end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
require 'minitest_helper'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
|
|
4
|
+
describe "Net::HTTP" do
|
|
5
|
+
before do
|
|
6
|
+
clear_all_traces
|
|
7
|
+
@collect_backtraces = TraceView::Config[:nethttp][:collect_backtraces]
|
|
8
|
+
@log_args = TraceView::Config[:nethttp][:log_args]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
after do
|
|
12
|
+
TraceView::Config[:nethttp][:collect_backtraces] = @collect_backtraces
|
|
13
|
+
TraceView::Config[:nethttp][:log_args] = @log_args
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'Net::HTTP should be defined and ready' do
|
|
17
|
+
defined?(::Net::HTTP).wont_match nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'Net::HTTP should have traceview methods defined' do
|
|
21
|
+
[ :request_with_traceview ].each do |m|
|
|
22
|
+
::Net::HTTP.method_defined?(m).must_equal true
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should trace a Net::HTTP request to an instr'd app" do
|
|
27
|
+
TraceView::API.start_trace('net-http_test', '', {}) do
|
|
28
|
+
uri = URI('http://127.0.0.1:8101/?q=1')
|
|
29
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
30
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
|
31
|
+
response = http.request(request)
|
|
32
|
+
# The HTTP response should have an X-Trace header inside of it
|
|
33
|
+
response["x-trace"].wont_match nil
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
traces = get_all_traces
|
|
37
|
+
traces.count.must_equal 8
|
|
38
|
+
valid_edges?(traces).must_equal true
|
|
39
|
+
validate_outer_layers(traces, 'net-http_test')
|
|
40
|
+
|
|
41
|
+
traces[1]['Layer'].must_equal 'net-http'
|
|
42
|
+
traces[1]['Label'].must_equal 'entry'
|
|
43
|
+
|
|
44
|
+
traces[2]['Layer'].must_equal 'rack'
|
|
45
|
+
traces[2]['Label'].must_equal 'entry'
|
|
46
|
+
|
|
47
|
+
traces[3]['Layer'].must_equal 'rack'
|
|
48
|
+
traces[3]['Label'].must_equal 'info'
|
|
49
|
+
|
|
50
|
+
traces[4]['Layer'].must_equal 'rack'
|
|
51
|
+
traces[4]['Label'].must_equal 'exit'
|
|
52
|
+
|
|
53
|
+
traces[5]['IsService'].must_equal 1
|
|
54
|
+
traces[5]['RemoteProtocol'].must_equal "HTTP"
|
|
55
|
+
traces[5]['RemoteHost'].must_equal "127.0.0.1:8101"
|
|
56
|
+
traces[5]['ServiceArg'].must_equal "/?q=1"
|
|
57
|
+
traces[5]['HTTPMethod'].must_equal "GET"
|
|
58
|
+
traces[5]['HTTPStatus'].must_equal "200"
|
|
59
|
+
traces[5].has_key?('Backtrace').must_equal TraceView::Config[:nethttp][:collect_backtraces]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should trace a GET request" do
|
|
63
|
+
TraceView::API.start_trace('net-http_test', '', {}) do
|
|
64
|
+
uri = URI('http://127.0.0.1:8101/')
|
|
65
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
66
|
+
http.get('/?q=1').read_body
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
traces = get_all_traces
|
|
70
|
+
traces.count.must_equal 8
|
|
71
|
+
valid_edges?(traces).must_equal true
|
|
72
|
+
|
|
73
|
+
validate_outer_layers(traces, 'net-http_test')
|
|
74
|
+
|
|
75
|
+
traces[1]['Layer'].must_equal 'net-http'
|
|
76
|
+
traces[5]['IsService'].must_equal 1
|
|
77
|
+
traces[5]['RemoteProtocol'].must_equal "HTTP"
|
|
78
|
+
traces[5]['RemoteHost'].must_equal "127.0.0.1:8101"
|
|
79
|
+
traces[5]['ServiceArg'].must_equal "/?q=1"
|
|
80
|
+
traces[5]['HTTPMethod'].must_equal "GET"
|
|
81
|
+
traces[5]['HTTPStatus'].must_equal "200"
|
|
82
|
+
traces[5].has_key?('Backtrace').must_equal TraceView::Config[:nethttp][:collect_backtraces]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should obey :log_args setting when true" do
|
|
86
|
+
TraceView::Config[:nethttp][:log_args] = true
|
|
87
|
+
|
|
88
|
+
TraceView::API.start_trace('nethttp_test', '', {}) do
|
|
89
|
+
uri = URI('http://127.0.0.1:8101/')
|
|
90
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
91
|
+
http.use_ssl = false
|
|
92
|
+
http.get('/?q=ruby_test_suite').read_body
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
traces = get_all_traces
|
|
96
|
+
traces[5]['ServiceArg'].must_equal '/?q=ruby_test_suite'
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "should obey :log_args setting when false" do
|
|
100
|
+
TraceView::Config[:nethttp][:log_args] = false
|
|
101
|
+
|
|
102
|
+
TraceView::API.start_trace('nethttp_test', '', {}) do
|
|
103
|
+
uri = URI('http://127.0.0.1:8101/')
|
|
104
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
105
|
+
http.use_ssl = false
|
|
106
|
+
http.get('/?q=ruby_test_suite').read_body
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
traces = get_all_traces
|
|
110
|
+
traces[5]['ServiceArg'].must_equal '/'
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "should obey :collect_backtraces setting when true" do
|
|
114
|
+
TraceView::Config[:nethttp][:collect_backtraces] = true
|
|
115
|
+
|
|
116
|
+
TraceView::API.start_trace('nethttp_test', '', {}) do
|
|
117
|
+
uri = URI('http://127.0.0.1:8101/')
|
|
118
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
119
|
+
http.use_ssl = false
|
|
120
|
+
http.get('/?q=ruby_test_suite').read_body
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
traces = get_all_traces
|
|
124
|
+
layer_has_key(traces, 'net-http', 'Backtrace')
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "should obey :collect_backtraces setting when false" do
|
|
128
|
+
TraceView::Config[:nethttp][:collect_backtraces] = false
|
|
129
|
+
|
|
130
|
+
TraceView::API.start_trace('nethttp_test', '', {}) do
|
|
131
|
+
uri = URI('http://127.0.0.1:8101/')
|
|
132
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
133
|
+
http.use_ssl = false
|
|
134
|
+
http.get('/?q=ruby_test_suite').read_body
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
traces = get_all_traces
|
|
138
|
+
layer_doesnt_have_key(traces, 'net-http', 'Backtrace')
|
|
139
|
+
end
|
|
140
|
+
end
|