summary refs log tree commit diff
path: root/tests/logging/test_tracing.py
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2022-08-02 13:43:06 -0500
committerEric Eastwood <erice@element.io>2022-08-02 13:43:06 -0500
commitda396a253853702d55dc5fdaefe34728a160fd24 (patch)
treefd482d74a617aa91fef91cb794cc9d2f5b2faed9 /tests/logging/test_tracing.py
parentAlways return config path for config error (diff)
downloadsynapse-da396a253853702d55dc5fdaefe34728a160fd24.tar.xz
Add test for what happens when side by side spans in with statement
Diffstat (limited to 'tests/logging/test_tracing.py')
-rw-r--r--tests/logging/test_tracing.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/logging/test_tracing.py b/tests/logging/test_tracing.py

index d380c3b9ad..75b7745ab6 100644 --- a/tests/logging/test_tracing.py +++ b/tests/logging/test_tracing.py
@@ -112,6 +112,24 @@ class TracingTestCase(TestCase): ["child_span2", "child_span1", "root_span"], ) + def test_side_by_side_spans(self) -> None: + with start_active_span( + "span1", tracer=self._tracer + ) as span1, start_active_span("span2", tracer=self._tracer) as span2: + # We expect the last span in `with` list to be active + self.assertEqual(opentelemetry.trace.get_current_span(), span2) + + # Active span is unset now that we're outside of the `with` scopes + self.assertEqual( + opentelemetry.trace.get_current_span(), opentelemetry.trace.INVALID_SPAN + ) + + # the spans should be reported in order of their finishing. + self.assertListEqual( + [span.name for span in self._exporter.get_finished_spans()], + ["span2", "span1"], + ) + def test_overlapping_spans(self) -> None: """Overlapping spans which are not neatly nested should work""" reactor = MemoryReactorClock()