@@ -97,7 +97,25 @@ def _create_start_and_end_span(name, span_processor):
97
97
98
98
99
99
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 ):
101
119
spans_names_list = []
102
120
103
121
my_exporter = MySpanExporter (destination = spans_names_list )
@@ -116,12 +134,11 @@ def test_batch_span_processor(self):
116
134
for name in span_names1 :
117
135
_create_start_and_end_span (name , span_processor )
118
136
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 ()
123
138
self .assertListEqual (span_names0 + span_names1 , spans_names_list )
124
139
140
+ span_processor .shutdown ()
141
+
125
142
def test_batch_span_processor_lossless (self ):
126
143
"""Test that no spans are lost when sending max_queue_size spans"""
127
144
spans_names_list = []
0 commit comments