async def test_set_call_context(tracer): tracer.configure(context_provider=context_provider) # a different Context is set for the current logical execution task = asyncio.Task.current_task() ctx = Context() helpers.set_call_context(task, ctx) assert ctx == tracer.current_trace_context()
def test_propagation_with_set_call_context(self): # ensures that if a new Context is attached to the current # running Task via helpers, a previous trace is resumed task = asyncio.Task.current_task() ctx = Context(trace_id=100, span_id=101) set_call_context(task, ctx) with self.tracer.trace('async_task'): yield from asyncio.sleep(0.01) traces = self.tracer.writer.pop_traces() assert len(traces) == 1 assert len(traces[0]) == 1 span = traces[0][0] assert span.trace_id == 100 assert span.parent_id == 101
def test_propagation_with_new_context(self): # ensures that if a new Context is attached to the current # running Task, a previous trace is resumed task = asyncio.Task.current_task() ctx = Context(trace_id=100, span_id=101) set_call_context(task, ctx) with self.tracer.trace('async_task'): yield from asyncio.sleep(0.01) traces = self.tracer.writer.pop_traces() eq_(len(traces), 1) eq_(len(traces[0]), 1) span = traces[0][0] eq_(span.trace_id, 100) eq_(span.parent_id, 101)
def test_propagation_with_set_call_context(self): # ensures that if a new Context is attached to the current # running Task via helpers, a previous trace is resumed task = asyncio.Task.current_task() ctx = Context(trace_id=100, span_id=101) set_call_context(task, ctx) with self.tracer.trace('async_task'): yield from asyncio.sleep(0.01) traces = self.tracer.writer.pop_traces() eq_(len(traces), 1) eq_(len(traces[0]), 1) span = traces[0][0] eq_(span.trace_id, 100) eq_(span.parent_id, 101)
async def test_propagation_with_set_call_context(tracer): # ensures that if a new Context is attached to the current # running Task via helpers, a previous trace is resumed tracer.configure(context_provider=context_provider) task = asyncio.Task.current_task() ctx = Context(trace_id=100, span_id=101) set_call_context(task, ctx) with tracer.trace("async_task"): await asyncio.sleep(0.01) traces = tracer.pop_traces() assert len(traces) == 1 assert len(traces[0]) == 1 span = traces[0][0] assert span.trace_id == 100 assert span.parent_id == 101
def test_set_call_context(self): # a different Context is set for the current logical execution task = asyncio.Task.current_task() ctx = Context() helpers.set_call_context(task, ctx) eq_(ctx, self.tracer.get_call_context())
def test_set_call_context(self): # a different Context is set for the current logical execution task = asyncio.Task.current_task() ctx = Context() helpers.set_call_context(task, ctx) eq_(ctx, self.tracer.get_call_context())