def test_double_instrumentation(self): # double instrumentation must not happen patch() def fn(): with self.tracer.trace('executor.thread'): return 42 with override_global_tracer(self.tracer): with self.tracer.trace('main.thread'): with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: future = executor.submit(fn) result = future.result() # assert the right result eq_(result, 42) # the trace must be completed traces = self.tracer.writer.pop_traces() eq_(len(traces), 1) eq_(len(traces[0]), 2)
def test_double_instrumentation(self): # double instrumentation must not happen patch() def fn(): with self.tracer.trace('executor.thread'): return 42 with override_global_tracer(self.tracer): with self.tracer.trace('main.thread'): with concurrent.futures.ThreadPoolExecutor( max_workers=2) as executor: future = executor.submit(fn) result = future.result() # assert the right result eq_(result, 42) # the trace must be completed traces = self.tracer.writer.pop_traces() eq_(len(traces), 1) eq_(len(traces[0]), 2)
def test_double_instrumentation(self): # double instrumentation must not happen patch() def fn(): with self.tracer.trace("executor.thread"): return 42 with self.override_global_tracer(): with self.tracer.trace("main.thread"): with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: future = executor.submit(fn) result = future.result() # assert the right result self.assertEqual(result, 42) # the trace must be completed self.assert_structure( dict(name="main.thread"), (dict(name="executor.thread"),), )
def setUp(self): super(PropagationTestCase, self).setUp() # instrument ``concurrent`` patch()
def setUp(self): # instrument ``concurrent`` patch() self.tracer = get_dummy_tracer()