Repository navigation
fix: respect timeout_millis in BatchProcessor.force_flush (#4568) - #4982
chimchim89 wants to merge 6 commits into
Conversation
7a97df8 to
e7f7b93
Compare
|
Please add a changelog entry |
e7f7b93 to
3e1e396
Compare
yes. I added a changelog entry under ## Unreleased. |
3e1e396 to
fa68592
Compare
fa68592 to
af1bc29
Compare
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
226e938 to
59bb176
Compare
…ut_exceeded to avoid flakiness on fast CI runners Fixes open-telemetry#4568.
4c001dc to
80b7d77
Compare
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
|
This PR has been closed due to inactivity. Please reopen if you would like to continue working on it. |
Description
force_flushinBatchProcessoraccepted atimeout_millisparameter but completely ignored it, blocking until all telemetry was exported regardless of the timeout passed by the caller.The fix has two parts:
_export()now accepts aflush_should_endparameter (an absolutetime.time()deadline). Before each batch export, itchecks whether the deadline has been reached and returns
Falseearly if so. ReturnsTruewhen all batches are exportednormally.
force_flush()now computes a deadline fromtimeout_millisand passes it to_export(), then propagates the result back tothe caller.
Note: the timeout is checked between batches, not during a single
exporter.export()call. Passing the timeout intoexporter.export()itself is a separate issue tracked in #4555.Fixes #4568
Type of change
How Has This Been Tested?
Three new unit tests were added to
opentelemetry-sdk/tests/shared_internal/test_batch_processor.py. Each test runs for bothBatchLogRecordProcessorandBatchSpanProcessorvia the existing@pytest.mark.parametrizedecorator (6 test runs total):test_force_flush_returns_true_when_all_exported— verifies thatforce_flushreturnsTruewhen all telemetry is exportedwithin the timeout.
test_force_flush_returns_false_when_timeout_exceeded— verifies thatforce_flushreturnsFalsewhen the deadline isexceeded before the queue is fully drained. Uses a slow exporter (
time.sleep(0.2)) with a 100ms timeout to reliably trigger thetimeout between batches.
test_force_flush_returns_false_when_shutdown— verifies thatforce_flushreturnsFalseimmediately when the processor isalready shut down and nothing is exported.
Ran new tests only:
Ran full test file to verify no regressions:
Ran ruff linter to verify style:
Ran tox to verify full lint and type check pipeline:
Does This PR Require a Contrib Repo Change?
Checklist: