diff --git a/Cargo.lock b/Cargo.lock index 6144732f..9713c073 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -426,10 +426,11 @@ dependencies = [ [[package]] name = "datadog-protos" version = "0.1.0" -source = "git+https://github.com/DataDog/saluki/?rev=c89b58e5784b985819baf11f13f7d35876741222#c89b58e5784b985819baf11f13f7d35876741222" +source = "git+https://github.com/DataDog/saluki/?rev=f863626dbfe3c59bb390985fa6530b0621c2a0a2#f863626dbfe3c59bb390985fa6530b0621c2a0a2" dependencies = [ "bytes", "prost", + "prost-types", "protobuf", "protobuf-codegen", "tonic", @@ -441,13 +442,11 @@ name = "datadog-serverless-compat" version = "0.1.0" dependencies = [ "datadog-trace-agent", - "datadog-trace-protobuf", - "datadog-trace-utils", "dogstatsd", + "libdd-trace-utils", "tokio", "tokio-util", "tracing", - "tracing-core", "tracing-subscriber", "zstd", ] @@ -458,43 +457,33 @@ version = "0.1.0" dependencies = [ "anyhow", "async-trait", - "datadog-trace-normalization", "datadog-trace-obfuscation", - "datadog-trace-protobuf", - "datadog-trace-utils", - "ddcommon", "duplicate", "http-body-util", "hyper", + "hyper-http-proxy", "hyper-util", + "libdd-common", + "libdd-trace-protobuf", + "libdd-trace-utils", "rmp-serde", "serde", "serde_json", "serial_test", "tempfile", "tokio", - "tower", "tracing", ] -[[package]] -name = "datadog-trace-normalization" -version = "21.0.0" -source = "git+https://github.com/DataDog/libdatadog/?rev=902b6a5296963b96c4faf355f6c53eec263b7568#902b6a5296963b96c4faf355f6c53eec263b7568" -dependencies = [ - "anyhow", - "datadog-trace-protobuf", -] - [[package]] name = "datadog-trace-obfuscation" -version = "21.0.0" -source = "git+https://github.com/DataDog/libdatadog/?rev=902b6a5296963b96c4faf355f6c53eec263b7568#902b6a5296963b96c4faf355f6c53eec263b7568" +version = "24.0.0" +source = "git+https://github.com/DataDog/libdatadog/?rev=6e559d75fd184d5cc46c0caf8b78c2b31a36af5e#6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" dependencies = [ "anyhow", - "datadog-trace-protobuf", - "datadog-trace-utils", - "ddcommon", + "libdd-common", + "libdd-trace-protobuf", + "libdd-trace-utils", "log", "percent-encoding", "regex", @@ -503,85 +492,10 @@ dependencies = [ "url", ] -[[package]] -name = "datadog-trace-protobuf" -version = "21.0.0" -source = "git+https://github.com/DataDog/libdatadog/?rev=902b6a5296963b96c4faf355f6c53eec263b7568#902b6a5296963b96c4faf355f6c53eec263b7568" -dependencies = [ - "prost", - "serde", - "serde_bytes", -] - -[[package]] -name = "datadog-trace-utils" -version = "21.0.0" -source = "git+https://github.com/DataDog/libdatadog/?rev=902b6a5296963b96c4faf355f6c53eec263b7568#902b6a5296963b96c4faf355f6c53eec263b7568" -dependencies = [ - "anyhow", - "bytes", - "cargo-platform", - "cargo_metadata", - "datadog-trace-normalization", - "datadog-trace-protobuf", - "ddcommon", - "flate2", - "futures", - "http-body-util", - "httpmock", - "hyper", - "hyper-http-proxy", - "prost", - "rand 0.8.5", - "rmp", - "rmp-serde", - "rmpv", - "serde", - "serde_json", - "tinybytes", - "tokio", - "tracing", - "urlencoding", - "zstd", -] - -[[package]] -name = "ddcommon" -version = "21.0.0" -source = "git+https://github.com/DataDog/libdatadog/?rev=902b6a5296963b96c4faf355f6c53eec263b7568#902b6a5296963b96c4faf355f6c53eec263b7568" -dependencies = [ - "anyhow", - "cc", - "const_format", - "futures", - "futures-core", - "futures-util", - "hex", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-rustls", - "hyper-util", - "libc", - "nix", - "pin-project", - "regex", - "rustls", - "rustls-native-certs", - "serde", - "static_assertions", - "thiserror 1.0.69", - "tokio", - "tokio-rustls", - "tower-service", - "windows-sys 0.52.0", -] - [[package]] name = "ddsketch-agent" version = "0.1.0" -source = "git+https://github.com/DataDog/saluki/?rev=c89b58e5784b985819baf11f13f7d35876741222#c89b58e5784b985819baf11f13f7d35876741222" +source = "git+https://github.com/DataDog/saluki/?rev=f863626dbfe3c59bb390985fa6530b0621c2a0a2#f863626dbfe3c59bb390985fa6530b0621c2a0a2" dependencies = [ "datadog-protos", "float-cmp", @@ -943,6 +857,12 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + [[package]] name = "headers" version = "0.4.0" @@ -1294,12 +1214,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.8.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", - "hashbrown 0.15.2", + "hashbrown 0.16.0", ] [[package]] @@ -1369,6 +1289,98 @@ version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +[[package]] +name = "libdd-common" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog/?rev=6e559d75fd184d5cc46c0caf8b78c2b31a36af5e#6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" +dependencies = [ + "anyhow", + "cc", + "const_format", + "futures", + "futures-core", + "futures-util", + "hex", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "libc", + "nix", + "pin-project", + "regex", + "rustls", + "rustls-native-certs", + "serde", + "static_assertions", + "thiserror 1.0.69", + "tokio", + "tokio-rustls", + "tower-service", + "windows-sys 0.52.0", +] + +[[package]] +name = "libdd-tinybytes" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog/?rev=6e559d75fd184d5cc46c0caf8b78c2b31a36af5e#6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" +dependencies = [ + "serde", +] + +[[package]] +name = "libdd-trace-normalization" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog/?rev=6e559d75fd184d5cc46c0caf8b78c2b31a36af5e#6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" +dependencies = [ + "anyhow", + "libdd-trace-protobuf", +] + +[[package]] +name = "libdd-trace-protobuf" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog/?rev=6e559d75fd184d5cc46c0caf8b78c2b31a36af5e#6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" +dependencies = [ + "prost", + "serde", + "serde_bytes", +] + +[[package]] +name = "libdd-trace-utils" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog/?rev=6e559d75fd184d5cc46c0caf8b78c2b31a36af5e#6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" +dependencies = [ + "anyhow", + "bytes", + "cargo-platform", + "cargo_metadata", + "flate2", + "futures", + "http-body-util", + "httpmock", + "hyper", + "indexmap", + "libdd-common", + "libdd-tinybytes", + "libdd-trace-normalization", + "libdd-trace-protobuf", + "prost", + "rand 0.8.5", + "rmp", + "rmp-serde", + "rmpv", + "serde", + "serde_json", + "tokio", + "tracing", + "urlencoding", + "zstd", +] + [[package]] name = "libloading" version = "0.8.6" @@ -2590,14 +2602,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "tinybytes" -version = "21.0.0" -source = "git+https://github.com/DataDog/libdatadog/?rev=902b6a5296963b96c4faf355f6c53eec263b7568#902b6a5296963b96c4faf355f6c53eec263b7568" -dependencies = [ - "serde", -] - [[package]] name = "tinystr" version = "0.7.6" @@ -2687,9 +2691,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.3" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +checksum = "7e581ba15a835f4d9ea06c55ab1bd4dce26fc53752c69a04aac00703bfb49ba9" dependencies = [ "async-trait", "base64 0.22.1", @@ -2708,9 +2712,9 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.12.3" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" +checksum = "eac6f67be712d12f0b41328db3137e0d0757645d8904b4cb7d51cd9c2279e847" dependencies = [ "prettyplease", "proc-macro2", diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index aa7392d4..74273011 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -39,11 +39,7 @@ crossbeam-utils,https://github.com/crossbeam-rs/crossbeam,MIT OR Apache-2.0,The crypto-common,https://github.com/RustCrypto/traits,MIT OR Apache-2.0,RustCrypto Developers dashmap,https://github.com/xacrimon/dashmap,MIT,Acrimon datadog-protos,https://github.com/DataDog/saluki,Apache-2.0,The datadog-protos Authors -datadog-trace-normalization,https://github.com/DataDog/libdatadog,Apache-2.0,David Lee datadog-trace-obfuscation,https://github.com/DataDog/libdatadog,Apache-2.0,David Lee -datadog-trace-protobuf,https://github.com/DataDog/libdatadog,Apache-2.0,David Lee -datadog-trace-utils,https://github.com/DataDog/libdatadog,Apache-2.0,The datadog-trace-utils Authors -ddcommon,https://github.com/DataDog/libdatadog,Apache-2.0,The ddcommon Authors ddsketch-agent,https://github.com/DataDog/saluki,Apache-2.0,The ddsketch-agent Authors derive_more,https://github.com/JelteF/derive_more,MIT,Jelte Fennema derive_more-impl,https://github.com/JelteF/derive_more,MIT,Jelte Fennema @@ -113,6 +109,11 @@ js-sys,https://github.com/rustwasm/wasm-bindgen/tree/master/crates/js-sys,MIT OR lazy_static,https://github.com/rust-lang-nursery/lazy-static.rs,MIT OR Apache-2.0,Marvin Löbel lazycell,https://github.com/indiv0/lazycell,MIT OR Apache-2.0,"Alex Crichton , Nikita Pekin " libc,https://github.com/rust-lang/libc,MIT OR Apache-2.0,The Rust Project Developers +libdd-common,https://github.com/DataDog/libdatadog/tree/main/datadog-common,Apache-2.0,The libdd-common Authors +libdd-tinybytes,https://github.com/DataDog/libdatadog/tree/main/libdd-tinybytes,Apache-2.0,The libdd-tinybytes Authors +libdd-trace-normalization,https://github.com/DataDog/libdatadog/tree/main/libdd-trace-normalization,Apache-2.0,David Lee +libdd-trace-protobuf,https://github.com/DataDog/libdatadog/tree/main/libdd-trace-protobuf,Apache-2.0,The libdd-trace-protobuf Authors +libdd-trace-utils,https://github.com/DataDog/libdatadog/tree/main/libdd-trace-utils,Apache-2.0,The libdd-trace-utils Authors libloading,https://github.com/nagisa/rust_libloading,ISC,Simonas Kazlauskas linux-raw-sys,https://github.com/sunfishcode/linux-raw-sys,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Dan Gohman litemap,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers @@ -222,7 +223,6 @@ tempfile,https://github.com/Stebalien/tempfile,MIT OR Apache-2.0,"Steven Allen < thiserror,https://github.com/dtolnay/thiserror,MIT OR Apache-2.0,David Tolnay thiserror-impl,https://github.com/dtolnay/thiserror,MIT OR Apache-2.0,David Tolnay thread_local,https://github.com/Amanieu/thread_local-rs,MIT OR Apache-2.0,Amanieu d'Antras -tinybytes,https://github.com/DataDog/libdatadog,Apache-2.0,The tinybytes Authors tinystr,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers tinyvec,https://github.com/Lokathor/tinyvec,Zlib OR Apache-2.0 OR MIT,Lokathor tinyvec_macros,https://github.com/Soveu/tinyvec_macros,MIT OR Apache-2.0 OR Zlib,Soveu diff --git a/crates/datadog-serverless-compat/Cargo.toml b/crates/datadog-serverless-compat/Cargo.toml index 46c4f87c..cac9b6f4 100644 --- a/crates/datadog-serverless-compat/Cargo.toml +++ b/crates/datadog-serverless-compat/Cargo.toml @@ -7,14 +7,18 @@ description = "Binary to run trace-agent and dogstatsd servers in Serverless env [dependencies] datadog-trace-agent = { path = "../datadog-trace-agent" } -datadog-trace-protobuf = { git = "https://github.com/DataDog/libdatadog/", rev = "902b6a5296963b96c4faf355f6c53eec263b7568" } -datadog-trace-utils = { git = "https://github.com/DataDog/libdatadog/", rev = "902b6a5296963b96c4faf355f6c53eec263b7568" } +libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog/", rev = "6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" } dogstatsd = { path = "../dogstatsd", default-features = true } -tokio = { version = "1", features = ["macros", "rt-multi-thread"]} +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tokio-util = { version = "0.7", default-features = false } tracing = { version = "0.1", default-features = false } -tracing-core = { version = "0.1", default-features = false } -tracing-subscriber = { version = "0.3", default-features = false, features = ["std", "registry", "fmt", "env-filter", "tracing-log"] } +tracing-subscriber = { version = "0.3", default-features = false, features = [ + "std", + "registry", + "fmt", + "env-filter", + "tracing-log", +] } zstd = { version = "0.13.3", default-features = false } [[bin]] diff --git a/crates/datadog-serverless-compat/src/main.rs b/crates/datadog-serverless-compat/src/main.rs index 4354609b..5b91a911 100644 --- a/crates/datadog-serverless-compat/src/main.rs +++ b/crates/datadog-serverless-compat/src/main.rs @@ -23,7 +23,7 @@ use datadog_trace_agent::{ trace_processor, }; -use datadog_trace_utils::{config_utils::read_cloud_env, trace_utils::EnvironmentType}; +use libdd_trace_utils::{config_utils::read_cloud_env, trace_utils::EnvironmentType}; use dogstatsd::{ aggregator_service::{AggregatorHandle, AggregatorService}, diff --git a/crates/datadog-trace-agent/Cargo.toml b/crates/datadog-trace-agent/Cargo.toml index d614e391..149a0e13 100644 --- a/crates/datadog-trace-agent/Cargo.toml +++ b/crates/datadog-trace-agent/Cargo.toml @@ -10,23 +10,28 @@ bench = false [dependencies] anyhow = "1.0" hyper = { version = "1.6", features = ["http1", "client", "server"] } -hyper-util = {version = "0.1", features = ["service"] } -tower = { version = "0.5.2", features = ["util"] } +hyper-http-proxy = { version = "1.1.0", default-features = false, features = [ + "rustls-tls-webpki-roots", +] } +hyper-util = { version = "0.1", features = ["service"] } http-body-util = "0.1" -tokio = { version = "1", features = ["macros", "rt-multi-thread"]} +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } async-trait = "0.1.64" tracing = { version = "0.1", default-features = false } serde = { version = "1.0.145", features = ["derive"] } serde_json = "1.0" -ddcommon = { git = "https://github.com/DataDog/libdatadog/", rev = "902b6a5296963b96c4faf355f6c53eec263b7568" } -datadog-trace-protobuf = { git = "https://github.com/DataDog/libdatadog/", rev = "902b6a5296963b96c4faf355f6c53eec263b7568" } -datadog-trace-utils = { git = "https://github.com/DataDog/libdatadog/", rev = "902b6a5296963b96c4faf355f6c53eec263b7568", features = ["mini_agent"] } -datadog-trace-normalization = { git = "https://github.com/DataDog/libdatadog/", rev = "902b6a5296963b96c4faf355f6c53eec263b7568" } -datadog-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog/", rev = "902b6a5296963b96c4faf355f6c53eec263b7568" } +libdd-common = { git = "https://github.com/DataDog/libdatadog/", rev = "6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" } +libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog/", rev = "6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" } +libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog/", rev = "6e559d75fd184d5cc46c0caf8b78c2b31a36af5e", features = [ + "mini_agent", +] } +datadog-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog/", rev = "6e559d75fd184d5cc46c0caf8b78c2b31a36af5e" } [dev-dependencies] rmp-serde = "1.1.1" serial_test = "2.0.0" duplicate = "0.4.1" tempfile = "3.3.0" -datadog-trace-utils = { git = "https://github.com/DataDog/libdatadog/", rev = "902b6a5296963b96c4faf355f6c53eec263b7568", features=["test-utils"] } +libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog/", rev = "6e559d75fd184d5cc46c0caf8b78c2b31a36af5e", features = [ + "test-utils", +] } diff --git a/crates/datadog-trace-agent/src/aggregator.rs b/crates/datadog-trace-agent/src/aggregator.rs index 1f7a5949..de66a018 100644 --- a/crates/datadog-trace-agent/src/aggregator.rs +++ b/crates/datadog-trace-agent/src/aggregator.rs @@ -1,7 +1,7 @@ // Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -use datadog_trace_utils::send_data::SendData; +use libdd_trace_utils::send_data::SendData; use std::collections::VecDeque; /// Maximum content size per payload uncompressed in bytes, @@ -69,10 +69,10 @@ impl TraceAggregator { #[cfg(test)] #[allow(clippy::unwrap_used)] mod tests { - use datadog_trace_utils::{ + use libdd_common::Endpoint; + use libdd_trace_utils::{ trace_utils::TracerHeaderTags, tracer_payload::TracerPayloadCollection, }; - use ddcommon::Endpoint; use super::*; diff --git a/crates/datadog-trace-agent/src/config.rs b/crates/datadog-trace-agent/src/config.rs index 31459257..13dfd8a3 100644 --- a/crates/datadog-trace-agent/src/config.rs +++ b/crates/datadog-trace-agent/src/config.rs @@ -1,7 +1,7 @@ // Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -use ddcommon::Endpoint; +use libdd_common::Endpoint; use std::borrow::Cow; use std::collections::HashMap; use std::env; @@ -9,11 +9,11 @@ use std::str::FromStr; use std::sync::OnceLock; use datadog_trace_obfuscation::obfuscation_config; -use datadog_trace_utils::config_utils::{ +use libdd_trace_utils::config_utils::{ read_cloud_env, trace_intake_url, trace_intake_url_prefixed, trace_stats_url, trace_stats_url_prefixed, }; -use datadog_trace_utils::trace_utils; +use libdd_trace_utils::trace_utils; const DEFAULT_DOGSTATSD_PORT: u16 = 8125; diff --git a/crates/datadog-trace-agent/src/env_verifier.rs b/crates/datadog-trace-agent/src/env_verifier.rs index a22d929c..7e56dace 100644 --- a/crates/datadog-trace-agent/src/env_verifier.rs +++ b/crates/datadog-trace-agent/src/env_verifier.rs @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 use async_trait::async_trait; -use ddcommon::hyper_migration; use http_body_util::BodyExt; use hyper::{Method, Request}; +use libdd_common::hyper_migration; use serde::{Deserialize, Serialize}; use std::env; use std::fs; @@ -14,7 +14,7 @@ use std::sync::Arc; use std::time::{Duration, Instant}; use tracing::{debug, error}; -use datadog_trace_utils::trace_utils; +use libdd_trace_utils::trace_utils; const GCP_METADATA_URL: &str = "http://metadata.google.internal/computeMetadata/v1/?recursive=true"; const AZURE_LINUX_FUNCTION_ROOT_PATH_STR: &str = "/home/site/wwwroot"; @@ -354,9 +354,9 @@ async fn ensure_azure_function_environment( #[cfg(test)] mod tests { use async_trait::async_trait; - use datadog_trace_utils::trace_utils; - use ddcommon::hyper_migration; use hyper::{body::Bytes, Response, StatusCode}; + use libdd_common::hyper_migration; + use libdd_trace_utils::trace_utils; use serde_json::json; use serial_test::serial; use std::{env, fs, path::Path, time::Duration}; diff --git a/crates/datadog-trace-agent/src/http_utils.rs b/crates/datadog-trace-agent/src/http_utils.rs index 7f6b9400..241204ad 100644 --- a/crates/datadog-trace-agent/src/http_utils.rs +++ b/crates/datadog-trace-agent/src/http_utils.rs @@ -1,12 +1,12 @@ // Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -use ddcommon::hyper_migration; use hyper::{ header, http::{self, HeaderMap}, Response, StatusCode, }; +use libdd_common::hyper_migration; use serde_json::json; use tracing::{debug, error}; @@ -113,11 +113,11 @@ pub fn verify_request_content_length( #[cfg(test)] mod tests { - use ddcommon::hyper_migration; use http_body_util::BodyExt; use hyper::header; use hyper::HeaderMap; use hyper::StatusCode; + use libdd_common::hyper_migration; use super::verify_request_content_length; diff --git a/crates/datadog-trace-agent/src/mini_agent.rs b/crates/datadog-trace-agent/src/mini_agent.rs index 552c69d3..dcfa6aeb 100644 --- a/crates/datadog-trace-agent/src/mini_agent.rs +++ b/crates/datadog-trace-agent/src/mini_agent.rs @@ -1,9 +1,9 @@ // Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -use ddcommon::hyper_migration; use hyper::service::service_fn; use hyper::{http, Method, Response, StatusCode}; +use libdd_common::hyper_migration; use serde_json::json; use std::io; use std::net::SocketAddr; @@ -14,9 +14,9 @@ use tracing::{debug, error}; use crate::http_utils::log_and_create_http_response; use crate::{config, env_verifier, stats_flusher, stats_processor, trace_flusher, trace_processor}; -use datadog_trace_protobuf::pb; -use datadog_trace_utils::trace_utils; -use datadog_trace_utils::trace_utils::SendData; +use libdd_trace_protobuf::pb; +use libdd_trace_utils::trace_utils; +use libdd_trace_utils::trace_utils::SendData; const MINI_AGENT_PORT: usize = 8126; const TRACE_ENDPOINT_PATH: &str = "/v0.4/traces"; diff --git a/crates/datadog-trace-agent/src/stats_flusher.rs b/crates/datadog-trace-agent/src/stats_flusher.rs index f2f6547c..fbadeda9 100644 --- a/crates/datadog-trace-agent/src/stats_flusher.rs +++ b/crates/datadog-trace-agent/src/stats_flusher.rs @@ -6,8 +6,8 @@ use std::{sync::Arc, time}; use tokio::sync::{mpsc::Receiver, Mutex}; use tracing::{debug, error}; -use datadog_trace_protobuf::pb; -use datadog_trace_utils::stats_utils; +use libdd_trace_protobuf::pb; +use libdd_trace_utils::stats_utils; use crate::config::Config; diff --git a/crates/datadog-trace-agent/src/stats_processor.rs b/crates/datadog-trace-agent/src/stats_processor.rs index 56bb0615..d15be854 100644 --- a/crates/datadog-trace-agent/src/stats_processor.rs +++ b/crates/datadog-trace-agent/src/stats_processor.rs @@ -5,13 +5,13 @@ use std::sync::Arc; use std::time::UNIX_EPOCH; use async_trait::async_trait; -use ddcommon::hyper_migration; use hyper::{http, StatusCode}; +use libdd_common::hyper_migration; use tokio::sync::mpsc::Sender; use tracing::debug; -use datadog_trace_protobuf::pb; -use datadog_trace_utils::stats_utils; +use libdd_trace_protobuf::pb; +use libdd_trace_utils::stats_utils; use crate::config::Config; use crate::http_utils::{self, log_and_create_http_response}; diff --git a/crates/datadog-trace-agent/src/trace_flusher.rs b/crates/datadog-trace-agent/src/trace_flusher.rs index b33be204..c65fd4b8 100644 --- a/crates/datadog-trace-agent/src/trace_flusher.rs +++ b/crates/datadog-trace-agent/src/trace_flusher.rs @@ -2,12 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 use async_trait::async_trait; -use std::{sync::Arc, time}; +use std::{error::Error, sync::Arc, time}; use tokio::sync::{mpsc::Receiver, Mutex}; use tracing::{debug, error}; -use datadog_trace_utils::trace_utils; -use datadog_trace_utils::trace_utils::SendData; +use libdd_common::{hyper_migration, GenericHttpClient}; +use libdd_trace_utils::trace_utils; +use libdd_trace_utils::trace_utils::SendData; use crate::aggregator::TraceAggregator; use crate::config::Config; @@ -100,12 +101,17 @@ impl TraceFlusher for ServerlessTraceFlusher { // Since we return the original traces on error, we need to clone them before coalescing let traces_clone = traces.clone(); + let http_client = + match ServerlessTraceFlusher::get_http_client(self.config.proxy_url.as_ref()) { + Ok(client) => client, + Err(e) => { + error!("Failed to create HTTP client: {e:?}"); + return None; + } + }; + for coalesced_traces in trace_utils::coalesce_send_data(traces) { - match coalesced_traces - .send_proxy(self.config.proxy_url.as_deref()) - .await - .last_result - { + match coalesced_traces.send(&http_client).await.last_result { Ok(_) => debug!("Successfully flushed traces"), Err(e) => { error!("Error sending trace: {e:?}"); @@ -117,3 +123,27 @@ impl TraceFlusher for ServerlessTraceFlusher { None } } + +impl ServerlessTraceFlusher { + fn get_http_client( + proxy_https: Option<&String>, + ) -> Result< + GenericHttpClient>, + Box, + > { + if let Some(proxy) = proxy_https { + let proxy = + hyper_http_proxy::Proxy::new(hyper_http_proxy::Intercept::Https, proxy.parse()?); + let proxy_connector = hyper_http_proxy::ProxyConnector::from_proxy( + libdd_common::connector::Connector::default(), + proxy, + )?; + Ok(hyper_migration::client_builder().build(proxy_connector)) + } else { + let proxy_connector = hyper_http_proxy::ProxyConnector::new( + libdd_common::connector::Connector::default(), + )?; + Ok(hyper_migration::client_builder().build(proxy_connector)) + } + } +} diff --git a/crates/datadog-trace-agent/src/trace_processor.rs b/crates/datadog-trace-agent/src/trace_processor.rs index dbdf65d1..a226f0bb 100644 --- a/crates/datadog-trace-agent/src/trace_processor.rs +++ b/crates/datadog-trace-agent/src/trace_processor.rs @@ -4,16 +4,16 @@ use std::sync::Arc; use async_trait::async_trait; -use ddcommon::hyper_migration; use hyper::{http, StatusCode}; +use libdd_common::hyper_migration; use tokio::sync::mpsc::Sender; use tracing::debug; use datadog_trace_obfuscation::obfuscate::obfuscate_span; -use datadog_trace_protobuf::pb; -use datadog_trace_utils::trace_utils::{self}; -use datadog_trace_utils::trace_utils::{EnvironmentType, SendData}; -use datadog_trace_utils::tracer_payload::{TraceChunkProcessor, TracerPayloadCollection}; +use libdd_trace_protobuf::pb; +use libdd_trace_utils::trace_utils::{self}; +use libdd_trace_utils::trace_utils::{EnvironmentType, SendData}; +use libdd_trace_utils::tracer_payload::{TraceChunkProcessor, TracerPayloadCollection}; use crate::{ config::Config, @@ -167,13 +167,13 @@ mod tests { config::{Config, Tags}, trace_processor::{self, TraceProcessor, TRACER_PAYLOAD_FUNCTION_TAGS_TAG_KEY}, }; - use datadog_trace_protobuf::pb; - use datadog_trace_utils::test_utils::{create_test_gcp_json_span, create_test_gcp_span}; - use datadog_trace_utils::trace_utils::MiniAgentMetadata; - use datadog_trace_utils::{ + use libdd_common::{hyper_migration, Endpoint}; + use libdd_trace_protobuf::pb; + use libdd_trace_utils::test_utils::{create_test_gcp_json_span, create_test_gcp_span}; + use libdd_trace_utils::trace_utils::MiniAgentMetadata; + use libdd_trace_utils::{ test_utils::create_test_json_span, trace_utils, tracer_payload::TracerPayloadCollection, }; - use ddcommon::{hyper_migration, Endpoint}; fn get_current_timestamp_nanos() -> i64 { UNIX_EPOCH.elapsed().unwrap().as_nanos() as i64 diff --git a/crates/dogstatsd/Cargo.toml b/crates/dogstatsd/Cargo.toml index 73e07d3a..14f7255e 100644 --- a/crates/dogstatsd/Cargo.toml +++ b/crates/dogstatsd/Cargo.toml @@ -8,8 +8,8 @@ license.workspace = true bench = false [dependencies] -datadog-protos = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "c89b58e5784b985819baf11f13f7d35876741222" } -ddsketch-agent = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "c89b58e5784b985819baf11f13f7d35876741222" } +datadog-protos = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "f863626dbfe3c59bb390985fa6530b0621c2a0a2" } +ddsketch-agent = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "f863626dbfe3c59bb390985fa6530b0621c2a0a2" } derive_more = { version = "1.0.0", features = ["display", "into"] } hashbrown = { version = "0.15.0", default-features = false, features = ["inline-more"] } protobuf = { version = "3.5.0", default-features = false }