|
48 | 48 |
|
49 | 49 | _(exporter.finished_spans.size).must_equal 1
|
50 | 50 | _(span.name).must_equal 'HTTP GET'
|
| 51 | + _(span.attributes['http.host']).must_equal 'example.com' |
51 | 52 | _(span.attributes['http.method']).must_equal 'GET'
|
52 |
| - _(span.attributes['http.status_code']).must_equal 200 |
53 | 53 | _(span.attributes['http.scheme']).must_equal 'http'
|
54 |
| - _(span.attributes['http.host']).must_equal 'example.com' |
| 54 | + _(span.attributes['http.status_code']).must_equal 200 |
55 | 55 | _(span.attributes['http.target']).must_equal '/success'
|
| 56 | + _(span.attributes['http.url']).must_equal 'http://example.com/success' |
56 | 57 | assert_requested(
|
57 | 58 | :get,
|
58 | 59 | 'http://example.com/success',
|
|
71 | 72 |
|
72 | 73 | _(exporter.finished_spans.size).must_equal 1
|
73 | 74 | _(span.name).must_equal 'HTTP GET'
|
| 75 | + _(span.attributes['http.host']).must_equal 'example.com' |
74 | 76 | _(span.attributes['http.method']).must_equal 'GET'
|
75 |
| - _(span.attributes['http.status_code']).must_equal 500 |
76 | 77 | _(span.attributes['http.scheme']).must_equal 'http'
|
77 |
| - _(span.attributes['http.host']).must_equal 'example.com' |
| 78 | + _(span.attributes['http.status_code']).must_equal 500 |
78 | 79 | _(span.attributes['http.target']).must_equal '/failure'
|
| 80 | + _(span.attributes['http.url']).must_equal 'http://example.com/failure' |
79 | 81 | assert_requested(
|
80 | 82 | :get,
|
81 | 83 | 'http://example.com/failure',
|
|
90 | 92 |
|
91 | 93 | _(exporter.finished_spans.size).must_equal 1
|
92 | 94 | _(span.name).must_equal 'HTTP GET'
|
| 95 | + _(span.attributes['http.host']).must_equal 'example.com' |
93 | 96 | _(span.attributes['http.method']).must_equal 'GET'
|
94 | 97 | _(span.attributes['http.scheme']).must_equal 'http'
|
95 |
| - _(span.attributes['http.host']).must_equal 'example.com' |
96 | 98 | _(span.attributes['http.target']).must_equal '/timeout'
|
| 99 | + _(span.attributes['http.url']).must_equal 'http://example.com/timeout' |
97 | 100 | _(span.status.code).must_equal(
|
98 | 101 | OpenTelemetry::Trace::Status::ERROR
|
99 | 102 | )
|
|
119 | 122 |
|
120 | 123 | _(exporter.finished_spans.size).must_equal 1
|
121 | 124 | _(span.name).must_equal 'HTTP GET'
|
| 125 | + _(span.attributes['http.host']).must_equal 'example.com' |
122 | 126 | _(span.attributes['http.method']).must_equal 'OVERRIDE'
|
123 |
| - _(span.attributes['http.status_code']).must_equal 200 |
124 | 127 | _(span.attributes['http.scheme']).must_equal 'http'
|
125 |
| - _(span.attributes['http.host']).must_equal 'example.com' |
| 128 | + _(span.attributes['http.status_code']).must_equal 200 |
126 | 129 | _(span.attributes['http.target']).must_equal '/success'
|
| 130 | + _(span.attributes['http.url']).must_equal 'http://example.com/success' |
127 | 131 | _(span.attributes['test.attribute']).must_equal 'test.value'
|
128 | 132 | assert_requested(
|
129 | 133 | :get,
|
|
186 | 190 |
|
187 | 191 | _(exporter.finished_spans.size).must_equal 1
|
188 | 192 | _(span.name).must_equal 'HTTP GET'
|
189 |
| - _(span.attributes['http.method']).must_equal 'GET' |
190 | 193 | _(span.attributes['http.host']).must_equal 'example.com'
|
| 194 | + _(span.attributes['http.method']).must_equal 'GET' |
191 | 195 | end
|
192 | 196 |
|
193 | 197 | it 'creates a span on connect for a non-ignored request' do
|
|
215 | 219 | end
|
216 | 220 |
|
217 | 221 | it 'emits span on connect' do
|
| 222 | + port = nil |
| 223 | + |
218 | 224 | TCPServer.open('localhost', 0) do |server|
|
219 | 225 | Thread.start do
|
220 | 226 | server.accept
|
|
231 | 237 | _(span.name).must_equal 'connect'
|
232 | 238 | _(span.attributes['net.peer.name']).must_equal('localhost')
|
233 | 239 | _(span.attributes['net.peer.port']).wont_be_nil
|
| 240 | + _(span.attributes['net.peer.port']).must_equal(port) |
234 | 241 |
|
235 |
| - assert_http_spans(target: '/example', exception: 'Excon::Error::Timeout') |
| 242 | + assert_http_spans(port: port, target: '/example', exception: 'Excon::Error::Timeout') |
236 | 243 | end
|
237 | 244 |
|
238 | 245 | it 'captures errors' do
|
|
248 | 255 | # Depending on the Ruby and Excon Version this will be a SocketError, Socket::ResolutionError or Resolv::ResolvError
|
249 | 256 | _(span_event.attributes['exception.type']).must_match(/(Socket|Resolv)/)
|
250 | 257 |
|
251 |
| - assert_http_spans(host: 'invalid.com', target: '/example') |
| 258 | + assert_http_spans(host: 'invalid.com', port: 99_999, target: '/example') |
252 | 259 | end
|
253 | 260 |
|
254 | 261 | it '[BUG] fails to emit an HTTP CONNECT span when connecting through an SSL proxy for an HTTP service' do
|
|
296 | 303 | end
|
297 | 304 | end
|
298 | 305 |
|
299 |
| - def assert_http_spans(scheme: 'http', host: 'localhost', target: '/', exception: nil) |
| 306 | + def assert_http_spans(scheme: 'http', host: 'localhost', port: nil, target: '/', exception: nil) |
300 | 307 | exporter.finished_spans[1..].each do |http_span|
|
301 | 308 | _(http_span.name).must_equal 'HTTP GET'
|
| 309 | + _(http_span.attributes['http.host']).must_equal host |
302 | 310 | _(http_span.attributes['http.method']).must_equal 'GET'
|
303 | 311 | _(http_span.attributes['http.scheme']).must_equal scheme
|
304 |
| - _(http_span.attributes['http.host']).must_equal host |
305 | 312 | _(http_span.attributes['http.target']).must_equal target
|
| 313 | + _(http_span.attributes['http.url']).must_equal "#{scheme}://#{host}#{port&.to_s&.prepend(':')}#{target}" |
306 | 314 | _(http_span.status.code).must_equal(
|
307 | 315 | OpenTelemetry::Trace::Status::ERROR
|
308 | 316 | )
|
|
0 commit comments