Пример #1
0
 def test_log_unfinished_spans_disabled(self, log):
     # the trace finished status logging is disabled
     tracer = get_dummy_tracer()
     tracer.debug_logging = False
     ctx = Context()
     # manually create a root-child trace
     root = Span(tracer=tracer, name='root')
     child_1 = Span(tracer=tracer,
                    name='child_1',
                    trace_id=root.trace_id,
                    parent_id=root.span_id)
     child_2 = Span(tracer=tracer,
                    name='child_2',
                    trace_id=root.trace_id,
                    parent_id=root.span_id)
     child_1._parent = root
     child_2._parent = root
     ctx.add_span(root)
     ctx.add_span(child_1)
     ctx.add_span(child_2)
     # close only the parent
     root.finish()
     assert ctx.is_finished() is False
     # the logger has never been invoked to print unfinished spans
     for call, _ in log.call_args_list:
         msg = call[0]
         assert 'the trace has %d unfinished spans' not in msg
Пример #2
0
 def test_finished(self):
     # a Context is finished if all spans inside are finished
     ctx = Context()
     span = Span(tracer=None, name='fake_span')
     ctx.add_span(span)
     ctx.close_span(span)
     assert ctx.is_finished()
Пример #3
0
 def test_log_unfinished_spans(self, log):
     # when the root parent is finished, notify if there are spans still pending
     tracer = get_dummy_tracer()
     tracer.debug_logging = True
     ctx = Context()
     # manually create a root-child trace
     root = Span(tracer=tracer, name='root')
     child_1 = Span(tracer=tracer,
                    name='child_1',
                    trace_id=root.trace_id,
                    parent_id=root.span_id)
     child_2 = Span(tracer=tracer,
                    name='child_2',
                    trace_id=root.trace_id,
                    parent_id=root.span_id)
     child_1._parent = root
     child_2._parent = root
     ctx.add_span(root)
     ctx.add_span(child_1)
     ctx.add_span(child_2)
     # close only the parent
     root.finish()
     assert ctx.is_finished() is False
     unfinished_spans_log = log.call_args_list[-3][0][2]
     child_1_log = log.call_args_list[-2][0][1]
     child_2_log = log.call_args_list[-1][0][1]
     assert 2 == unfinished_spans_log
     assert 'name child_1' in child_1_log
     assert 'name child_2' in child_2_log
     assert 'duration 0.000000s' in child_1_log
     assert 'duration 0.000000s' in child_2_log
Пример #4
0
 def test_finished(self):
     # a Context is finished if all spans inside are finished
     ctx = Context()
     span = Span(tracer=None, name='fake_span')
     ctx.add_span(span)
     ctx.close_span(span)
     ok_(ctx.is_finished())
Пример #5
0
 def test_log_unfinished_spans(self, log):
     # when the root parent is finished, notify if there are spans still pending
     tracer = get_dummy_tracer()
     tracer.debug_logging = True
     ctx = Context()
     # manually create a root-child trace
     root = Span(tracer=tracer, name='root')
     child_1 = Span(tracer=tracer, name='child_1', trace_id=root.trace_id, parent_id=root.span_id)
     child_2 = Span(tracer=tracer, name='child_2', trace_id=root.trace_id, parent_id=root.span_id)
     child_1._parent = root
     child_2._parent = root
     ctx.add_span(root)
     ctx.add_span(child_1)
     ctx.add_span(child_2)
     # close only the parent
     root.finish()
     ok_(ctx.is_finished() is False)
     unfinished_spans_log = log.call_args_list[-3][0][2]
     child_1_log = log.call_args_list[-2][0][1]
     child_2_log = log.call_args_list[-1][0][1]
     eq_(2, unfinished_spans_log)
     ok_('name child_1' in child_1_log)
     ok_('name child_2' in child_2_log)
     ok_('duration 0.000000s' in child_1_log)
     ok_('duration 0.000000s' in child_2_log)
Пример #6
0
 def test_log_unfinished_spans_disabled(self, log):
     # the trace finished status logging is disabled
     tracer = get_dummy_tracer()
     tracer.debug_logging = False
     ctx = Context()
     # manually create a root-child trace
     root = Span(tracer=tracer, name='root')
     child_1 = Span(tracer=tracer, name='child_1', trace_id=root.trace_id, parent_id=root.span_id)
     child_2 = Span(tracer=tracer, name='child_2', trace_id=root.trace_id, parent_id=root.span_id)
     child_1._parent = root
     child_2._parent = root
     ctx.add_span(root)
     ctx.add_span(child_1)
     ctx.add_span(child_2)
     # close only the parent
     root.finish()
     ok_(ctx.is_finished() is False)
     # the logger has never been invoked to print unfinished spans
     for call, _ in log.call_args_list:
         msg = call[0]
         ok_('the trace has %d unfinished spans' not in msg)
Пример #7
0
 def test_finished_empty(self):
     # a Context is not finished if it's empty
     ctx = Context()
     assert ctx.is_finished() is False
Пример #8
0
 def test_finished_empty(self):
     # a Context is not finished if it's empty
     ctx = Context()
     ok_(ctx.is_finished() is False)