1
1
import mock
2
2
import unittest
3
3
4
- from flask import (Flask , request )
4
+ from flask import (Flask , Response , request )
5
5
import opentracing
6
6
from opentracing .ext import tags
7
7
from opentracing .mocktracer import MockTracer
@@ -27,32 +27,32 @@ def flush_spans(tcr):
27
27
28
28
@app .route ('/test' )
29
29
def check_test_works ():
30
- return 'Success'
30
+ return Response ( 'Success' )
31
31
32
32
33
33
@app .route ('/another_test' )
34
34
@tracing .trace ('url' , 'url_rule' )
35
35
def decorated_fn ():
36
- return 'Success again'
36
+ return Response ( 'Success again' )
37
37
38
38
39
39
@app .route ('/another_test_simple' )
40
40
@tracing .trace ('query_string' , 'is_xhr' )
41
41
def decorated_fn_simple ():
42
- return 'Success again'
42
+ return Response ( 'Success again' )
43
43
44
44
45
45
@app .route ('/error_test' )
46
46
@tracing .trace ()
47
47
def decorated_fn_with_error ():
48
- raise RuntimeError ('Should not happen ' )
48
+ raise RuntimeError ('Intentional testing exception ' )
49
49
50
50
51
51
@app .route ('/decorated_child_span_test' )
52
52
@tracing .trace ()
53
53
def decorated_fn_with_child_span ():
54
54
with tracing .tracer .start_active_span ('child' ):
55
- return 'Success'
55
+ return Response ( 'Success' )
56
56
57
57
58
58
@app .route ('/wire' )
@@ -93,7 +93,7 @@ def test_span_deletion(self):
93
93
assert not tracing_deferred ._current_scopes
94
94
95
95
def test_span_tags (self ):
96
- test_app .get ('/another_test_simple' )
96
+ response = test_app .get ('/another_test_simple' )
97
97
98
98
spans = tracing ._tracer .finished_spans ()
99
99
assert len (spans ) == 1
@@ -102,6 +102,7 @@ def test_span_tags(self):
102
102
tags .HTTP_METHOD : 'GET' ,
103
103
tags .SPAN_KIND : tags .SPAN_KIND_RPC_SERVER ,
104
104
tags .HTTP_URL : 'http://localhost/another_test_simple' ,
105
+ tags .HTTP_STATUS_CODE : response .status_code ,
105
106
}
106
107
107
108
@flaky (max_runs = 5 )
0 commit comments