Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Working second test although it's a bit pointless testing whether ope…
Browse files Browse the repository at this point in the history
…ntelemetry works
  • Loading branch information
MadLittleMods committed Jul 30, 2022
1 parent d29a4af commit 041acdf
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tests/logging/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,17 @@ def test_nested_spans(self) -> None:
)
self.assertEqual(child_span1.parent.span_id, root_context.span_id)

ctx1 = opentelemetry.trace.propagation.set_span_in_context(child_span1)
with start_active_span(
"child_span2",
context=ctx1,
tracer=self._tracer,
) as child_span2:
self.assertEqual(opentelemetry.trace.get_current_span(), child_span2)
self.assertEqual(
child_span2.parent.span_id, child_span1.get_span_context().span_id
)
with start_active_span(
"child_span2",
tracer=self._tracer,
) as child_span2:
self.assertEqual(
opentelemetry.trace.get_current_span(), child_span2
)
self.assertEqual(
child_span2.parent.span_id,
child_span1.get_span_context().span_id,
)

# the root scope should be restored
self.assertEqual(opentelemetry.trace.get_current_span(), root_span)
Expand All @@ -125,8 +126,9 @@ def test_nested_spans(self) -> None:
)

# the spans should be reported in order of their finishing.
self.assertEqual(
self._reporter.get_spans(), [scope2.span, scope1.span, root_scope.span]
self.assertListEqual(
[span.name for span in self._exporter.get_finished_spans()],
["child_span2", "child_span1", "root_span"],
)

# def test_overlapping_spans(self) -> None:
Expand Down

0 comments on commit 041acdf

Please sign in to comment.