File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
src/opentelemetry/sdk/_shared_internal Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -169,14 +169,21 @@ def worker(self):
169169 self ._worker_awaken .clear ()
170170 self ._export (BatchExportStrategy .EXPORT_ALL )
171171
172- def _export (self , batch_strategy : BatchExportStrategy , flush_should_end : Optional [float ] = None ) -> bool :
172+ def _export (
173+ self ,
174+ batch_strategy : BatchExportStrategy ,
175+ flush_should_end : Optional [float ] = None ,
176+ ) -> bool :
173177 # Returns True if all batches were exported, False if flush_should_end was reached.
174178 with self ._export_lock :
175179 iteration = 0
176180 # We could see concurrent export calls from worker and force_flush. We call _should_export_batch
177181 # once the lock is obtained to see if we still need to make the requested export.
178182 while self ._should_export_batch (batch_strategy , iteration ):
179- if flush_should_end is not None and time .time () >= flush_should_end :
183+ if (
184+ flush_should_end is not None
185+ and time .time () >= flush_should_end
186+ ):
180187 return False
181188 iteration += 1
182189 token = attach (set_value (_SUPPRESS_INSTRUMENTATION_KEY , True ))
Original file line number Diff line number Diff line change @@ -206,18 +206,19 @@ def slow_export(batch):
206206 exporter .export .side_effect = slow_export
207207 batch_processor = batch_processor_class (
208208 exporter ,
209- max_queue_size = 50 ,
209+ max_queue_size = 200 ,
210210 max_export_batch_size = 1 ,
211+ # Long enough that the worker thread won't wake up during the test.
211212 schedule_delay_millis = 30000 ,
212213 export_timeout_millis = 500 ,
213214 )
214- for _ in range (10 ):
215+ for _ in range (50 ):
215216 batch_processor ._batch_processor .emit (telemetry )
216217 # 100ms timeout, each export takes 200ms, so deadline is hit after first batch.
217218 result = batch_processor .force_flush (timeout_millis = 100 )
218219 assert result is False
219220 # Exporter was called at least once but not for all batches.
220- assert 1 <= call_count < 10
221+ assert 1 <= call_count < 50
221222 batch_processor .shutdown ()
222223
223224 # pylint: disable=no-self-use
You can’t perform that action at this time.
0 commit comments