6
6
from opentracing .ext import tags
7
7
from opentracing .mocktracer import MockTracer
8
8
from flask_opentracing import FlaskTracing
9
+ from flaky import flaky
9
10
10
11
11
12
app = Flask (__name__ )
19
20
20
21
21
22
def flush_spans (tcr ):
22
- for req in tcr ._current_scopes :
23
- tcr . _current_scopes [ req ] .close ()
23
+ for span in tcr ._current_scopes . values () :
24
+ span .close ()
24
25
tcr ._current_scopes = {}
25
26
26
27
@@ -101,9 +102,9 @@ def test_span_tags(self):
101
102
tags .HTTP_METHOD : 'GET' ,
102
103
tags .SPAN_KIND : tags .SPAN_KIND_RPC_SERVER ,
103
104
tags .HTTP_URL : 'http://localhost/another_test_simple' ,
104
- 'is_xhr' : 'False' ,
105
105
}
106
106
107
+ @flaky (max_runs = 5 )
107
108
def test_requests_distinct (self ):
108
109
with app .test_request_context ('/test' ):
109
110
app .preprocess_request ()
@@ -176,6 +177,7 @@ def _verify_error(self, span):
176
177
RuntimeError
177
178
)
178
179
180
+ @flaky (max_runs = 5 )
179
181
def test_over_wire (self ):
180
182
rv = test_app .get ('/wire' )
181
183
assert '200' in str (rv .status_code )
@@ -193,33 +195,3 @@ def test_child_span(self):
193
195
assert len (spans ) == 2
194
196
assert spans [0 ].context .trace_id == spans [1 ].context .trace_id
195
197
assert spans [0 ].parent_id == spans [1 ].context .span_id
196
-
197
-
198
- class TestTracingStartSpanCallback (unittest .TestCase ):
199
- def test_simple (self ):
200
- def start_span_cb (span , request ):
201
- span .set_tag ('component' , 'not-flask' )
202
- span .set_tag ('mytag' , 'myvalue' )
203
-
204
- tracing = FlaskTracing (MockTracer (), True , app ,
205
- start_span_cb = start_span_cb )
206
- rv = test_app .get ('/test' )
207
- assert '200' in str (rv .status_code )
208
-
209
- spans = tracing .tracer .finished_spans ()
210
- assert len (spans ) == 1
211
- assert spans [0 ].tags .get (tags .COMPONENT , None ) == 'not-flask'
212
- assert spans [0 ].tags .get ('mytag' , None ) == 'myvalue'
213
-
214
- def test_error (self ):
215
- def start_span_cb (span , request ):
216
- raise RuntimeError ('Should not happen' )
217
-
218
- tracing = FlaskTracing (MockTracer (), True , app ,
219
- start_span_cb = start_span_cb )
220
- rv = test_app .get ('/test' )
221
- assert '200' in str (rv .status_code )
222
-
223
- spans = tracing .tracer .finished_spans ()
224
- assert len (spans ) == 1
225
- assert spans [0 ].tags .get (tags .ERROR , None ) is None
0 commit comments