Skip to content
Open
Show file tree
Hide file tree
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
126 changes: 76 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/capabilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ http = "1"
bytes = "1.4"
futures-core = "0.3"
anyhow = "1"
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "3081603d3c74f209be4e3be951f78a1a7469397f" }
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "1b9b7a26f54f116a0f6525abdcd2013b341921a7" }

[dev-dependencies]
wasm-bindgen-test = "0.3"
19 changes: 17 additions & 2 deletions crates/capabilities/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern "C" {
body_ptr: *const u8,
body_len: u32,
wasm_memory: &JsValue,
no_pooling: bool,
) -> js_sys::Promise;

#[wasm_bindgen(js_name = "setStorage")]
Expand All @@ -52,18 +53,31 @@ extern "C" {
/// [`crate::WasmCapabilities`] alongside the sleep and log-output capabilities
/// that `TraceExporter` requires.
#[derive(Debug, Clone)]
pub struct WasmHttpClient;
pub struct WasmHttpClient {
no_pooling: bool,
}

impl HttpClientCapability for WasmHttpClient {
fn new_client() -> Self {
Self
Self { no_pooling: false }
}

/// Requested by libdatadog's telemetry worker, whose sends are paced further
/// apart than the agent's HTTP keep-alive: a pooled socket is typically
/// half-closed by the next send, so reuse fails with EOF/ECONNRESET.
/// libdatadog used to force a fresh socket with a `Connection: close` header
/// and dropped it in #2286, because the agent's telemetry proxy mishandles
/// that hop-by-hop header.
fn new_without_connection_pooling() -> Self {
Self { no_pooling: true }
}

#[allow(clippy::manual_async_fn)]
fn request(
&self,
req: http::Request<Bytes>,
) -> impl Future<Output = Result<http::Response<Bytes>, HttpError>> + MaybeSend {
let no_pooling = self.no_pooling;
async move {
let scheme = req.uri().scheme_str().unwrap_or("http");

Expand Down Expand Up @@ -106,6 +120,7 @@ impl HttpClientCapability for WasmHttpClient {
body.as_ptr(),
body.len() as u32,
WASM_MEMORY.as_ref(),
no_pooling,
))
.await
.map_err(|e| HttpError::Network(anyhow::anyhow!("{:?}", e)))?;
Expand Down
Loading
Loading