Skip to content

Commit b190d85

Browse files
committed
Update force_flush to return a bool. Currently force_flush ignores it's timeout which is bad, but the behavior before made even less sense..
1 parent bd0399c commit b190d85

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def emit(self, log_data: LogData) -> None:
192192
def shutdown(self):
193193
return self._batch_processor.shutdown()
194194

195-
def force_flush(self, timeout_millis: Optional[int] = None):
195+
def force_flush(self, timeout_millis: Optional[int] = None) -> bool:
196196
return self._batch_processor.force_flush(timeout_millis)
197197

198198
@staticmethod

opentelemetry-sdk/src/opentelemetry/sdk/_shared_internal/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ def shutdown(self):
191191
self._worker_thread.join()
192192
self._exporter.shutdown()
193193

194-
def force_flush(self, timeout_millis: Optional[int] = None):
194+
# TODO: Fix force flush so the timeout is used https://github.com/open-telemetry/opentelemetry-python/issues/4568.
195+
def force_flush(self, timeout_millis: Optional[int] = None) -> bool:
195196
if self._shutdown:
196-
return
197+
return False
197198
# Blocking call to export.
198199
self._export(BatchExportStrategy.EXPORT_ALL)
200+
return True

opentelemetry-sdk/src/opentelemetry/sdk/trace/export/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def __init__(
169169
)
170170

171171
self._batch_processor = BatchProcessor(
172-
span_exporter,
172+
span_exporter, # type: ignore [reportArgumentType]
173173
schedule_delay_millis,
174174
max_export_batch_size,
175175
export_timeout_millis,
@@ -190,7 +190,7 @@ def on_end(self, span: ReadableSpan) -> None:
190190
def shutdown(self):
191191
return self._batch_processor.shutdown()
192192

193-
def force_flush(self, timeout_millis: typing.Optional[int] = None):
193+
def force_flush(self, timeout_millis: typing.Optional[int] = None) -> bool:
194194
return self._batch_processor.force_flush(timeout_millis)
195195

196196
@staticmethod

0 commit comments

Comments
 (0)