Exemple #1
0
    def test_add_span(self):
        ctx = Context()
        span = Span(tracer=None, name="fake_span")
        ctx.add_span(span)
        assert ctx == span.context
        assert ctx.span_id == span.span_id
        assert ctx.get_current_span() == span
        assert ctx.get_current_root_span() == span

        span2 = Span(tracer=None, name="fake_span2")
        span2.parent_id = span.span_id
        span2._parent = span
        ctx.add_span(span2)
        assert ctx == span2.context
        assert ctx.span_id == span2.span_id
        assert ctx.get_current_span() == span2
        assert ctx.get_current_root_span() == span
Exemple #2
0
 def test_current_root_span(self):
     # it should return the current active root span
     ctx = Context()
     span = Span(tracer=None, name='fake_span')
     ctx.add_span(span)
     assert span == ctx.get_current_root_span()
Exemple #3
0
 def test_current_root_span_none(self):
     # it should return none when there is no root span
     ctx = Context()
     assert ctx.get_current_root_span() is None