|
1 | 1 | from __future__ import absolute_import |
2 | 2 | from nose.tools import assert_equals |
3 | 3 | from instana import internal_tracer as tracer |
| 4 | +import requests |
4 | 5 | import urllib3 |
5 | 6 |
|
6 | 7 |
|
@@ -149,3 +150,49 @@ def test_client_error(self): |
149 | 150 |
|
150 | 151 | assert_equals(second_span.t, first_span.t) |
151 | 152 | assert_equals(second_span.p, first_span.s) |
| 153 | + |
| 154 | + def test_requestspkg_get(self): |
| 155 | + span = tracer.start_span("test") |
| 156 | + r = requests.get('http://127.0.0.1:5000/', timeout=2) |
| 157 | + span.finish() |
| 158 | + |
| 159 | + spans = self.recorder.queued_spans() |
| 160 | + assert_equals(2, len(spans)) |
| 161 | + first_span = spans[1] |
| 162 | + second_span = spans[0] |
| 163 | + |
| 164 | + assert(r) |
| 165 | + assert_equals(200, r.status_code) |
| 166 | + assert_equals("test", first_span.data.sdk.name) |
| 167 | + assert_equals("urllib3", second_span.n) |
| 168 | + assert_equals(200, second_span.data.http.status) |
| 169 | + assert_equals("http://127.0.0.1:5000/", second_span.data.http.url) |
| 170 | + assert_equals("GET", second_span.data.http.method) |
| 171 | + |
| 172 | + assert_equals(None, second_span.error) |
| 173 | + assert_equals(None, second_span.ec) |
| 174 | + |
| 175 | + assert_equals(second_span.t, first_span.t) |
| 176 | + assert_equals(second_span.p, first_span.s) |
| 177 | + |
| 178 | + def test_requestspkg_put(self): |
| 179 | + span = tracer.start_span("test") |
| 180 | + r = requests.put('http://127.0.0.1:5000/notfound') |
| 181 | + span.finish() |
| 182 | + |
| 183 | + spans = self.recorder.queued_spans() |
| 184 | + assert_equals(2, len(spans)) |
| 185 | + first_span = spans[1] |
| 186 | + second_span = spans[0] |
| 187 | + |
| 188 | + assert_equals(404, r.status_code) |
| 189 | + assert_equals("test", first_span.data.sdk.name) |
| 190 | + assert_equals("urllib3", second_span.n) |
| 191 | + assert_equals(404, second_span.data.http.status) |
| 192 | + assert_equals("http://127.0.0.1:5000/notfound", second_span.data.http.url) |
| 193 | + assert_equals("PUT", second_span.data.http.method) |
| 194 | + assert_equals(None, second_span.error) |
| 195 | + assert_equals(None, second_span.ec) |
| 196 | + |
| 197 | + assert_equals(second_span.t, first_span.t) |
| 198 | + assert_equals(second_span.p, first_span.s) |
0 commit comments