Skip to content

Commit f8e6dd9

Browse files
[mq] [skip ddci] working branch - merge 38ff9d1 on top of main at c7c315b
{"baseBranch":"main","baseCommit":"c7c315baf9a5baff11d94d0af1c99ce086049bfa","createdAt":"2026-04-21T07:58:58.395512Z","headSha":"38ff9d1d6d8ba8a5b4523551a42ce3e0a41e56ae","id":"ad37155a-afa8-40f7-96cb-56f2017fccb0","priority":"200","pullRequestNumber":"1895","queuedAt":"2026-04-21T07:58:58.394011Z","status":"STATUS_QUEUED"}
2 parents 00a93e9 + 38ff9d1 commit f8e6dd9

11 files changed

Lines changed: 109 additions & 97 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datadog-sidecar/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ anyhow = { version = "1.0" }
1818
arrayref = "0.3.7"
1919
priority-queue = "2.1.1"
2020
libdd-common = { path = "../libdd-common" }
21+
libdd-capabilities = { path = "../libdd-capabilities", version = "0.1.0" }
2122
datadog-sidecar-macros = { path = "../datadog-sidecar-macros" }
2223

2324
libdd-telemetry = { path = "../libdd-telemetry", features = ["tracing"] }

datadog-sidecar/src/service/agent_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use datadog_ipc::platform::NamedShmHandle;
1616
use futures::future::Shared;
1717
use futures::FutureExt;
1818
use http::uri::PathAndQuery;
19-
use libdd_common::DefaultHttpClient;
19+
use libdd_capabilities_impl::DefaultHttpClient;
2020
use libdd_common::{Endpoint, MutexExt};
2121
use libdd_data_pipeline::agent_info::schema::AgentInfoStruct;
2222
use libdd_data_pipeline::agent_info::{fetch_info_with_state, FetchInfoStatus};

datadog-sidecar/src/service/tracing/trace_flusher.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use super::TraceSendData;
55
use crate::agent_remote_config::AgentRemoteConfigWriter;
66
use datadog_ipc::platform::NamedShmHandle;
77
use futures::future::join_all;
8-
use libdd_common::capabilities::HttpClientTrait;
9-
use libdd_common::{DefaultHttpClient, Endpoint, MutexExt};
8+
use libdd_capabilities::HttpClientTrait;
9+
use libdd_capabilities_impl::DefaultHttpClient;
10+
use libdd_common::{Endpoint, MutexExt};
1011
use libdd_trace_utils::trace_utils;
1112
use libdd_trace_utils::trace_utils::SendData;
1213
use libdd_trace_utils::trace_utils::SendDataResult;

libdd-capabilities-impl/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ http = "1"
2121
libdd-capabilities = { path = "../libdd-capabilities", version = "0.1.0" }
2222
libdd-common = { path = "../libdd-common", version = "3.0.2", default-features = false }
2323

24+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
25+
http-body-util = "0.1"
26+
2427
[features]
2528
default = ["https"]
2629
https = ["libdd-common/https"]
Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,60 @@
11
// Copyright 2026-Present Datadog, Inc. https://www.datadoghq.com/
22
// SPDX-License-Identifier: Apache-2.0
33

4-
//! Re-exports `DefaultHttpClient` from `libdd-common`, where it lives alongside
5-
//! the hyper infrastructure it wraps.
4+
//! Native HTTP client implementation backed by hyper.
65
7-
pub use libdd_common::DefaultHttpClient;
6+
mod native {
7+
use libdd_capabilities::http::{HttpClientTrait, HttpError};
8+
use libdd_capabilities::maybe_send::MaybeSend;
9+
use libdd_common::connector::Connector;
10+
use libdd_common::http_common::{new_default_client, Body, GenericHttpClient};
11+
12+
use http_body_util::BodyExt;
13+
14+
#[derive(Clone)]
15+
pub struct DefaultHttpClient {
16+
client: GenericHttpClient<Connector>,
17+
}
18+
19+
impl std::fmt::Debug for DefaultHttpClient {
20+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21+
f.debug_struct("DefaultHttpClient").finish()
22+
}
23+
}
24+
25+
impl HttpClientTrait for DefaultHttpClient {
26+
fn new_client() -> Self {
27+
Self {
28+
client: new_default_client(),
29+
}
30+
}
31+
32+
#[allow(clippy::manual_async_fn)]
33+
fn request(
34+
&self,
35+
req: http::Request<bytes::Bytes>,
36+
) -> impl std::future::Future<Output = Result<http::Response<bytes::Bytes>, HttpError>> + MaybeSend
37+
{
38+
let client = self.client.clone();
39+
async move {
40+
let hyper_req = req.map(Body::from_bytes);
41+
42+
let response = client
43+
.request(hyper_req)
44+
.await
45+
.map_err(|e| HttpError::Network(e.into()))?;
46+
47+
let (parts, body) = response.into_parts();
48+
let collected = body
49+
.collect()
50+
.await
51+
.map_err(|e| HttpError::ResponseBody(e.into()))?
52+
.to_bytes();
53+
54+
Ok(http::Response::from_parts(parts, collected))
55+
}
56+
}
57+
}
58+
}
59+
60+
pub use native::DefaultHttpClient;

libdd-capabilities-impl/src/lib.rs

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,53 @@
99
1010
mod http;
1111

12-
use core::future::Future;
12+
pub use libdd_capabilities::HttpClientTrait;
1313

14+
#[cfg(not(target_arch = "wasm32"))]
1415
pub use http::DefaultHttpClient;
15-
use libdd_capabilities::http::HttpError;
16-
pub use libdd_capabilities::HttpClientTrait;
17-
use libdd_capabilities::MaybeSend;
18-
19-
/// Bundle struct for native platform capabilities.
20-
///
21-
/// Delegates to [`DefaultHttpClient`] for HTTP. As more capability traits are
22-
/// added (spawn, sleep, etc.), additional fields and impls are added here
23-
/// without changing the type identity — consumers see the same
24-
/// `NativeCapabilities` throughout.
25-
///
26-
/// Individual capability traits keep minimal per-function bounds (e.g.
27-
/// functions that only need HTTP require just `H: HttpClientTrait`, not the
28-
/// full bundle) so that native callers like the sidecar can use
29-
/// `DefaultHttpClient` directly without pulling in this bundle.
30-
#[derive(Clone, Debug)]
31-
pub struct NativeCapabilities {
32-
http: DefaultHttpClient,
33-
}
3416

35-
impl HttpClientTrait for NativeCapabilities {
36-
fn new_client() -> Self {
37-
Self {
38-
http: DefaultHttpClient::new_client(),
39-
}
17+
#[cfg(not(target_arch = "wasm32"))]
18+
mod native {
19+
use core::future::Future;
20+
21+
use libdd_capabilities::http::HttpError;
22+
use libdd_capabilities::MaybeSend;
23+
24+
use super::DefaultHttpClient;
25+
use super::HttpClientTrait;
26+
27+
/// Bundle struct for native platform capabilities.
28+
///
29+
/// Delegates to [`DefaultHttpClient`] for HTTP. As more capability traits are
30+
/// added (spawn, sleep, etc.), additional fields and impls are added here
31+
/// without changing the type identity — consumers see the same
32+
/// `NativeCapabilities` throughout.
33+
///
34+
/// Individual capability traits keep minimal per-function bounds (e.g.
35+
/// functions that only need HTTP require just `H: HttpClientTrait`, not the
36+
/// full bundle) so that native callers like the sidecar can use
37+
/// `DefaultHttpClient` directly without pulling in this bundle.
38+
#[derive(Clone, Debug)]
39+
pub struct NativeCapabilities {
40+
http: DefaultHttpClient,
4041
}
4142

42-
fn request(
43-
&self,
44-
req: ::http::Request<bytes::Bytes>,
45-
) -> impl Future<Output = Result<::http::Response<bytes::Bytes>, HttpError>> + MaybeSend {
46-
self.http.request(req)
43+
impl HttpClientTrait for NativeCapabilities {
44+
fn new_client() -> Self {
45+
Self {
46+
http: DefaultHttpClient::new_client(),
47+
}
48+
}
49+
50+
fn request(
51+
&self,
52+
req: ::http::Request<bytes::Bytes>,
53+
) -> impl Future<Output = Result<::http::Response<bytes::Bytes>, HttpError>> + MaybeSend
54+
{
55+
self.http.request(req)
56+
}
4757
}
4858
}
59+
60+
#[cfg(not(target_arch = "wasm32"))]
61+
pub use native::NativeCapabilities;

libdd-common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ crate-type = ["lib"]
1616
bench = false
1717

1818
[dependencies]
19-
libdd-capabilities = { path = "../libdd-capabilities", version = "0.1.0" }
2019
anyhow = "1.0"
2120
futures = "0.3"
2221
futures-core = { version = "0.3.0", default-features = false }

libdd-common/src/capabilities/mod.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

libdd-common/src/http_common.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -300,56 +300,6 @@ mod native {
300300
pub fn client_builder() -> hyper_util::client::legacy::Builder {
301301
hyper_util::client::legacy::Client::builder(hyper_util::rt::TokioExecutor::default())
302302
}
303-
304-
// --- DefaultHttpClient: portable HttpClientTrait backed by hyper ---
305-
306-
use libdd_capabilities::http::{HttpClientTrait, HttpError};
307-
use libdd_capabilities::maybe_send::MaybeSend;
308-
309-
#[derive(Clone)]
310-
pub struct DefaultHttpClient {
311-
client: GenericHttpClient<Connector>,
312-
}
313-
314-
impl std::fmt::Debug for DefaultHttpClient {
315-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
316-
f.debug_struct("DefaultHttpClient").finish()
317-
}
318-
}
319-
320-
impl HttpClientTrait for DefaultHttpClient {
321-
fn new_client() -> Self {
322-
Self {
323-
client: new_default_client(),
324-
}
325-
}
326-
327-
#[allow(clippy::manual_async_fn)]
328-
fn request(
329-
&self,
330-
req: http::Request<bytes::Bytes>,
331-
) -> impl std::future::Future<Output = Result<http::Response<bytes::Bytes>, HttpError>> + MaybeSend
332-
{
333-
let client = self.client.clone();
334-
async move {
335-
let hyper_req = req.map(Body::from_bytes);
336-
337-
let response = client
338-
.request(hyper_req)
339-
.await
340-
.map_err(|e| HttpError::Network(e.into()))?;
341-
342-
let (parts, body) = response.into_parts();
343-
let collected = body
344-
.collect()
345-
.await
346-
.map_err(|e| HttpError::ResponseBody(e.into()))?
347-
.to_bytes();
348-
349-
Ok(http::Response::from_parts(parts, collected))
350-
}
351-
}
352-
}
353303
}
354304

355305
#[cfg(not(target_arch = "wasm32"))]

0 commit comments

Comments
 (0)