Skip to content

Commit 29678bd

Browse files
ekumpyannham
andauthored
feat!: implement HTTP common component (#1624)
# What does this PR do? This PR introduces `libdd-http-client`, a new crate providing a generic, backend-agnostic async HTTP client supporting multipart/form-data designed to be consumed by external language libraries (Python, Ruby, .NET, …) via FFI. This plan is to follow-up with a higher-level ddog-agent-specific layer (header injection, endpoint routing, etc.) on top of it. The client supports both a `hyper` and a `reqwest` backend, depending on the binary size/performance tradeoffs of consumers. Supported transport: - TCP (HTTP / HTTPS) - Unix Domain Socket - Windows Named Pipe Additional features: - Opt-in exponential backoff with jitter via `RetryConfig` - FIPS support # Motivation `dd-trace-py` and `dd-trace-rb` currently implement HTTP communication in their native languages (`http.client` / `net/http`). This creates three problems: 1. Instrumentation leakage: the SDK's own HTTP calls can be accidentally captured by the tracing instrumentation running in the same process. 2. VM lock contention: synchronous I/O in Python holds the GIL; doing this on a background thread blocks the host application. 3. Duplicated protocol logic: every SDK independently re-implements retries, UDS support, connection pooling, and FIPS TLS. A shared Rust HTTP client exposed over FFI solves all three: it runs outside the language runtime, is never instrumented by the tracer, and provides one canonical implementation of transport and resilience. # Additional Notes N/A # How to test the change? Several unit tests are included. This is an initial PR, and porper integration will be handled later. Co-authored-by: yannham <[email protected]>
1 parent 8d2029d commit 29678bd

28 files changed

Lines changed: 2498 additions & 25 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ libdd-crashtracker*/ @DataDog/libdatadog-profiling
4444
libdd-data-pipeline*/ @DataDog/libdatadog-apm
4545
libdd-ddsketch*/ @DataDog/libdatadog-apm @DataDog/apm-common-components-core
4646
libdd-dogstatsd-client @DataDog/apm-common-components-core
47+
libdd-http-client @DataDog/apm-common-components-core
4748
libdd-library-config*/ @DataDog/apm-sdk-capabilities-rust
4849
libdd-libunwind*/ @DataDog/libdatadog-profiling
4950
libdd-log*/ @DataDog/apm-common-components-core

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ jobs:
7171
run: cargo nextest run --workspace --features libdd-crashtracker/generate-unit-test-files --exclude builder --profile ci --test-threads=1 --verbose -E 'test(tracing_integration_tests::)'
7272
env:
7373
RUST_BACKTRACE: full
74+
- name: "[${{ steps.rust-version.outputs.version}}] cargo nextest run -p libdd-http-client (hyper-backend)"
75+
shell: bash
76+
run: cargo nextest run -p libdd-http-client --no-default-features --features hyper-backend,https --profile ci --verbose
77+
env:
78+
RUST_BACKTRACE: full
7479
- name: "[${{ steps.rust-version.outputs.version}}] RUSTFLAGS=\"-C prefer-dynamic\" cargo nextest run --package test_spawn_from_lib --features prefer-dynamic -E '!test(tracing_integration_tests::)'"
7580
shell: bash
7681
run: cargo nextest run --package test_spawn_from_lib --features prefer-dynamic -E '!test(tracing_integration_tests::)'

Cargo.lock

Lines changed: 75 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ members = [
4545
"libdd-ddsketch-ffi",
4646
"libdd-tinybytes",
4747
"libdd-dogstatsd-client",
48+
"libdd-http-client",
4849
"libdd-log",
4950
"libdd-log-ffi", "libdd-libunwind-sys",
5051
]

LICENSE-3rdparty.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
root_name: builder, build_common, tools, libdd-alloc, libdd-crashtracker, libdd-common, libdd-telemetry, libdd-ddsketch, libdd-libunwind-sys, libdd-crashtracker-ffi, libdd-common-ffi, datadog-ffe, datadog-ffe-ffi, datadog-ipc, datadog-ipc-macros, libdd-tinybytes, spawn_worker, cc_utils, libdd-library-config, libdd-trace-protobuf, libdd-library-config-ffi, datadog-live-debugger, libdd-data-pipeline, libdd-dogstatsd-client, libdd-trace-stats, libdd-trace-utils, libdd-trace-normalization, libdd-log, datadog-live-debugger-ffi, libdd-profiling, libdd-profiling-protobuf, libdd-profiling-ffi, libdd-data-pipeline-ffi, libdd-ddsketch-ffi, libdd-log-ffi, libdd-telemetry-ffi, symbolizer-ffi, datadog-profiling-replayer, datadog-remote-config, datadog-sidecar, datadog-sidecar-macros, datadog-sidecar-ffi, libdd-trace-obfuscation, datadog-tracer-flare, sidecar_mockgen, test_spawn_from_lib
1+
root_name: builder, build_common, tools, libdd-alloc, libdd-crashtracker, libdd-common, libdd-telemetry, libdd-ddsketch, libdd-libunwind-sys, libdd-crashtracker-ffi, libdd-common-ffi, datadog-ffe, datadog-ffe-ffi, datadog-ipc, datadog-ipc-macros, libdd-tinybytes, spawn_worker, cc_utils, libdd-library-config, libdd-trace-protobuf, libdd-library-config-ffi, datadog-live-debugger, libdd-data-pipeline, libdd-dogstatsd-client, libdd-trace-stats, libdd-trace-utils, libdd-trace-normalization, libdd-log, datadog-live-debugger-ffi, libdd-profiling, libdd-profiling-protobuf, libdd-profiling-ffi, libdd-data-pipeline-ffi, libdd-ddsketch-ffi, libdd-log-ffi, libdd-telemetry-ffi, symbolizer-ffi, datadog-profiling-replayer, datadog-remote-config, datadog-sidecar, datadog-sidecar-macros, datadog-sidecar-ffi, libdd-trace-obfuscation, datadog-tracer-flare, sidecar_mockgen, test_spawn_from_lib, bin_tests
22
third_party_libraries:
33
- package_name: addr2line
44
package_version: 0.24.2
@@ -2941,7 +2941,7 @@ third_party_libraries:
29412941
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
29422942
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29432943
- package_name: aws-lc-sys
2944-
package_version: 0.39.0
2944+
package_version: 0.39.1
29452945
repository: https://github.com/aws/aws-lc-rs
29462946
license: ISC AND (Apache-2.0 OR ISC) AND Apache-2.0 AND MIT AND BSD-3-Clause AND (Apache-2.0 OR ISC OR MIT) AND (Apache-2.0 OR ISC OR MIT-0)
29472947
licenses:
@@ -5708,7 +5708,7 @@ third_party_libraries:
57085708
This Source Code Form is "Incompatible With Secondary Licenses", as
57095709
defined by the Mozilla Public License, v. 2.0.
57105710
- package_name: cc
5711-
package_version: 1.2.57
5711+
package_version: 1.2.58
57125712
repository: https://github.com/rust-lang/cc-rs
57135713
license: MIT OR Apache-2.0
57145714
licenses:
@@ -6717,7 +6717,7 @@ third_party_libraries:
67176717
See the License for the specific language governing permissions and
67186718
limitations under the License.
67196719
- package_name: cmake
6720-
package_version: 0.1.57
6720+
package_version: 0.1.58
67216721
repository: https://github.com/rust-lang/cmake-rs
67226722
license: MIT OR Apache-2.0
67236723
licenses:
@@ -15148,9 +15148,9 @@ third_party_libraries:
1514815148
limitations under the License.
1514915149

1515015150
- package_name: itertools
15151-
package_version: 0.10.5
15151+
package_version: 0.11.0
1515215152
repository: https://github.com/rust-itertools/itertools
15153-
license: MIT/Apache-2.0
15153+
license: MIT OR Apache-2.0
1515415154
licenses:
1515515155
- license: MIT
1515615156
text: |
@@ -21659,7 +21659,7 @@ third_party_libraries:
2165921659
See the License for the specific language governing permissions and
2166021660
limitations under the License.
2166121661
- package_name: quinn-proto
21662-
package_version: 0.11.14
21662+
package_version: 0.11.13
2166321663
repository: https://github.com/quinn-rs/quinn
2166421664
license: MIT OR Apache-2.0
2166521665
licenses:

libdd-common/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub mod cstr;
2424
pub mod config;
2525
pub mod error;
2626
pub mod http_common;
27+
pub mod multipart;
2728
pub mod rate_limiter;
2829
pub mod tag;
2930
#[cfg(any(test, feature = "test-utils"))]

0 commit comments

Comments
 (0)