Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions bottlecap/src/traces/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,25 @@ pub fn create_client(
let proxy =
hyper_http_proxy::Proxy::new(hyper_http_proxy::Intercept::Https, proxy.parse()?);
let proxy_connector = hyper_http_proxy::ProxyConnector::from_proxy(connector, proxy)?;
let client = http_common::client_builder().build(proxy_connector);
// Disable connection pooling to avoid stale connections after Lambda freeze/resume.
// In Lambda, the execution environment can be frozen for seconds to minutes between
// invocations. Pooled connections become stale during this time, causing failures
// when reused. Setting pool_max_idle_per_host(0) ensures each request gets a fresh
// connection, matching the pattern used in libdatadog's new_client_periodic().
let client = http_common::client_builder()
.pool_max_idle_per_host(0)
.build(proxy_connector);
Comment on lines +176 to +183
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pooling configuration and explanatory comment are duplicated across both proxy branches. To reduce drift risk and simplify future changes, consider factoring the builder configuration into a single let builder = http_common::client_builder().pool_max_idle_per_host(0); (or a small helper) and reuse it for both build(...) calls; likewise, keep one canonical comment (or a brief reference) in one place.

Copilot uses AI. Check for mistakes.
debug!(
"HTTP_CLIENT | Proxy connector created with proxy: {:?}",
proxy_https
);
Ok(client)
} else {
let proxy_connector = hyper_http_proxy::ProxyConnector::new(connector)?;
Ok(http_common::client_builder().build(proxy_connector))
// Disable connection pooling to avoid stale connections after Lambda freeze/resume.
// See comment above for detailed explanation.
Ok(http_common::client_builder()
.pool_max_idle_per_host(0)
.build(proxy_connector))
Comment on lines +191 to +195
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pooling configuration and explanatory comment are duplicated across both proxy branches. To reduce drift risk and simplify future changes, consider factoring the builder configuration into a single let builder = http_common::client_builder().pool_max_idle_per_host(0); (or a small helper) and reuse it for both build(...) calls; likewise, keep one canonical comment (or a brief reference) in one place.

Copilot uses AI. Check for mistakes.
}
}
Loading