File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ class TestAppSafety(TornadoTestCase):
4848 """
4949 Ensure that the application patch has the proper safety guards.
5050 """
51+
5152 def test_trace_unpatch (self ):
5253 # the application must not be traced if unpatch() is called
5354 patch ()
@@ -108,6 +109,27 @@ def test_arbitrary_resource_404(self):
108109 eq_ ('tornado.web.ErrorHandler' , request_span .resource )
109110 eq_ ('/does_not_exist/' , request_span .get_tag ('http.url' ))
110111
112+ @gen_test
113+ def test_futures_without_context (self ):
114+ # ensures that if futures propagation is available, an empty
115+ # context doesn't crash the system
116+ from .web .compat import ThreadPoolExecutor
117+
118+ def job ():
119+ with self .tracer .trace ('job' ):
120+ return 42
121+
122+ executor = ThreadPoolExecutor (max_workers = 3 )
123+ yield executor .submit (job )
124+
125+ traces = self .tracer .writer .pop_traces ()
126+ eq_ (1 , len (traces ))
127+ eq_ (1 , len (traces [0 ]))
128+
129+ # this trace yields the execution of the thread
130+ span = traces [0 ][0 ]
131+ eq_ ('job' , span .name )
132+
111133
112134class TestCustomAppSafety (TornadoTestCase ):
113135 """
You can’t perform that action at this time.
0 commit comments