[BUGFIX] Complete an OTLP HTTP request on every state its client can end on - #4453
Open
thc1006 wants to merge 3 commits into
Open
[BUGFIX] Complete an OTLP HTTP request on every state its client can end on#4453thc1006 wants to merge 3 commits into
thc1006 wants to merge 3 commits into
Conversation
thc1006
marked this pull request as ready for review
August 19, 2026 20:20
…end on The switch that decides whether a request is over named seven states. The client can end a transfer on three more: Destroyed, ReadError and WriteError. The switch below it recognises all three and logs them, so they arrive, are described, and are then dropped. A request ended that way never reaches Unbind, so its result callback never runs and its session is never released. ForceFlush and Shutdown have nothing to wait on but their own deadlines, and the caller is left waiting for a callback that is not coming. The bundled curl client does not currently produce those three states, so this is reached through the installed HttpClient interface by a client the user supplies. That interface is a supported extension point and the states are part of it, which is why the exporter has to answer them rather than assume which ones a client uses. Ordering is unchanged. stopping_ is a compare-exchange and the first writer wins, so one of these arriving after a response has already been reported still reports nothing. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
thc1006
force-pushed
the
bugfix/otlp-http-terminal-events-4425
branch
from
August 23, 2026 23:29
5e754a9 to
31118d3
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4453 +/- ##
==========================================
+ Coverage 82.67% 82.73% +0.06%
==========================================
Files 516 516
Lines 20197 20197
==========================================
+ Hits 16696 16708 +12
+ Misses 3501 3489 -12
🚀 New features to boost your workflow:
|
Three warnings, all from scaffolding this branch added rather than from what it is testing. The clang-tidy job counts warnings against a limit and main is at that limit, so three new ones fail it. The parameterised fixture is gone. It existed to run one body over three states, and a loop with SCOPED_TRACE does that without a class that only this translation unit can use, which is also how the case next to it is written. The two shared_ptr parameters of the recording helper are const references. The lambda inside still takes its own copy, so nothing about the lifetime changes; what goes away is a copy per call at the boundary. Checked the way CI checks it, with CMAKE_CXX_CLANG_TIDY over the all-options-abiv1-preview cache file, which reports no warnings for the test file and leaves the one in otlp_http_client.cc that main already has. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
The switch comment and the two test comments described what the code used to do before the fix. That reads as history beside code that no longer has it, and it belongs in this PR and in the commit message. What is left states the invariant: every state the client can end a request on is named here, and the exchange below decides ordering. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #4425.
ResponseHandler::OnEventdecides a request is over from a switch naming seven states. The client can end a transfer on three more, which the switch below it recognises and logs:CreateFailed,ConnectFailed,SendFailed,SSLHandshakeFailed,TimedOut,NetworkError,CancelledDestroyed,ReadError,WriteErrorA request that ends on one of those three is described and then dropped. It never reaches
Unbind, its result callback never runs and its session is never released, soForceFlushandShutdownwait out their own deadlines and the caller waits for a callback that is not coming.The three states join the same switch. That is the whole change, seven lines in
otlp_http_client.cc.The bundled curl client does not produce any of them, so this is reached through the installed
HttpClientinterface by a client the user supplies.SessionStateis part of that interface, and the header describes these three as a read error, a write error and a destroyed session, so an exporter is not in a position to decide which of them a client may use.Exactly-once is unchanged.
stopping_is a compare exchange and the first writer wins, so one of these arriving after a response has already been reported still reports nothing.Two cases in
otlp_http_exporter_custom_client_test.cccover it: each of the three delivered as the only terminal event, and each delivered after a response. Removing the three lines does not turn them red, it hangs the binary on a session that never settles, which is the shape the defect has for a user.@lalitb noted on #4448 that this can go ahead independently of the transport design. It changes no curl code.
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes