Skip to content

Commit 7612e6e

Browse files
Separate tests for shutdown and force_flush
1 parent 4cf3c3c commit 7612e6e

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

opentelemetry-sdk/tests/trace/export/test_export.py

+22-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,25 @@ def _create_start_and_end_span(name, span_processor):
9797

9898

9999
class TestBatchExportSpanProcessor(unittest.TestCase):
100-
def test_batch_span_processor(self):
100+
def test_shutdown(self):
101+
spans_names_list = []
102+
103+
my_exporter = MySpanExporter(destination=spans_names_list)
104+
span_processor = export.BatchExportSpanProcessor(my_exporter)
105+
106+
span_names = ["xxx", "bar", "foo"]
107+
108+
for name in span_names:
109+
_create_start_and_end_span(name, span_processor)
110+
111+
span_processor.shutdown()
112+
self.assertTrue(my_exporter.is_shutdown)
113+
114+
# check that spans are exported without an explicitly call to
115+
# force_flush()
116+
self.assertListEqual(span_names, spans_names_list)
117+
118+
def test_flush(self):
101119
spans_names_list = []
102120

103121
my_exporter = MySpanExporter(destination=spans_names_list)
@@ -116,12 +134,11 @@ def test_batch_span_processor(self):
116134
for name in span_names1:
117135
_create_start_and_end_span(name, span_processor)
118136

119-
span_processor.shutdown()
120-
self.assertTrue(my_exporter.is_shutdown)
121-
122-
# check that processor is flushed after shutdown()
137+
span_processor.force_flush()
123138
self.assertListEqual(span_names0 + span_names1, spans_names_list)
124139

140+
span_processor.shutdown()
141+
125142
def test_batch_span_processor_lossless(self):
126143
"""Test that no spans are lost when sending max_queue_size spans"""
127144
spans_names_list = []

0 commit comments

Comments
 (0)