oboe 2.7.15.1-java → 2.7.16.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +15 -2
- data/Rakefile +1 -4
- data/lib/oboe/config.rb +6 -3
- data/lib/oboe/inst/excon.rb +110 -0
- data/lib/oboe/inst/faraday.rb +3 -2
- data/lib/oboe/inst/http.rb +10 -5
- data/lib/oboe/inst/rest-client.rb +38 -0
- data/lib/oboe/inst/sequel.rb +3 -0
- data/lib/oboe/inst/typhoeus.rb +5 -2
- data/lib/oboe/ruby.rb +7 -2
- data/lib/oboe/util.rb +27 -9
- data/lib/oboe/version.rb +1 -1
- data/lib/oboe/xtrace.rb +42 -0
- data/test/instrumentation/excon_test.rb +170 -0
- data/test/instrumentation/faraday_test.rb +20 -7
- data/test/instrumentation/http_test.rb +5 -0
- data/test/instrumentation/rest-client_test.rb +302 -0
- data/test/instrumentation/typhoeus_test.rb +90 -132
- data/test/minitest_helper.rb +38 -0
- data/test/servers/rackapp_8101.rb +22 -0
- data/test/support/config_test.rb +7 -1
- metadata +10 -2
data/lib/oboe/xtrace.rb
CHANGED
@@ -43,6 +43,48 @@ module Oboe
|
|
43
43
|
Oboe.logger.debug e.backtrace
|
44
44
|
return nil
|
45
45
|
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Oboe::XTrace.edge_id
|
49
|
+
#
|
50
|
+
# Extract and return the edge_id portion of an X-Trace ID
|
51
|
+
#
|
52
|
+
def edge_id(xtrace)
|
53
|
+
return nil unless Oboe::XTrace.valid?(xtrace)
|
54
|
+
|
55
|
+
xtrace[42..57]
|
56
|
+
rescue StandardError => e
|
57
|
+
Oboe.logger.debug e.message
|
58
|
+
Oboe.logger.debug e.backtrace
|
59
|
+
return nil
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# continue_service_context
|
64
|
+
#
|
65
|
+
# In the case of service calls such as external HTTP requests, we
|
66
|
+
# pass along X-Trace headers so that request context can be maintained
|
67
|
+
# across servers and applications.
|
68
|
+
#
|
69
|
+
# Remote requests can return a X-Trace header in which case we want
|
70
|
+
# to pickup on and continue the context in most cases.
|
71
|
+
#
|
72
|
+
# @start is the context just before the outgoing request
|
73
|
+
#
|
74
|
+
# @finish is the context returned to us (as an HTTP response header
|
75
|
+
# if that be the case)
|
76
|
+
#
|
77
|
+
def continue_service_context(start, finish)
|
78
|
+
if Oboe::XTrace.valid?(finish) && Oboe.tracing?
|
79
|
+
|
80
|
+
# Assure that we received back a valid X-Trace with the same task_id
|
81
|
+
if Oboe::XTrace.task_id(start) == Oboe::XTrace.task_id(finish)
|
82
|
+
Oboe::Context.fromString(finish)
|
83
|
+
else
|
84
|
+
Oboe.logger.debug "Mismatched returned X-Trace ID: #{finish}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
46
88
|
end
|
47
89
|
end
|
48
90
|
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
require 'oboe/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 Oboe::XTrace.valid?(xtrace)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_reports_version_init
|
21
|
+
init_kvs = ::Oboe::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
|
+
Oboe::API.start_trace('excon_tests') do
|
30
|
+
response = 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
|
+
Oboe::API.start_trace('excon_tests') do
|
54
|
+
response = Excon.get('http://www.gameface.in/gamers')
|
55
|
+
xtrace = response.headers['X-Trace']
|
56
|
+
assert xtrace
|
57
|
+
assert Oboe::XTrace.valid?(xtrace)
|
58
|
+
end
|
59
|
+
|
60
|
+
traces = get_all_traces
|
61
|
+
assert_equal traces.count, 4
|
62
|
+
validate_outer_layers(traces, "excon_tests")
|
63
|
+
|
64
|
+
assert_equal traces[1]['IsService'], 1
|
65
|
+
assert_equal traces[1]['RemoteHost'], 'www.gameface.in'
|
66
|
+
assert_equal traces[1]['RemoteProtocol'], 'HTTP'
|
67
|
+
assert_equal traces[1]['ServiceArg'], '/gamers'
|
68
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
69
|
+
assert traces[1].key?('Backtrace')
|
70
|
+
assert_equal traces[2]['HTTPStatus'], 200
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_persistent_requests
|
74
|
+
# Persistence was adding in 0.31.0
|
75
|
+
skip if Excon::VERSION < '0.31.0'
|
76
|
+
|
77
|
+
clear_all_traces
|
78
|
+
|
79
|
+
Oboe::API.start_trace('excon_tests') do
|
80
|
+
connection = Excon.new('http://www.gameface.in/') # non-persistent by default
|
81
|
+
connection.get # socket established, then closed
|
82
|
+
connection.get(:persistent => true) # socket established, left open
|
83
|
+
connection.get # socket reused, then closed
|
84
|
+
end
|
85
|
+
|
86
|
+
traces = get_all_traces
|
87
|
+
assert_equal traces.count, 8
|
88
|
+
validate_outer_layers(traces, "excon_tests")
|
89
|
+
|
90
|
+
assert_equal traces[1]['IsService'], 1
|
91
|
+
assert_equal traces[1]['RemoteHost'], 'www.gameface.in'
|
92
|
+
assert_equal traces[1]['RemoteProtocol'], 'HTTP'
|
93
|
+
assert_equal traces[1]['ServiceArg'], '/'
|
94
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
95
|
+
assert traces[1].key?('Backtrace')
|
96
|
+
assert_equal traces[2]['HTTPStatus'], 200
|
97
|
+
|
98
|
+
assert_equal traces[3]['IsService'], 1
|
99
|
+
assert_equal traces[3]['RemoteHost'], 'www.gameface.in'
|
100
|
+
assert_equal traces[3]['RemoteProtocol'], 'HTTP'
|
101
|
+
assert_equal traces[3]['ServiceArg'], '/'
|
102
|
+
assert_equal traces[3]['HTTPMethod'], 'GET'
|
103
|
+
assert traces[3].key?('Backtrace')
|
104
|
+
assert_equal traces[4]['HTTPStatus'], 200
|
105
|
+
|
106
|
+
assert_equal traces[5]['IsService'], 1
|
107
|
+
assert_equal traces[5]['RemoteHost'], 'www.gameface.in'
|
108
|
+
assert_equal traces[5]['RemoteProtocol'], 'HTTP'
|
109
|
+
assert_equal traces[5]['ServiceArg'], '/'
|
110
|
+
assert_equal traces[5]['HTTPMethod'], 'GET'
|
111
|
+
assert traces[5].key?('Backtrace')
|
112
|
+
assert_equal traces[6]['HTTPStatus'], 200
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_pipelined_requests
|
116
|
+
skip if Excon::VERSION <= '0.17.0'
|
117
|
+
|
118
|
+
clear_all_traces
|
119
|
+
|
120
|
+
Oboe::API.start_trace('excon_tests') do
|
121
|
+
connection = Excon.new('http://www.gameface.in/')
|
122
|
+
connection.requests([{:method => :get}, {:method => :put}])
|
123
|
+
end
|
124
|
+
|
125
|
+
traces = get_all_traces
|
126
|
+
assert_equal traces.count, 4
|
127
|
+
validate_outer_layers(traces, "excon_tests")
|
128
|
+
valid_edges?(traces)
|
129
|
+
|
130
|
+
assert_equal traces[1]['IsService'], 1
|
131
|
+
assert_equal traces[1]['RemoteHost'], 'www.gameface.in'
|
132
|
+
assert_equal traces[1]['RemoteProtocol'], 'HTTP'
|
133
|
+
assert_equal traces[1]['ServiceArg'], '/'
|
134
|
+
assert_equal traces[1]['Pipeline'], 'true'
|
135
|
+
assert_equal traces[1]['HTTPMethods'], 'GET, PUT'
|
136
|
+
assert traces[1].key?('Backtrace')
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_requests_with_errors
|
140
|
+
clear_all_traces
|
141
|
+
|
142
|
+
begin
|
143
|
+
Oboe::API.start_trace('excon_tests') do
|
144
|
+
connection = Excon.get('http://asfjalkfjlajfljkaljf/')
|
145
|
+
end
|
146
|
+
rescue
|
147
|
+
end
|
148
|
+
|
149
|
+
traces = get_all_traces
|
150
|
+
assert_equal traces.count, 5
|
151
|
+
validate_outer_layers(traces, "excon_tests")
|
152
|
+
|
153
|
+
assert_equal traces[1]['IsService'], 1
|
154
|
+
assert_equal traces[1]['RemoteHost'], 'asfjalkfjlajfljkaljf'
|
155
|
+
assert_equal traces[1]['RemoteProtocol'], 'HTTP'
|
156
|
+
assert_equal traces[1]['ServiceArg'], '/'
|
157
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
158
|
+
assert traces[1].key?('Backtrace')
|
159
|
+
|
160
|
+
assert_equal traces[2]['Layer'], 'excon'
|
161
|
+
assert_equal traces[2]['Label'], 'error'
|
162
|
+
assert_equal traces[2]['ErrorClass'], "Excon::Errors::SocketError"
|
163
|
+
assert traces[2].key?('ErrorMsg')
|
164
|
+
assert traces[2].key?('Backtrace')
|
165
|
+
|
166
|
+
assert_equal traces[3]['Layer'], 'excon'
|
167
|
+
assert_equal traces[3]['Label'], 'exit'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
@@ -63,6 +63,7 @@ describe Oboe::Inst::FaradayConnection do
|
|
63
63
|
traces = get_all_traces
|
64
64
|
traces.count.must_equal 8
|
65
65
|
|
66
|
+
valid_edges?(traces)
|
66
67
|
validate_outer_layers(traces, 'faraday_test')
|
67
68
|
|
68
69
|
traces[1]['Layer'].must_equal 'faraday'
|
@@ -94,6 +95,7 @@ describe Oboe::Inst::FaradayConnection do
|
|
94
95
|
traces = get_all_traces
|
95
96
|
traces.count.must_equal 8
|
96
97
|
|
98
|
+
valid_edges?(traces)
|
97
99
|
validate_outer_layers(traces, 'faraday_test')
|
98
100
|
|
99
101
|
traces[1]['Layer'].must_equal 'faraday'
|
@@ -126,25 +128,36 @@ describe Oboe::Inst::FaradayConnection do
|
|
126
128
|
end
|
127
129
|
|
128
130
|
traces = get_all_traces
|
129
|
-
traces.count.must_equal
|
131
|
+
traces.count.must_equal 7
|
130
132
|
|
133
|
+
valid_edges?(traces)
|
131
134
|
validate_outer_layers(traces, 'faraday_test')
|
132
135
|
|
133
136
|
traces[1]['Layer'].must_equal 'faraday'
|
134
137
|
traces[1].key?('Backtrace').must_equal Oboe::Config[:faraday][:collect_backtraces]
|
135
138
|
|
139
|
+
traces[2]['Layer'].must_equal 'excon'
|
140
|
+
traces[2]['Label'].must_equal 'entry'
|
136
141
|
traces[2]['IsService'].must_equal 1
|
137
142
|
traces[2]['RemoteProtocol'].must_equal 'HTTP'
|
138
143
|
traces[2]['RemoteHost'].must_equal 'www.curlmyip.de'
|
139
144
|
traces[2]['ServiceArg'].must_equal '/?q=1'
|
140
|
-
traces[2]['HTTPMethod'].
|
145
|
+
traces[2]['HTTPMethod'].must_equal 'GET'
|
141
146
|
|
142
|
-
traces[
|
143
|
-
traces[2]['Label'].must_equal 'info'
|
144
|
-
traces[2]['HTTPStatus'].must_equal 200
|
145
|
-
|
146
|
-
traces[3]['Layer'].must_equal 'faraday'
|
147
|
+
traces[3]['Layer'].must_equal 'excon'
|
147
148
|
traces[3]['Label'].must_equal 'exit'
|
149
|
+
traces[3]['HTTPStatus'].must_equal 200
|
150
|
+
|
151
|
+
traces[4]['Layer'].must_equal 'faraday'
|
152
|
+
traces[4]['Label'].must_equal 'info'
|
153
|
+
unless RUBY_VERSION < '1.9.3'
|
154
|
+
# FIXME: Ruby 1.8 is reporting an object instance instead of
|
155
|
+
# an array
|
156
|
+
traces[4]['Middleware'].must_equal '[Faraday::Adapter::Excon]'
|
157
|
+
end
|
158
|
+
|
159
|
+
traces[5]['Layer'].must_equal 'faraday'
|
160
|
+
traces[5]['Label'].must_equal 'exit'
|
148
161
|
end
|
149
162
|
|
150
163
|
it 'should obey :collect_backtraces setting when true' do
|
@@ -34,6 +34,10 @@ describe Oboe::Inst do
|
|
34
34
|
traces = get_all_traces
|
35
35
|
traces.count.must_equal 5
|
36
36
|
|
37
|
+
# FIXME: We need to switch from making external calls to an internal test
|
38
|
+
# stack instead so we can validate cross-app traces.
|
39
|
+
# valid_edges?(traces).must_equal true
|
40
|
+
|
37
41
|
validate_outer_layers(traces, 'net-http_test')
|
38
42
|
|
39
43
|
traces[1]['Layer'].must_equal 'net-http'
|
@@ -55,6 +59,7 @@ describe Oboe::Inst do
|
|
55
59
|
|
56
60
|
traces = get_all_traces
|
57
61
|
traces.count.must_equal 5
|
62
|
+
valid_edges?(traces).must_equal true
|
58
63
|
|
59
64
|
validate_outer_layers(traces, 'net-http_test')
|
60
65
|
|
@@ -0,0 +1,302 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
if RUBY_VERSION >= '1.9.3'
|
4
|
+
describe Oboe::Inst::RestClientRequest do
|
5
|
+
before do
|
6
|
+
clear_all_traces
|
7
|
+
@collect_backtraces = Oboe::Config[:rest_client][:collect_backtraces]
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
Oboe::Config[:rest_client][:collect_backtraces] = @collect_backtraces
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'RestClient should be defined and ready' do
|
15
|
+
defined?(::RestClient).wont_match nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'RestClient should have oboe methods defined' do
|
19
|
+
[ :execute_with_oboe ].each do |m|
|
20
|
+
::RestClient::Request.method_defined?(m).must_equal true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should report rest-client version in __Init" do
|
25
|
+
init_kvs = ::Oboe::Util.build_init_report
|
26
|
+
|
27
|
+
init_kvs.key?('Ruby.RestClient.Version').must_equal true
|
28
|
+
init_kvs['Ruby.RestClient.Version'].must_equal "RestClient-#{::RestClient::VERSION}"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should trace a request to an instr'd app" do
|
32
|
+
response = nil
|
33
|
+
|
34
|
+
Oboe::API.start_trace('rest_client_test') do
|
35
|
+
response = RestClient.get 'http://gameface.in/gamers'
|
36
|
+
end
|
37
|
+
|
38
|
+
traces = get_all_traces
|
39
|
+
traces.count.must_equal 7
|
40
|
+
|
41
|
+
# FIXME: We need to switch from making external calls to an internal test
|
42
|
+
# stack instead so we can validate cross-app traces.
|
43
|
+
# valid_edges?(traces).must_equal true
|
44
|
+
validate_outer_layers(traces, 'rest_client_test')
|
45
|
+
|
46
|
+
traces[1]['Layer'].must_equal 'rest-client'
|
47
|
+
traces[1]['Label'].must_equal 'entry'
|
48
|
+
|
49
|
+
traces[2]['Layer'].must_equal 'net-http'
|
50
|
+
traces[2]['Label'].must_equal 'entry'
|
51
|
+
|
52
|
+
traces[3]['Layer'].must_equal 'net-http'
|
53
|
+
traces[3]['Label'].must_equal 'info'
|
54
|
+
traces[3]['IsService'].must_equal 1
|
55
|
+
traces[3]['RemoteProtocol'].must_equal 'HTTP'
|
56
|
+
traces[3]['RemoteHost'].must_equal 'gameface.in'
|
57
|
+
traces[3]['ServiceArg'].must_equal '/gamers'
|
58
|
+
traces[3]['HTTPMethod'].must_equal 'GET'
|
59
|
+
traces[3]['HTTPStatus'].must_equal "200"
|
60
|
+
traces[3].key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
|
61
|
+
|
62
|
+
traces[4]['Layer'].must_equal 'net-http'
|
63
|
+
traces[4]['Label'].must_equal 'exit'
|
64
|
+
|
65
|
+
traces[5]['Layer'].must_equal 'rest-client'
|
66
|
+
traces[5]['Label'].must_equal 'exit'
|
67
|
+
|
68
|
+
response.headers.key?(:x_trace).wont_equal nil
|
69
|
+
xtrace = response.headers[:x_trace]
|
70
|
+
Oboe::XTrace.valid?(xtrace).must_equal true
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should trace a raw GET request' do
|
74
|
+
response = nil
|
75
|
+
|
76
|
+
Oboe::API.start_trace('rest_client_test') do
|
77
|
+
response = RestClient.get 'http://www.appneta.com/products/traceview/?a=1'
|
78
|
+
end
|
79
|
+
|
80
|
+
traces = get_all_traces
|
81
|
+
traces.count.must_equal 7
|
82
|
+
|
83
|
+
# FIXME: We need to switch from making external calls to an internal test
|
84
|
+
# stack instead so we can validate cross-app traces.
|
85
|
+
# valid_edges?(traces).must_equal true
|
86
|
+
validate_outer_layers(traces, 'rest_client_test')
|
87
|
+
|
88
|
+
traces[1]['Layer'].must_equal 'rest-client'
|
89
|
+
traces[1]['Label'].must_equal 'entry'
|
90
|
+
|
91
|
+
traces[2]['Layer'].must_equal 'net-http'
|
92
|
+
traces[2]['Label'].must_equal 'entry'
|
93
|
+
|
94
|
+
traces[3]['Layer'].must_equal 'net-http'
|
95
|
+
traces[3]['Label'].must_equal 'info'
|
96
|
+
traces[3]['IsService'].must_equal 1
|
97
|
+
traces[3]['RemoteProtocol'].must_equal 'HTTP'
|
98
|
+
traces[3]['RemoteHost'].must_equal 'www.appneta.com'
|
99
|
+
traces[3]['ServiceArg'].must_equal '/products/traceview/?a=1'
|
100
|
+
traces[3]['HTTPMethod'].must_equal 'GET'
|
101
|
+
traces[3]['HTTPStatus'].must_equal "200"
|
102
|
+
traces[3].key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
|
103
|
+
|
104
|
+
traces[4]['Layer'].must_equal 'net-http'
|
105
|
+
traces[4]['Label'].must_equal 'exit'
|
106
|
+
|
107
|
+
traces[5]['Layer'].must_equal 'rest-client'
|
108
|
+
traces[5]['Label'].must_equal 'exit'
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should trace a raw POST request' do
|
112
|
+
response = nil
|
113
|
+
|
114
|
+
Oboe::API.start_trace('rest_client_test') do
|
115
|
+
response = RestClient.post 'http://www.appneta.com/', :param1 => 'one', :nested => { :param2 => 'two' }
|
116
|
+
end
|
117
|
+
|
118
|
+
traces = get_all_traces
|
119
|
+
traces.count.must_equal 7
|
120
|
+
|
121
|
+
# FIXME: We need to switch from making external calls to an internal test
|
122
|
+
# stack instead so we can validate cross-app traces.
|
123
|
+
# valid_edges?(traces).must_equal true
|
124
|
+
validate_outer_layers(traces, 'rest_client_test')
|
125
|
+
|
126
|
+
traces[1]['Layer'].must_equal 'rest-client'
|
127
|
+
traces[1]['Label'].must_equal 'entry'
|
128
|
+
|
129
|
+
traces[2]['Layer'].must_equal 'net-http'
|
130
|
+
traces[2]['Label'].must_equal 'entry'
|
131
|
+
|
132
|
+
traces[3]['Layer'].must_equal 'net-http'
|
133
|
+
traces[3]['Label'].must_equal 'info'
|
134
|
+
traces[3]['IsService'].must_equal 1
|
135
|
+
traces[3]['RemoteProtocol'].must_equal 'HTTP'
|
136
|
+
traces[3]['RemoteHost'].must_equal 'www.appneta.com'
|
137
|
+
traces[3]['ServiceArg'].must_equal '/'
|
138
|
+
traces[3]['HTTPMethod'].must_equal 'POST'
|
139
|
+
traces[3]['HTTPStatus'].must_equal "200"
|
140
|
+
traces[3].key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
|
141
|
+
|
142
|
+
traces[4]['Layer'].must_equal 'net-http'
|
143
|
+
traces[4]['Label'].must_equal 'exit'
|
144
|
+
|
145
|
+
traces[5]['Layer'].must_equal 'rest-client'
|
146
|
+
traces[5]['Label'].must_equal 'exit'
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should trace a ActiveResource style GET request' do
|
150
|
+
response = nil
|
151
|
+
|
152
|
+
Oboe::API.start_trace('rest_client_test') do
|
153
|
+
resource = RestClient::Resource.new 'http://www.appneta.com/products/traceview/?a=1'
|
154
|
+
response = resource.get
|
155
|
+
end
|
156
|
+
|
157
|
+
traces = get_all_traces
|
158
|
+
traces.count.must_equal 7
|
159
|
+
|
160
|
+
# FIXME: We need to switch from making external calls to an internal test
|
161
|
+
# stack instead so we can validate cross-app traces.
|
162
|
+
# valid_edges?(traces).must_equal true
|
163
|
+
validate_outer_layers(traces, 'rest_client_test')
|
164
|
+
|
165
|
+
traces[1]['Layer'].must_equal 'rest-client'
|
166
|
+
traces[1]['Label'].must_equal 'entry'
|
167
|
+
|
168
|
+
traces[2]['Layer'].must_equal 'net-http'
|
169
|
+
traces[2]['Label'].must_equal 'entry'
|
170
|
+
|
171
|
+
traces[3]['Layer'].must_equal 'net-http'
|
172
|
+
traces[3]['Label'].must_equal 'info'
|
173
|
+
traces[3]['IsService'].must_equal 1
|
174
|
+
traces[3]['RemoteProtocol'].must_equal 'HTTP'
|
175
|
+
traces[3]['RemoteHost'].must_equal 'www.appneta.com'
|
176
|
+
traces[3]['ServiceArg'].must_equal '/products/traceview/?a=1'
|
177
|
+
traces[3]['HTTPMethod'].must_equal 'GET'
|
178
|
+
traces[3]['HTTPStatus'].must_equal "200"
|
179
|
+
traces[3].key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
|
180
|
+
|
181
|
+
traces[4]['Layer'].must_equal 'net-http'
|
182
|
+
traces[4]['Label'].must_equal 'exit'
|
183
|
+
|
184
|
+
traces[5]['Layer'].must_equal 'rest-client'
|
185
|
+
traces[5]['Label'].must_equal 'exit'
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should trace requests with redirects' do
|
189
|
+
response = nil
|
190
|
+
|
191
|
+
Oboe::API.start_trace('rest_client_test') do
|
192
|
+
resource = RestClient::Resource.new 'http://www.appneta.com/products/traceview?a=1'
|
193
|
+
response = resource.get
|
194
|
+
end
|
195
|
+
|
196
|
+
traces = get_all_traces
|
197
|
+
traces.count.must_equal 12
|
198
|
+
|
199
|
+
# FIXME: We need to switch from making external calls to an internal test
|
200
|
+
# stack instead so we can validate cross-app traces.
|
201
|
+
# valid_edges?(traces).must_equal true
|
202
|
+
validate_outer_layers(traces, 'rest_client_test')
|
203
|
+
|
204
|
+
traces[1]['Layer'].must_equal 'rest-client'
|
205
|
+
traces[1]['Label'].must_equal 'entry'
|
206
|
+
|
207
|
+
traces[2]['Layer'].must_equal 'net-http'
|
208
|
+
traces[2]['Label'].must_equal 'entry'
|
209
|
+
|
210
|
+
traces[3]['Layer'].must_equal 'net-http'
|
211
|
+
traces[3]['Label'].must_equal 'info'
|
212
|
+
traces[3]['IsService'].must_equal 1
|
213
|
+
traces[3]['RemoteProtocol'].must_equal 'HTTP'
|
214
|
+
traces[3]['RemoteHost'].must_equal 'www.appneta.com'
|
215
|
+
traces[3]['ServiceArg'].must_equal '/products/traceview?a=1'
|
216
|
+
traces[3]['HTTPMethod'].must_equal 'GET'
|
217
|
+
traces[3]['HTTPStatus'].must_equal "301"
|
218
|
+
traces[3].key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
|
219
|
+
|
220
|
+
traces[4]['Layer'].must_equal 'net-http'
|
221
|
+
traces[4]['Label'].must_equal 'exit'
|
222
|
+
|
223
|
+
traces[5]['Layer'].must_equal 'rest-client'
|
224
|
+
traces[5]['Label'].must_equal 'entry'
|
225
|
+
|
226
|
+
traces[6]['Layer'].must_equal 'net-http'
|
227
|
+
traces[6]['Label'].must_equal 'entry'
|
228
|
+
|
229
|
+
traces[7]['Layer'].must_equal 'net-http'
|
230
|
+
traces[7]['Label'].must_equal 'info'
|
231
|
+
traces[7]['IsService'].must_equal 1
|
232
|
+
traces[7]['RemoteProtocol'].must_equal 'HTTP'
|
233
|
+
traces[7]['RemoteHost'].must_equal 'www.appneta.com'
|
234
|
+
traces[7]['ServiceArg'].must_equal '/products/traceview/?a=1'
|
235
|
+
traces[7]['HTTPMethod'].must_equal 'GET'
|
236
|
+
traces[7]['HTTPStatus'].must_equal "200"
|
237
|
+
traces[7].key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
|
238
|
+
|
239
|
+
traces[8]['Layer'].must_equal 'net-http'
|
240
|
+
traces[8]['Label'].must_equal 'exit'
|
241
|
+
|
242
|
+
traces[9]['Layer'].must_equal 'rest-client'
|
243
|
+
traces[9]['Label'].must_equal 'exit'
|
244
|
+
|
245
|
+
traces[10]['Layer'].must_equal 'rest-client'
|
246
|
+
traces[10]['Label'].must_equal 'exit'
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'should trace and capture raised exceptions' do
|
250
|
+
response = nil
|
251
|
+
|
252
|
+
Oboe::API.start_trace('rest_client_test') do
|
253
|
+
begin
|
254
|
+
RestClient.get 'http://s6KTgaz7636z/resource'
|
255
|
+
rescue
|
256
|
+
# We want an exception to be raised. Just don't raise
|
257
|
+
# it beyond this point.
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
traces = get_all_traces
|
262
|
+
traces.count.must_equal 5
|
263
|
+
|
264
|
+
valid_edges?(traces).must_equal true
|
265
|
+
validate_outer_layers(traces, 'rest_client_test')
|
266
|
+
|
267
|
+
traces[1]['Layer'].must_equal 'rest-client'
|
268
|
+
traces[1]['Label'].must_equal 'entry'
|
269
|
+
|
270
|
+
traces[2]['Layer'].must_equal 'rest-client'
|
271
|
+
traces[2]['Label'].must_equal 'error'
|
272
|
+
traces[2]['ErrorClass'].must_equal 'SocketError'
|
273
|
+
traces[2].key?('ErrorMsg').must_equal true
|
274
|
+
traces[2].key?('Backtrace').must_equal true
|
275
|
+
|
276
|
+
traces[3]['Layer'].must_equal 'rest-client'
|
277
|
+
traces[3]['Label'].must_equal 'exit'
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'should obey :collect_backtraces setting when true' do
|
281
|
+
Oboe::Config[:rest_client][:collect_backtraces] = true
|
282
|
+
|
283
|
+
Oboe::API.start_trace('rest_client_test') do
|
284
|
+
RestClient.get('http://www.appneta.com', {:a => 1})
|
285
|
+
end
|
286
|
+
|
287
|
+
traces = get_all_traces
|
288
|
+
layer_has_key(traces, 'rest-client', 'Backtrace')
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'should obey :collect_backtraces setting when false' do
|
292
|
+
Oboe::Config[:rest_client][:collect_backtraces] = false
|
293
|
+
|
294
|
+
Oboe::API.start_trace('rest_client_test') do
|
295
|
+
RestClient.get('http://www.appneta.com', {:a => 1})
|
296
|
+
end
|
297
|
+
|
298
|
+
traces = get_all_traces
|
299
|
+
layer_doesnt_have_key(traces, 'rest-client', 'Backtrace')
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|