[BUGFIX] Complete an OTLP HTTP request on every state its client can end on - #4453
Open
thc1006 wants to merge 1 commit into
Open
[BUGFIX] Complete an OTLP HTTP request on every state its client can end on#4453thc1006 wants to merge 1 commit into
thc1006 wants to merge 1 commit into
Conversation
…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
marked this pull request as ready for review
August 19, 2026 20:20
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 whether a request is over from a switch that names seven states. The client can end a transfer on three more, and the switch below it recognises all three and logs them:CreateFailed,ConnectFailed,SendFailed,SSLHandshakeFailed,TimedOut,NetworkError,CancelledDestroyed,ReadError,WriteErrorSo a request that ends on one of those three arrives, is described, and is then dropped. It never reaches
Unbind, its result callback never runs, and its session is never released.ForceFlushandShutdownhave nothing to wait on but their own deadlines, and the caller is left waiting for a callback that is not coming.The three states join the same switch. Nothing else changes.
Why the exporter has to answer them
The bundled curl client does not currently produce any of the three, so this is reached through the installed
HttpClientinterface by a client the user supplies. That interface is a supported extension point,SessionStateis part of it, and the header describes these aserror reading response,error writing requestand a session destroyed. An exporter cannot decide which of them a client is allowed to use.Ordering does not change.
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. That is what the last case below holds.Checks
Four cases, all in
otlp_http_exporter_custom_client_test.cc, driven by the existing nosend client. Three are a parameterised case, one per state: deliver it as the only terminal event and require the result callback to have run exactly once withkFailure, andForceFlushwith a 50 ms deadline to report success rather than wait. The fourth delivers a response first and then each of the three, and requires the callback count to stay at one.Removing the three lines from the switch does not turn those cases red. It hangs the whole binary: without them the request never settles, so the
OtlpHttpClientdestructor waits for a session that is still outstanding and the run does not terminate. That is the same shape the defect has for a user, which is why it is worth saying rather than reporting a red assertion that does not exist.This is an exporter-side correctness fix over the installed custom
HttpClientinterface. It does not change the curl implementation and does not pre-commit anything in the transport design discussed in #4448, which is where @lalitb noted it can proceed independently.For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes