oboe 2.7.15.1-java → 2.7.16.1-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.
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
  require 'rack'
3
6
 
@@ -23,214 +26,165 @@ describe Oboe::Inst::TyphoeusRequestOps do
23
26
 
24
27
  it 'should trace a typhoeus request' do
25
28
  Oboe::API.start_trace('typhoeus_test') do
26
- Typhoeus.get("www.appneta.com/products/traceview/")
29
+ Typhoeus.get("http://127.0.0.1:8101/")
27
30
  end
28
31
 
29
32
  traces = get_all_traces
30
- traces.count.must_equal 5
33
+ traces.count.must_equal 8
31
34
 
35
+ valid_edges?(traces).must_equal true
32
36
  validate_outer_layers(traces, 'typhoeus_test')
33
37
 
34
38
  traces[1]['Layer'].must_equal 'typhoeus'
35
39
  traces[1].key?('Backtrace').must_equal Oboe::Config[:typhoeus][:collect_backtraces]
36
40
 
37
- traces[2]['Layer'].must_equal 'typhoeus'
38
- traces[2]['Label'].must_equal 'info'
39
- traces[2]['IsService'].must_equal 1
40
- traces[2]['RemoteProtocol'].downcase.must_equal 'http'
41
- traces[2]['RemoteHost'].must_equal 'www.appneta.com'
42
- traces[2]['ServiceArg'].must_equal '/products/traceview/'
43
- traces[2]['HTTPMethod'].must_equal 'get'
44
- traces[2]['HTTPStatus'].must_equal 200
41
+ traces[5]['Layer'].must_equal 'typhoeus'
42
+ traces[5]['Label'].must_equal 'info'
43
+ traces[5]['IsService'].must_equal 1
44
+ traces[5]['RemoteProtocol'].must_equal 'HTTP'
45
+ traces[5]['RemoteHost'].must_equal '127.0.0.1'
46
+ traces[5]['ServiceArg'].must_equal '/'
47
+ traces[5]['HTTPMethod'].must_equal 'GET'
48
+ traces[5]['HTTPStatus'].must_equal 200
45
49
 
46
- traces[3]['Layer'].must_equal 'typhoeus'
47
- traces[3]['Label'].must_equal 'exit'
50
+ traces[6]['Layer'].must_equal 'typhoeus'
51
+ traces[6]['Label'].must_equal 'exit'
48
52
  end
49
53
 
50
54
  it 'should trace a typhoeus POST request' do
51
55
  Oboe::API.start_trace('typhoeus_test') do
52
- Typhoeus.post("https://internal.tv.appneta.com/api-v2/log_message",
56
+ Typhoeus.post("127.0.0.1:8101/",
53
57
  :body => { :key => "oboe-ruby-fake", :content => "oboe-ruby repo test suite"})
54
58
  end
55
59
 
56
60
  traces = get_all_traces
57
- traces.count.must_equal 5
61
+ traces.count.must_equal 8
58
62
 
63
+ valid_edges?(traces).must_equal true
59
64
  validate_outer_layers(traces, 'typhoeus_test')
60
65
 
61
66
  traces[1]['Layer'].must_equal 'typhoeus'
62
67
  traces[1].key?('Backtrace').must_equal Oboe::Config[:typhoeus][:collect_backtraces]
63
68
 
64
- traces[2]['Layer'].must_equal 'typhoeus'
65
- traces[2]['Label'].must_equal 'info'
66
- traces[2]['IsService'].must_equal 1
67
- traces[2]['RemoteProtocol'].downcase.must_equal 'https'
68
- traces[2]['RemoteHost'].must_equal 'internal.tv.appneta.com'
69
- traces[2]['RemotePort'].must_equal 443
70
- traces[2]['ServiceArg'].must_equal '/api-v2/log_message'
71
- traces[2]['HTTPMethod'].must_equal 'post'
72
- traces[2]['HTTPStatus'].must_equal 302
69
+ traces[5]['Layer'].must_equal 'typhoeus'
70
+ traces[5]['Label'].must_equal 'info'
71
+ traces[5]['IsService'].must_equal 1
72
+ traces[5]['RemoteProtocol'].must_equal 'HTTP'
73
+ traces[5]['RemoteHost'].must_equal '127.0.0.1'
74
+ traces[5]['RemotePort'].must_equal 8101
75
+ traces[5]['ServiceArg'].must_equal '/'
76
+ traces[5]['HTTPMethod'].must_equal 'POST'
77
+ traces[5]['HTTPStatus'].must_equal 200
73
78
 
74
- traces[3]['Layer'].must_equal 'typhoeus'
75
- traces[3]['Label'].must_equal 'exit'
79
+ traces[6]['Layer'].must_equal 'typhoeus'
80
+ traces[6]['Label'].must_equal 'exit'
76
81
  end
77
82
 
78
83
  it 'should trace a typhoeus PUT request' do
79
84
  Oboe::API.start_trace('typhoeus_test') do
80
- Typhoeus.put("https://internal.tv.appneta.com/api-v2/log_message",
85
+ Typhoeus.put("http://127.0.0.1:8101/",
81
86
  :body => { :key => "oboe-ruby-fake", :content => "oboe-ruby repo test suite"})
82
87
  end
83
88
 
84
89
  traces = get_all_traces
85
- traces.count.must_equal 5
90
+ traces.count.must_equal 8
86
91
 
92
+ valid_edges?(traces).must_equal true
87
93
  validate_outer_layers(traces, 'typhoeus_test')
88
94
 
89
95
  traces[1]['Layer'].must_equal 'typhoeus'
90
96
  traces[1].key?('Backtrace').must_equal Oboe::Config[:typhoeus][:collect_backtraces]
91
97
 
92
- traces[2]['Layer'].must_equal 'typhoeus'
93
- traces[2]['Label'].must_equal 'info'
94
- traces[2]['IsService'].must_equal 1
95
- traces[2]['RemoteProtocol'].downcase.must_equal 'https'
96
- traces[2]['RemoteHost'].must_equal 'internal.tv.appneta.com'
97
- traces[2]['RemotePort'].must_equal 443
98
- traces[2]['ServiceArg'].must_equal '/api-v2/log_message'
99
- traces[2]['HTTPMethod'].must_equal 'put'
100
- traces[2]['HTTPStatus'].must_equal 405
98
+ traces[5]['Layer'].must_equal 'typhoeus'
99
+ traces[5]['Label'].must_equal 'info'
100
+ traces[5]['IsService'].must_equal 1
101
+ traces[5]['RemoteProtocol'].must_equal 'HTTP'
102
+ traces[5]['RemoteHost'].must_equal '127.0.0.1'
103
+ traces[5]['RemotePort'].must_equal 8101
104
+ traces[5]['ServiceArg'].must_equal '/'
105
+ traces[5]['HTTPMethod'].must_equal 'PUT'
106
+ traces[5]['HTTPStatus'].must_equal 200
101
107
 
102
- traces[3]['Layer'].must_equal 'typhoeus'
103
- traces[3]['Label'].must_equal 'exit'
108
+ traces[6]['Layer'].must_equal 'typhoeus'
109
+ traces[6]['Label'].must_equal 'exit'
104
110
  end
105
111
 
106
112
  it 'should trace a typhoeus DELETE request' do
107
113
  Oboe::API.start_trace('typhoeus_test') do
108
- Typhoeus.delete("https://internal.tv.appneta.com/api-v2/log_message")
114
+ Typhoeus.delete("http://127.0.0.1:8101/")
109
115
  end
110
116
 
111
117
  traces = get_all_traces
112
- traces.count.must_equal 5
118
+ traces.count.must_equal 8
113
119
 
120
+ valid_edges?(traces).must_equal true
114
121
  validate_outer_layers(traces, 'typhoeus_test')
115
122
 
116
123
  traces[1]['Layer'].must_equal 'typhoeus'
117
124
  traces[1].key?('Backtrace').must_equal Oboe::Config[:typhoeus][:collect_backtraces]
118
125
 
119
- traces[2]['Layer'].must_equal 'typhoeus'
120
- traces[2]['Label'].must_equal 'info'
121
- traces[2]['IsService'].must_equal 1
122
- traces[2]['RemoteProtocol'].downcase.must_equal 'https'
123
- traces[2]['RemoteHost'].must_equal 'internal.tv.appneta.com'
124
- traces[2]['RemotePort'].must_equal 443
125
- traces[2]['ServiceArg'].must_equal '/api-v2/log_message'
126
- traces[2]['HTTPMethod'].must_equal 'delete'
127
- traces[2]['HTTPStatus'].must_equal 405
126
+ traces[5]['Layer'].must_equal 'typhoeus'
127
+ traces[5]['Label'].must_equal 'info'
128
+ traces[5]['IsService'].must_equal 1
129
+ traces[5]['RemoteProtocol'].must_equal 'HTTP'
130
+ traces[5]['RemoteHost'].must_equal '127.0.0.1'
131
+ traces[5]['RemotePort'].must_equal 8101
132
+ traces[5]['ServiceArg'].must_equal '/'
133
+ traces[5]['HTTPMethod'].must_equal 'DELETE'
134
+ traces[5]['HTTPStatus'].must_equal 200
128
135
 
129
- traces[3]['Layer'].must_equal 'typhoeus'
130
- traces[3]['Label'].must_equal 'exit'
136
+ traces[6]['Layer'].must_equal 'typhoeus'
137
+ traces[6]['Label'].must_equal 'exit'
131
138
  end
132
139
 
133
140
  it 'should trace a typhoeus HEAD request' do
134
141
  Oboe::API.start_trace('typhoeus_test') do
135
- Typhoeus.head("http://www.appneta.com/")
142
+ Typhoeus.head("http://127.0.0.1:8101/")
136
143
  end
137
144
 
138
145
  traces = get_all_traces
139
- traces.count.must_equal 5
146
+ traces.count.must_equal 8
140
147
 
148
+ valid_edges?(traces).must_equal true
141
149
  validate_outer_layers(traces, 'typhoeus_test')
142
150
 
143
151
  traces[1]['Layer'].must_equal 'typhoeus'
144
152
  traces[1].key?('Backtrace').must_equal Oboe::Config[:typhoeus][:collect_backtraces]
145
153
 
146
- traces[2]['Layer'].must_equal 'typhoeus'
147
- traces[2]['Label'].must_equal 'info'
148
- traces[2]['IsService'].must_equal 1
149
- traces[2]['RemoteProtocol'].downcase.must_equal 'http'
150
- traces[2]['RemoteHost'].must_equal 'www.appneta.com'
151
- traces[2]['ServiceArg'].must_equal '/'
152
- traces[2]['HTTPMethod'].must_equal 'head'
153
- traces[2]['HTTPStatus'].must_equal 200
154
+ traces[5]['Layer'].must_equal 'typhoeus'
155
+ traces[5]['Label'].must_equal 'info'
156
+ traces[5]['IsService'].must_equal 1
157
+ traces[5]['RemoteProtocol'].must_equal 'HTTP'
158
+ traces[5]['RemoteHost'].must_equal '127.0.0.1'
159
+ traces[5]['ServiceArg'].must_equal '/'
160
+ traces[5]['HTTPMethod'].must_equal 'HEAD'
161
+ traces[5]['HTTPStatus'].must_equal 200
154
162
 
155
- traces[3]['Layer'].must_equal 'typhoeus'
156
- traces[3]['Label'].must_equal 'exit'
163
+ traces[6]['Layer'].must_equal 'typhoeus'
164
+ traces[6]['Label'].must_equal 'exit'
157
165
  end
158
166
 
159
167
  it 'should trace a typhoeus GET request to an instr\'d app' do
160
168
  Oboe::API.start_trace('typhoeus_test') do
161
- Typhoeus.get("www.gameface.in/gamers")
162
- end
163
-
164
- traces = get_all_traces
165
- traces.count.must_equal 5
166
-
167
- validate_outer_layers(traces, 'typhoeus_test')
168
-
169
- traces[1]['Layer'].must_equal 'typhoeus'
170
- traces[1].key?('Backtrace').must_equal Oboe::Config[:typhoeus][:collect_backtraces]
171
-
172
- traces[2]['Layer'].must_equal 'typhoeus'
173
- traces[2]['Label'].must_equal 'info'
174
- traces[2]['IsService'].must_equal 1
175
- traces[2]['RemoteProtocol'].downcase.must_equal 'http'
176
- traces[2]['RemoteHost'].must_equal 'www.gameface.in'
177
- traces[2]['ServiceArg'].must_equal '/gamers'
178
- traces[2]['HTTPMethod'].must_equal 'get'
179
- traces[2]['HTTPStatus'].must_equal 200
180
-
181
- traces[3]['Layer'].must_equal 'typhoeus'
182
- traces[3]['Label'].must_equal 'exit'
183
- end
184
-
185
- it 'should trace a typhoeus GET request to an internal app' do
186
- # TODO: JRuby doesn't trace the inner rack app for some reason...
187
- skip if defined?(JRUBY_VERSION)
188
-
189
- Thread.new do
190
- app = Rack::Builder.new {
191
- use Oboe::Rack
192
- run Proc.new { |env|
193
- [200, {"Content-Type" => "text/html"}, ['Hello, world!']]
194
- }
195
- }
196
-
197
- Rack::Handler::WEBrick.run(app, :Port => 8000)
198
- end
199
-
200
- sleep(1)
201
-
202
- Oboe::API.start_trace('outer') do
203
- res = Typhoeus.get("127.0.0.1:8000/")
169
+ Typhoeus.get("127.0.0.1:8101/")
204
170
  end
205
171
 
206
172
  traces = get_all_traces
207
173
  traces.count.must_equal 8
208
174
 
209
- validate_outer_layers(traces, 'outer')
210
-
211
- #require 'byebug'
212
- #debugger
213
-
214
- traces[2]['Layer'].must_equal 'rack'
215
- traces[2]['Label'].must_equal 'entry'
216
- traces[4]['Layer'].must_equal 'rack'
217
- traces[4]['Label'].must_equal 'exit'
218
-
219
- # Verify typhoeus info edges to inner exit
220
- traces[6]['Edge'].must_equal traces[5]['X-Trace'][42...58]
175
+ valid_edges?(traces).must_equal true
176
+ validate_outer_layers(traces, 'typhoeus_test')
221
177
 
222
- # Verify typhoeus events
223
178
  traces[1]['Layer'].must_equal 'typhoeus'
224
179
  traces[1].key?('Backtrace').must_equal Oboe::Config[:typhoeus][:collect_backtraces]
225
180
 
226
181
  traces[5]['Layer'].must_equal 'typhoeus'
227
182
  traces[5]['Label'].must_equal 'info'
228
183
  traces[5]['IsService'].must_equal 1
229
- traces[5]['RemoteProtocol'].downcase.must_equal 'http'
184
+ traces[5]['RemoteProtocol'].must_equal 'HTTP'
230
185
  traces[5]['RemoteHost'].must_equal '127.0.0.1'
231
- traces[5]['RemotePort'].must_equal 8000
232
186
  traces[5]['ServiceArg'].must_equal '/'
233
- traces[5]['HTTPMethod'].must_equal 'get'
187
+ traces[5]['HTTPMethod'].must_equal 'GET'
234
188
  traces[5]['HTTPStatus'].must_equal 200
235
189
 
236
190
  traces[6]['Layer'].must_equal 'typhoeus'
@@ -245,6 +199,7 @@ describe Oboe::Inst::TyphoeusRequestOps do
245
199
  traces = get_all_traces
246
200
  traces.count.must_equal 6
247
201
 
202
+ valid_edges?(traces).must_equal true
248
203
  validate_outer_layers(traces, 'typhoeus_test')
249
204
 
250
205
  traces[1]['Layer'].must_equal 'typhoeus'
@@ -256,10 +211,10 @@ describe Oboe::Inst::TyphoeusRequestOps do
256
211
  traces[3]['Layer'].must_equal 'typhoeus'
257
212
  traces[3]['Label'].must_equal 'info'
258
213
  traces[3]['IsService'].must_equal 1
259
- traces[3]['RemoteProtocol'].downcase.must_equal 'http'
214
+ traces[3]['RemoteProtocol'].must_equal 'HTTP'
260
215
  traces[3]['RemoteHost'].must_equal 'thisdomaindoesntexisthopefully.asdf'
261
216
  traces[3]['ServiceArg'].must_equal '/products/traceview/'
262
- traces[3]['HTTPMethod'].must_equal 'get'
217
+ traces[3]['HTTPMethod'].must_equal 'GET'
263
218
  traces[3]['HTTPStatus'].must_equal 0
264
219
 
265
220
  traces[3]['Layer'].must_equal 'typhoeus'
@@ -273,9 +228,9 @@ describe Oboe::Inst::TyphoeusRequestOps do
273
228
  Oboe::API.start_trace('typhoeus_test') do
274
229
  hydra = Typhoeus::Hydra.hydra
275
230
 
276
- first_request = Typhoeus::Request.new("www.appneta.com/products/traceview/")
277
- second_request = Typhoeus::Request.new("www.appneta.com/products/")
278
- third_request = Typhoeus::Request.new("www.curlmyip.de")
231
+ first_request = Typhoeus::Request.new("127.0.0.1:8101/products/traceview/")
232
+ second_request = Typhoeus::Request.new("127.0.0.1:8101/products/")
233
+ third_request = Typhoeus::Request.new("127.0.0.1:8101/")
279
234
 
280
235
  hydra.queue first_request
281
236
  hydra.queue second_request
@@ -285,22 +240,25 @@ describe Oboe::Inst::TyphoeusRequestOps do
285
240
  end
286
241
 
287
242
  traces = get_all_traces
288
- traces.count.must_equal 4
243
+ traces.count.must_equal 13
289
244
 
245
+ # FIXME: Until we support async tracing for Typhoeus, this won't
246
+ # work.
247
+ # valid_edges?(traces).must_equal true
290
248
  validate_outer_layers(traces, 'typhoeus_test')
291
249
 
292
250
  traces[1]['Layer'].must_equal 'typhoeus_hydra'
293
251
  traces[1]['Label'].must_equal 'entry'
294
252
 
295
- traces[2]['Layer'].must_equal 'typhoeus_hydra'
296
- traces[2]['Label'].must_equal 'exit'
253
+ traces[11]['Layer'].must_equal 'typhoeus_hydra'
254
+ traces[11]['Label'].must_equal 'exit'
297
255
  end
298
256
 
299
257
  it 'should obey :collect_backtraces setting when true' do
300
258
  Oboe::Config[:typhoeus][:collect_backtraces] = true
301
259
 
302
260
  Oboe::API.start_trace('typhoeus_test') do
303
- Typhoeus.get("www.appneta.com/products/traceview/")
261
+ Typhoeus.get("127.0.0.1:8101/")
304
262
  end
305
263
 
306
264
  traces = get_all_traces
@@ -311,7 +269,7 @@ describe Oboe::Inst::TyphoeusRequestOps do
311
269
  Oboe::Config[:typhoeus][:collect_backtraces] = false
312
270
 
313
271
  Oboe::API.start_trace('typhoeus_test') do
314
- Typhoeus.get("www.appneta.com/products/traceview/")
272
+ Typhoeus.get("127.0.0.1:8101/")
315
273
  end
316
274
 
317
275
  traces = get_all_traces
@@ -36,6 +36,9 @@ Oboe::Config[:tracing_mode] = "always"
36
36
  Oboe::Config[:sample_rate] = 1000000
37
37
  Oboe.logger.level = Logger::DEBUG
38
38
 
39
+ # Our background Rack-app for http client testing
40
+ require "./test/servers/rackapp_8101"
41
+
39
42
  ##
40
43
  # clear_all_traces
41
44
  #
@@ -80,6 +83,41 @@ def validate_event_keys(event, kvs)
80
83
  end
81
84
  end
82
85
 
86
+ ##
87
+ # has_edge?
88
+ #
89
+ # Searches the array of <tt>traces</tt> for
90
+ # <tt>edge</tt>
91
+ #
92
+ def has_edge?(edge, traces)
93
+ traces.each do |t|
94
+ if Oboe::XTrace.edge_id(t["X-Trace"]) == edge
95
+ return true
96
+ end
97
+ end
98
+ Oboe.logger.debug "[oboe/debug] edge #{edge} not found in traces."
99
+ false
100
+ end
101
+
102
+ ##
103
+ # valid_edges?
104
+ #
105
+ # Runs through the array of <tt>traces</tt> to validate
106
+ # that all edges connect.
107
+ #
108
+ # Not that this won't work for external cross-app tracing
109
+ # since we won't have those remote traces to validate
110
+ # against.
111
+ #
112
+ def valid_edges?(traces)
113
+ traces.reverse.each do |t|
114
+ if t.key?("Edge")
115
+ return false unless has_edge?(t["Edge"], traces)
116
+ end
117
+ end
118
+ true
119
+ end
120
+
83
121
  ##
84
122
  # layer_has_key
85
123
  #
@@ -0,0 +1,22 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require 'rack/handler/puma'
5
+ require 'oboe/inst/rack'
6
+
7
+ Oboe.logger.info "[oboe/info] Starting background utility rack app on localhost:8101."
8
+
9
+ Thread.new do
10
+ app = Rack::Builder.new {
11
+ use Oboe::Rack
12
+ run Proc.new { |env|
13
+ [200, {"Content-Type" => "text/html"}, ['Hello TraceView!']]
14
+ }
15
+ }
16
+
17
+ Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 8101})
18
+ end
19
+
20
+ # Allow Thin to boot.
21
+ sleep(2)
22
+
@@ -23,7 +23,7 @@ describe Oboe::Config do
23
23
  instrumentation = Oboe::Config.instrumentation_list
24
24
 
25
25
  # Verify the number of individual instrumentations
26
- instrumentation.count.must_equal 18
26
+ instrumentation.count.must_equal 20
27
27
 
28
28
  Oboe::Config[:action_controller][:enabled].must_equal true
29
29
  Oboe::Config[:action_view][:enabled].must_equal true
@@ -41,6 +41,9 @@ describe Oboe::Config do
41
41
  Oboe::Config[:rack][:enabled].must_equal true
42
42
  Oboe::Config[:redis][:enabled].must_equal true
43
43
  Oboe::Config[:resque][:enabled].must_equal true
44
+ Oboe::Config[:rest_client][:enabled].must_equal true
45
+ Oboe::Config[:sequel][:enabled].must_equal true
46
+ Oboe::Config[:typhoeus][:enabled].must_equal true
44
47
 
45
48
  Oboe::Config[:action_controller][:log_args].must_equal true
46
49
  Oboe::Config[:action_view][:log_args].must_equal true
@@ -58,6 +61,9 @@ describe Oboe::Config do
58
61
  Oboe::Config[:rack][:log_args].must_equal true
59
62
  Oboe::Config[:redis][:log_args].must_equal true
60
63
  Oboe::Config[:resque][:log_args].must_equal true
64
+ Oboe::Config[:rest_client][:log_args].must_equal true
65
+ Oboe::Config[:sequel][:log_args].must_equal true
66
+ Oboe::Config[:typhoeus][:log_args].must_equal true
61
67
 
62
68
  Oboe::Config[:resque][:link_workers].must_equal false
63
69
  Oboe::Config[:blacklist].is_a?(Array).must_equal true