-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set default timeout on curl handles #66
Conversation
|
src/datadog/curl.cpp
Outdated
@@ -464,6 +473,7 @@ CURLMcode CurlImpl::log_on_error(CURLMcode result) { | |||
void CurlImpl::run() { | |||
int num_messages_remaining; | |||
CURLMsg *message; | |||
const int max_wait_milliseconds = 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
post
and libcurl both will awaken the thread if necessary. What purpose does having this timeout less than the request timeout serve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's from another experimentation. Back when my hypothesis was drain()
has been called but the thread is waiting for an event from curl or that previous 10s timeout. In that scenario, drain()
would be useless. Is it happening ? I don't know 🤷♂️ One thing I am sure of is it is not here on purpose, so good and catch and:
- revert
The consensus is that library is only used by us for webserver integrations. I do not know if we want to be more than that, but if we do, it will be useful to let users of the library make use of their own transport library. That's a discussion for another time. Your recommandation is going deeper and makes everything more explicit. I do like it even if I am still not convinced the removal of a deadline in All in all, my only suggestion is to increase the shutdown timeout. It must always be bigger than the request timeout to actually give a chance for the request to be processed. Otherwise, in some cases (shutdown) it will makes no difference with our current solution. I may be wrong, what's your thought? |
You're right that this code is used only for reverse proxy integrations. My question is: what usage do we want the class interfaces to allow? If our only concern is nginx-datadog (Envoy does its own thing), then an unbounded drain with a hard-coded libcurl timeout is fine. It's what nginx wants, and it's one timeout instead of two. But reading the code without knowledge of nginx,
The request timeout is not an upper bound on typical request latency, but a line that we draw in the sand to say "if it's taking this long, something is wrong and the application owner might want to know about it." When we set the
That fine, it's a vague claim on my part. Here's a compromise between what I recommend and what you have proposed:
|
BenchmarksBenchmark execution time: 2023-11-13 12:45:10 Comparing candidate commit 5fad53e in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 0 metrics, 0 unstable metrics. scenario:BM_TraceTinyCCSource
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since my suggestions were merged, I approve of these changes.
Hopefully the merge conflicts aren't too much trouble to sort out.
- curl default implementation set a 2s default timeout - drain waits indefinitely until the predicate is valid
- Need to talk about `clock`
- `easy_setopt_timeout` -> `easy_setopt_timeout_ms` - remove `HTTPClient::Deadline` alias - pass `Clock` into `CurlImpl` - `finalize_config(const TracerConfig&, const Clock&)` - `FinalizedTracerConfig::clock` - `finalize_config(const DatadogAgentConfig&, const Clock&)` - `default_http_client(const shared_ptr<Logger>&, const Clock&)` - `FinalizedDatadogAgentConfig::clock` - `DatadogAgent::DatadogAgent` - more specific `Error::CURL_DEADLINE_EXCEEDED_BEFORE_REQUEST_START`, and a little context in the error message - `dummy_timeout` -> `dummy_deadline` - `TEST_CASE` for `Error::CURL_DEADLINE_EXCEEDED_BEFORE_REQUEST_START`
f52ddad
to
abed062
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove dependency on `nginx-version-info` to build the module locally. Only `build-in-docker` need it now. - Rework CMake target. - Update README. - Remove support for old NGINX versions.
Why?
Now,
drain
guarantee after being executed all ongoing requests are processed (unless requests are posted while draining 👀) and if for whatever reason the request could not be processed, like timeout, the reason will be logged.Content: