You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: distinguish a timeout from other failures on shutdown and flush - #1663
runWithTimeout mapped TimeoutCancellationException to Failure, so callers could not tell a timeout from an exporter failure on shutdown/forceFlush.
OperationResultCode.Failure is now an open class whose companion is the generic failure (so existing equality checks keep working), with a Timeout subtype returned by runWithTimeout. The and combinator and batchExportOperation* preserve a timeout through aggregation (Timeout wins over a generic Failure), so composite closeables report it end to end.
Testing
New TimeoutOperationTest (runWithTimeout passthrough and timeout, Timeout is Failure, MutableShutdownState.shutdown, composite flush). BatchTelemetryProcessorTest and the persisting processors' over-timeout cases now assert Timeout.
Not run locally (no JDK available); relying on CI.
This was written with help from an AI coding assistant.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The change introduces a non-compiling test, leaves SDK timeout assertions expecting the wrong result, and omits ABI baseline updates for a binary-incompatible API change.
The reason will be displayed to describe this comment to others. Learn more.
Updated the JVM, Android and klib dumps in fc225cc. They were generated with the Kotlin 2.4.21 ABI tools, which reproduce the existing baselines exactly for the old Failure object; apiCheck passes in CI.
On binary compatibility: c3c3ff6 keeps OperationResultCode$Failure.INSTANCE. It adds a hidden @JvmFieldINSTANCE on the Failure companion, so JVM binaries compiled against the old object keep working without recompiling. Kotlin sources can't see it and keep using OperationResultCode.Failure.
runWithTimeout now returns OperationResultCode.Timeout, a kind of
Failure, when the timeout elapses before the action completes, so the
existing tests that pin that path asserted the old generic Failure.
Updated:
- OpenTelemetryImplTest testShutdownExceedsTimeout and
testForceFlushExceedsTimeout
- the 'times out if the result never completes' tests of
CompletableResultCodeExtTest, LogRecordExporterAdapterTest,
LogRecordProcessorAdapterTest, SpanExporterAdapterTest and
SpanProcessorAdapterTest, which await through runWithTimeout.
Assertions about generic and exceptional failures stay Failure.
The explicit-timeout variant of awaitOperationResultCode also goes
through runWithTimeout, so when that timeout elapses the result is
OperationResultCode.Timeout under the new contract, not Failure.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Removing OperationResultCode$Failure.INSTANCE breaks binary compatibility for previously compiled JVM/Android callers with NoSuchFieldError, while the checked-in ABI dumps remain inconsistent with the new public API.
This assertion is satisfied by the outer flush deadline, so it does not verify that and preserves an export's Timeout result. Please add a test where the worker finishes before that deadline, combining Timeout with Success and generic Failure in both orders.
Failure is now an open class whose companion is the generic failure, and
Timeout is a new Failure subtype, so the JVM, Android and klib dumps are
updated to match. This drops OperationResultCode$Failure.INSTANCE on
JVM/Android, so callers compiled against the old object need a
recompile; the type is @experimentalapi.
Also drops the redundant explicit constructor on Failure, which detekt
reports as EmptyDefaultConstructor; the implicit one has the same ABI.
- Order the OperationResultCode.Timeout import after Success in the
persisting processor tests (detekt ImportOrdering failed CI).
- Compare Failure and Timeout as OperationResultCode in
TimeoutOperationTest rather than via their concrete object types.
- Test that the and combinator keeps Timeout in both orders against
Success, Failure and Timeout, and that forceFlush reports an export
or exporter-flush timeout that completes before the flush deadline.
Failure changed from an object to an open class with a companion, which
removed the static INSTANCE field that JVM binaries compiled against the
old object read. Add a @JvmField INSTANCE on the companion, hidden from
Kotlin sources, so those binaries keep working, and update the ABI dumps.
The Duration-based export timeout merged from main still returned a plain
Failure, so forceFlush reported Failure instead of Timeout when the export
itself timed out (testForceFlushReportsExportTimeout).
❌ Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.22%. Comparing base (8019891) to head (a75b8e5). ⚠️ Report is 24 commits behind head on main.
Thanks @fractalwrench! CI is green now on a75b8e5. Summary of the follow-up commits:
f73fe28: fixes the detekt ImportOrdering failure in the two persisting-processor tests, widens the Failure/Timeout comparison, and adds testAndPreservesTimeout plus two forceFlush tests where a timeout happens before the flush deadline (Copilot's "previously missed" note).
fc225cc: updates the sdk-api ABI dumps and drops the empty explicit constructor on Failure, which detekt would otherwise flag.
71369be / e31889f: merges main and switches the new test to the Duration-based exportTimeout.
c3c3ff6: keeps Failure.INSTANCE as a hidden @JvmField on the companion, so existing JVM binaries don't need recompiling.
a75b8e5: the Duration-based guardUserCode that came in from main (Use Duration for span batch timing #1640) still returned Failure on an export timeout; it now returns Timeout, which testForceFlushReportsExportTimeout covers.
The Copilot threads are answered inline. The full Gradle build wasn't run locally; an AI agent ran detekt and targeted kotlinc/JUnit checks, and CI ran the full suite.
(This was put together with help from an AI coding assistant.)
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Changing the public Failure singleton into an open class requires maintainer review of JS/native binary compatibility and exhaustive Kotlin when-expression source compatibility, despite the retained JVM/Android INSTANCE bridge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
runWithTimeoutmappedTimeoutCancellationExceptiontoFailure, so callers could not tell a timeout from an exporter failure onshutdown/forceFlush.OperationResultCode.Failureis now an open class whose companion is the generic failure (so existing equality checks keep working), with aTimeoutsubtype returned byrunWithTimeout. Theandcombinator andbatchExportOperation*preserve a timeout through aggregation (Timeoutwins over a genericFailure), so composite closeables report it end to end.Testing
TimeoutOperationTest(runWithTimeout passthrough and timeout,Timeout is Failure,MutableShutdownState.shutdown, composite flush).BatchTelemetryProcessorTestand the persisting processors' over-timeout cases now assertTimeout.This was written with help from an AI coding assistant.