Exemplo n.º 1
0
 def test_start_finish(self):
     with ContextHelper() as ctx:
         tracer = tracer_module.Tracer(sampler=AlwaysOnSampler())
         parent = OpenCensusSpan()
         wrapped_class = parent.span()
         assert wrapped_class.span_instance.end_time is None
         wrapped_class.start()
         wrapped_class.finish()
         assert wrapped_class.span_instance.start_time is not None
         assert wrapped_class.span_instance.end_time is not None
         parent.finish()
Exemplo n.º 2
0
 def test_span(self):
     exporter = MockExporter()
     with ContextHelper() as ctx:
         tracer = tracer_module.Tracer(sampler=AlwaysOnSampler(), exporter=exporter)
         assert OpenCensusSpan.get_current_tracer() is tracer
         wrapped_class = OpenCensusSpan()
         assert tracer.current_span() == wrapped_class.span_instance
         child = wrapped_class.span()
         assert tracer.current_span() == child.span_instance
         assert child.span_instance.name == "span"
         assert child.span_instance.context_tracer.trace_id == tracer.span_context.trace_id
         assert child.span_instance.parent_span is wrapped_class.span_instance
         tracer.finish()
     exporter.build_tree()
     parent = exporter.root
     assert len(parent.children) == 1
     assert parent.children[0].span_data.span_id == child.span_instance.span_id