Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4266 +/- ##
==========================================
+ Coverage 82.61% 82.66% +0.05%
==========================================
Files 511 511
Lines 20132 20192 +60
==========================================
+ Hits 16631 16690 +59
- Misses 3501 3502 +1
🚀 New features to boost your workflow:
|
| return rc; | ||
| } | ||
|
|
||
| rc = SetCurlLongOption(CURLOPT_TCP_KEEPALIVE, 1L); |
There was a problem hiding this comment.
Would it be possible to expose this as a configuration option for HttpClient, OtlpHttpClient, and all HTTP-based exporters? That way users can opt-in rather than having it unconditionally enabled.
Also, I noticed CURLOPT_TCP_KEEPIDLE and CURLOPT_TCP_KEEPINTVL are being set without CURLOPT_TCP_KEEPALIVE. These two options are normally only effective when keep-alive is enabled, so we should probably set all three together.
There was a problem hiding this comment.
Hi @owent,
Thanks for the review.
My understanding is that the preferred direction is to make TCP keepalive opt-in (disabled by default) and expose it through HttpClient, OtlpHttpClient, and the HTTP-based exporters.
I was planning to expose a single boolean configuration (for CURLOPT_TCP_KEEPALIVE) while enabling the related libcurl behavior, rather than exposing additional public configuration for CURLOPT_TCP_KEEPIDLE and CURLOPT_TCP_KEEPINTVL unless you think those should also be configurable.
Does that match what you had in mind?
Thanks!
There was a problem hiding this comment.
I think that will be helpful to let CURLOPT_TCP_KEEPIDLE and CURLOPT_TCP_KEEPINTVL also be configurable.
There was a problem hiding this comment.
+1. I think these should be configurable together. If we only enable CURLOPT_TCP_KEEPALIVE, the timing still depends on libcurl/OS defaults, so it may not help users who need faster detection for half-open connections like in #3333.
…rs (#4266) - Make TCP keepalive opt-in ( default ) - Add and options - Propagate options through Request, OtlpHttpClient, and all OTLP HTTP exporters - Add unit tests for keepalive option propagation and curl request settings
af1e7f7 to
765872f
Compare
|
Thanks for working on this. Enabling TCP keepalive can be useful, but I don’t think we can say yet that it fixes #3333. TCP keepalive helps when a connection was established and the other side disappears without closing it. It does not help a connection still being created, such as the I’m also unsure about adding this setting to the common Request interface. Keepalive controls the underlying TCP connection, which may be reused for many requests. It is therefore better treated as a curl/client setting than as a property of one HTTP request. Changing the common virtual interface may also affect external custom HTTP clients. I suggest keeping this PR in draft for now. Let’s first add a small test that reproduces the long wait, identify whether the problem is in curl timeout handling or our session/shutdown logic, and discuss the right place for transport settings as part of #4448. |
Fixes #3333
Description
This PR fixes #3333 by enabling TCP keepalive on libcurl HTTP client connections.
Root Cause
When a remote endpoint silently disappears without closing the TCP connection, the client can remain connected to a half-open socket for an extended period. Since TCP keepalive is currently disabled, the exporter may remain blocked waiting on the connection.
Solution
Enable
CURLOPT_TCP_KEEPALIVEduringHttpOperation::Setup(). This allows libcurl and the underlying operating system to detect stale TCP connections using TCP keepalive mechanisms.Testing