diff --git a/src/native/Cargo.lock b/src/native/Cargo.lock index 8375ef1a699..63af29033df 100644 --- a/src/native/Cargo.lock +++ b/src/native/Cargo.lock @@ -216,8 +216,8 @@ dependencies = [ [[package]] name = "build_common" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" +version = "24.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" dependencies = [ "cbindgen", "serde", @@ -474,310 +474,19 @@ dependencies = [ "typenum", ] -[[package]] -name = "data-pipeline" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "arc-swap", - "bytes", - "datadog-ddsketch", - "datadog-trace-protobuf", - "datadog-trace-stats", - "datadog-trace-utils", - "ddcommon", - "ddtelemetry", - "dogstatsd-client", - "either", - "http", - "http-body-util", - "hyper", - "hyper-util", - "rmp-serde", - "serde", - "serde_json", - "sha2", - "tinybytes", - "tokio", - "tokio-util", - "tracing", - "uuid", -] - -[[package]] -name = "datadog-alloc" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "allocator-api2", - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "datadog-crashtracker" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "backtrace", - "blazesym", - "cc", - "chrono", - "ddcommon", - "ddtelemetry", - "http", - "libc", - "nix", - "num-derive", - "num-traits", - "os_info", - "page_size", - "portable-atomic", - "rand", - "schemars", - "serde", - "serde_json", - "symbolic-common", - "symbolic-demangle", - "thiserror", - "tokio", - "uuid", - "windows 0.59.0", -] - -[[package]] -name = "datadog-ddsketch" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "prost", -] - -[[package]] -name = "datadog-library-config" -version = "0.0.2" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "memfd", - "rand", - "rmp", - "rmp-serde", - "serde", - "serde_yaml", -] - -[[package]] -name = "datadog-log" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "chrono", - "tracing", - "tracing-appender", - "tracing-subscriber", -] - -[[package]] -name = "datadog-profiling" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "bitmaps", - "byteorder", - "bytes", - "chrono", - "datadog-alloc", - "datadog-profiling-protobuf", - "ddcommon", - "futures", - "http", - "http-body-util", - "hyper", - "hyper-multipart-rfc7578", - "indexmap", - "mime", - "prost", - "rustc-hash 1.1.0", - "serde", - "serde_json", - "target-triple", - "tokio", - "tokio-util", - "zstd", -] - -[[package]] -name = "datadog-profiling-ffi" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "build_common", - "datadog-profiling", - "ddcommon", - "ddcommon-ffi", - "function_name", - "futures", - "http-body-util", - "hyper", - "libc", - "serde_json", - "tokio-util", -] - -[[package]] -name = "datadog-profiling-protobuf" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "prost", -] - -[[package]] -name = "datadog-trace-normalization" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "datadog-trace-protobuf", -] - -[[package]] -name = "datadog-trace-protobuf" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "prost", - "serde", - "serde_bytes", -] - -[[package]] -name = "datadog-trace-stats" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "datadog-ddsketch", - "datadog-trace-protobuf", - "datadog-trace-utils", - "hashbrown 0.15.5", -] - -[[package]] -name = "datadog-trace-utils" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "bytes", - "datadog-trace-normalization", - "datadog-trace-protobuf", - "ddcommon", - "futures", - "http-body-util", - "hyper", - "prost", - "rand", - "rmp", - "rmp-serde", - "rmpv", - "serde", - "serde_json", - "tinybytes", - "tokio", - "tracing", -] - -[[package]] -name = "ddcommon" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -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", - "tokio", - "tokio-rustls", - "tower-service", - "windows-sys 0.52.0", -] - -[[package]] -name = "ddcommon-ffi" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "build_common", - "chrono", - "crossbeam-queue", - "ddcommon", - "hyper", - "serde", -] - -[[package]] -name = "ddtelemetry" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "base64", - "datadog-ddsketch", - "ddcommon", - "futures", - "hashbrown 0.15.5", - "http", - "http-body-util", - "hyper", - "hyper-util", - "libc", - "serde", - "serde_json", - "sys-info", - "tokio", - "tokio-util", - "tracing", - "uuid", - "winver", -] - [[package]] name = "ddtrace-native" version = "0.1.0" dependencies = [ "anyhow", "build_common", - "data-pipeline", - "datadog-crashtracker", - "datadog-ddsketch", - "datadog-library-config", - "datadog-log", - "datadog-profiling-ffi", - "ddcommon", + "libdd-common", + "libdd-crashtracker", + "libdd-data-pipeline", + "libdd-ddsketch", + "libdd-library-config", + "libdd-log", + "libdd-profiling-ffi", "pyo3", "pyo3-build-config", "tracing", @@ -811,19 +520,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "dogstatsd-client" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "anyhow", - "cadence", - "ddcommon", - "http", - "serde", - "tracing", -] - [[package]] name = "dunce" version = "1.0.5" @@ -1300,6 +996,320 @@ version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +[[package]] +name = "libdd-alloc" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "allocator-api2", + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "libdd-common" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +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", + "tokio", + "tokio-rustls", + "tower-service", + "windows-sys 0.52.0", +] + +[[package]] +name = "libdd-common-ffi" +version = "24.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "build_common", + "chrono", + "crossbeam-queue", + "hyper", + "libdd-common", + "serde", +] + +[[package]] +name = "libdd-crashtracker" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "backtrace", + "blazesym", + "cc", + "chrono", + "http", + "libc", + "libdd-common", + "libdd-telemetry", + "nix", + "num-derive", + "num-traits", + "os_info", + "page_size", + "portable-atomic", + "rand", + "schemars", + "serde", + "serde_json", + "symbolic-common", + "symbolic-demangle", + "thiserror", + "tokio", + "uuid", + "windows 0.59.0", +] + +[[package]] +name = "libdd-data-pipeline" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "arc-swap", + "bytes", + "either", + "http", + "http-body-util", + "hyper", + "hyper-util", + "libdd-common", + "libdd-ddsketch", + "libdd-dogstatsd-client", + "libdd-telemetry", + "libdd-tinybytes", + "libdd-trace-protobuf", + "libdd-trace-stats", + "libdd-trace-utils", + "rmp-serde", + "serde", + "serde_json", + "sha2", + "tokio", + "tokio-util", + "tracing", + "uuid", +] + +[[package]] +name = "libdd-ddsketch" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "prost", +] + +[[package]] +name = "libdd-dogstatsd-client" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "cadence", + "http", + "libdd-common", + "serde", + "tracing", +] + +[[package]] +name = "libdd-library-config" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "memfd", + "rand", + "rmp", + "rmp-serde", + "serde", + "serde_yaml", +] + +[[package]] +name = "libdd-log" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "chrono", + "tracing", + "tracing-appender", + "tracing-subscriber", +] + +[[package]] +name = "libdd-profiling" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "bitmaps", + "byteorder", + "bytes", + "chrono", + "futures", + "http", + "http-body-util", + "hyper", + "hyper-multipart-rfc7578", + "indexmap", + "libdd-alloc", + "libdd-common", + "libdd-profiling-protobuf", + "lz4_flex", + "mime", + "prost", + "rustc-hash 1.1.0", + "serde", + "serde_json", + "target-triple", + "tokio", + "tokio-util", + "zstd", +] + +[[package]] +name = "libdd-profiling-ffi" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "build_common", + "function_name", + "futures", + "http-body-util", + "hyper", + "libc", + "libdd-common", + "libdd-common-ffi", + "libdd-profiling", + "serde_json", + "tokio-util", +] + +[[package]] +name = "libdd-profiling-protobuf" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "prost", +] + +[[package]] +name = "libdd-telemetry" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "base64", + "futures", + "hashbrown 0.15.5", + "http", + "http-body-util", + "hyper", + "hyper-util", + "libc", + "libdd-common", + "libdd-ddsketch", + "serde", + "serde_json", + "sys-info", + "tokio", + "tokio-util", + "tracing", + "uuid", + "winver", +] + +[[package]] +name = "libdd-tinybytes" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "serde", +] + +[[package]] +name = "libdd-trace-normalization" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "libdd-trace-protobuf", +] + +[[package]] +name = "libdd-trace-protobuf" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "prost", + "serde", + "serde_bytes", +] + +[[package]] +name = "libdd-trace-stats" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "hashbrown 0.15.5", + "libdd-ddsketch", + "libdd-trace-protobuf", + "libdd-trace-utils", +] + +[[package]] +name = "libdd-trace-utils" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=v24.0.0#3445414c9ba4fefc76be46cf7e2f998986592892" +dependencies = [ + "anyhow", + "bytes", + "futures", + "http-body-util", + "hyper", + "indexmap", + "libdd-common", + "libdd-tinybytes", + "libdd-trace-normalization", + "libdd-trace-protobuf", + "prost", + "rand", + "rmp", + "rmp-serde", + "rmpv", + "serde", + "serde_json", + "tokio", + "tracing", +] + [[package]] name = "libloading" version = "0.8.9" @@ -1322,6 +1332,15 @@ version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +[[package]] +name = "lz4_flex" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a8cbbb2831780bc3b9c15a41f5b49222ef756b6730a95f3decfdd15903eb5a3" +dependencies = [ + "twox-hash", +] + [[package]] name = "matchers" version = "0.2.0" @@ -2270,14 +2289,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tinybytes" -version = "23.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=v23.0.0#c4a66e2075084b68174077b8306ba92e76be2240" -dependencies = [ - "serde", -] - [[package]] name = "tokio" version = "1.48.0" @@ -2438,6 +2449,16 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "static_assertions", +] + [[package]] name = "typenum" version = "1.19.0" diff --git a/src/native/Cargo.toml b/src/native/Cargo.toml index cdb9c79099e..c4f5aea89d7 100644 --- a/src/native/Cargo.toml +++ b/src/native/Cargo.toml @@ -11,26 +11,26 @@ opt-level = 's' codegen-units = 1 [features] -crashtracker = ["dep:anyhow", "dep:datadog-crashtracker"] -profiling = ["dep:datadog-profiling-ffi"] +crashtracker = ["dep:anyhow", "dep:libdd-crashtracker"] +profiling = ["dep:libdd-profiling-ffi"] [dependencies] anyhow = { version = "1.0", optional = true } -datadog-crashtracker = { git = "https://github.com/DataDog/libdatadog", rev = "v23.0.0", optional = true } -datadog-ddsketch = { git = "https://github.com/DataDog/libdatadog", rev = "v23.0.0" } -datadog-library-config = { git = "https://github.com/DataDog/libdatadog", rev = "v23.0.0" } -datadog-log = { git = "https://github.com/DataDog/libdatadog", rev = "v23.0.0" } -data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "v23.0.0" } -datadog-profiling-ffi = { git = "https://github.com/DataDog/libdatadog", rev = "v23.0.0", optional = true, features = [ +libdd-crashtracker = { git = "https://github.com/DataDog/libdatadog", rev = "v24.0.0", optional = true } +libdd-ddsketch = { git = "https://github.com/DataDog/libdatadog", rev = "v24.0.0" } +libdd-library-config = { git = "https://github.com/DataDog/libdatadog", rev = "v24.0.0" } +libdd-log = { git = "https://github.com/DataDog/libdatadog", rev = "v24.0.0" } +libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "v24.0.0" } +libdd-profiling-ffi = { git = "https://github.com/DataDog/libdatadog", rev = "v24.0.0", optional = true, features = [ "cbindgen", ] } -ddcommon = { git = "https://github.com/DataDog/libdatadog", rev = "v23.0.0" } +libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "v24.0.0" } pyo3 = { version = "0.25", features = ["extension-module", "anyhow"] } tracing = { version = "0.1", default-features = false } [build-dependencies] pyo3-build-config = "0.25" -build_common = { git = "https://github.com/DataDog/libdatadog", rev = "v23.0.0", features = [ +build_common = { git = "https://github.com/DataDog/libdatadog", rev = "v24.0.0", features = [ "cbindgen", ] } diff --git a/src/native/crashtracker.rs b/src/native/crashtracker.rs index f20c6906b3a..25e44823c50 100644 --- a/src/native/crashtracker.rs +++ b/src/native/crashtracker.rs @@ -4,10 +4,10 @@ use std::sync::atomic::{AtomicU8, Ordering}; use std::sync::Once; use std::time::Duration; -use datadog_crashtracker::{ +use libdd_common::Endpoint; +use libdd_crashtracker::{ CrashtrackerConfiguration, CrashtrackerReceiverConfig, Metadata, StacktraceCollection, }; -use ddcommon::Endpoint; use pyo3::prelude::*; pub trait RustWrapper { @@ -20,7 +20,7 @@ pub trait RustWrapper { } } -// We redefine the Enum here to expose it to Python as datadog_crashtracker::StacktraceCollection +// We redefine the Enum here to expose it to Python as libdd_crashtracker::StacktraceCollection // is defined in an external crate. #[pyclass( eq, @@ -92,7 +92,7 @@ impl CrashtrackerConfigurationPy { use_alt_stack, endpoint, resolve_frames, - datadog_crashtracker::default_signals(), + libdd_crashtracker::default_signals(), Some(Duration::from_millis(timeout_ms)), unix_socket_path, true, /* demangle_names */ @@ -235,7 +235,7 @@ pub fn crashtracker_init<'py>( if let (Some(config), Some(receiver_config), Some(metadata)) = (config_opt, receiver_config_opt, metadata_opt) { - match datadog_crashtracker::init(config, receiver_config, metadata) { + match libdd_crashtracker::init(config, receiver_config, metadata) { Ok(_) => CRASHTRACKER_STATUS .store(CrashtrackerStatus::Initialized as u8, Ordering::SeqCst), Err(e) => { @@ -269,7 +269,7 @@ pub fn crashtracker_on_fork<'py>( // Note to self: is it possible to call crashtracker_on_fork before crashtracker_init? // dd-trace-py seems to start crashtracker early on. - datadog_crashtracker::on_fork(inner_config, inner_receiver_config, inner_metadata) + libdd_crashtracker::on_fork(inner_config, inner_receiver_config, inner_metadata) } #[pyfunction(name = "crashtracker_status")] @@ -286,5 +286,5 @@ pub fn crashtracker_status() -> anyhow::Result { // binary names for the receiver, since Python installs the script as a command. #[pyfunction(name = "crashtracker_receiver")] pub fn crashtracker_receiver() -> anyhow::Result<()> { - datadog_crashtracker::receiver_entry_point_stdin() + libdd_crashtracker::receiver_entry_point_stdin() } diff --git a/src/native/data_pipeline/exceptions.rs b/src/native/data_pipeline/exceptions.rs index 2d0d1ee8236..491752e8dbe 100644 --- a/src/native/data_pipeline/exceptions.rs +++ b/src/native/data_pipeline/exceptions.rs @@ -1,4 +1,4 @@ -use data_pipeline::trace_exporter::error::TraceExporterError; +use libdd_data_pipeline::trace_exporter::error::TraceExporterError; use pyo3::{create_exception, exceptions::PyException, prelude::*, PyErr}; create_exception!( diff --git a/src/native/data_pipeline/mod.rs b/src/native/data_pipeline/mod.rs index 8868c24a10f..3fcba76ce0f 100644 --- a/src/native/data_pipeline/mod.rs +++ b/src/native/data_pipeline/mod.rs @@ -1,4 +1,4 @@ -use data_pipeline::trace_exporter::{ +use libdd_data_pipeline::trace_exporter::{ agent_response::AgentResponse, TelemetryConfig, TraceExporter, TraceExporterBuilder, TraceExporterInputFormat, TraceExporterOutputFormat, }; diff --git a/src/native/ddsketch.rs b/src/native/ddsketch.rs index f56881513f7..3491deb8b08 100644 --- a/src/native/ddsketch.rs +++ b/src/native/ddsketch.rs @@ -2,7 +2,7 @@ use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use pyo3::types::PyBytes; -use datadog_ddsketch::DDSketch; +use libdd_ddsketch::DDSketch; #[pyclass(name = "DDSketch", module = "ddtrace.internal._native")] pub struct DDSketchPy { diff --git a/src/native/library_config.rs b/src/native/library_config.rs index 10a4b255590..bb1c9bd08f8 100644 --- a/src/native/library_config.rs +++ b/src/native/library_config.rs @@ -1,4 +1,4 @@ -use datadog_library_config::{ +use libdd_library_config::{ tracer_metadata::{store_tracer_metadata, AnonymousFileHandle, TracerMetadata}, Configurator, ProcessInfo, }; @@ -42,7 +42,7 @@ impl PyConfigurator { &ProcessInfo::detect_global("python".to_string()), ); match res_config { - datadog_library_config::LoggedResult::Ok(config, logs) => { + libdd_library_config::LoggedResult::Ok(config, logs) => { // Previously, `libdatadog` printed debug logs to stderr. However, // in v21.0.0, we changed the behavior to buffer them and return // them in the logs returned by this `LoggedResult`. @@ -60,7 +60,7 @@ impl PyConfigurator { } Ok(list.into()) } - datadog_library_config::LoggedResult::Err(e) => { + libdd_library_config::LoggedResult::Err(e) => { let err_msg = format!("Failed to get configuration: {e:?}"); Err(PyException::new_err(err_msg)) } diff --git a/src/native/log.rs b/src/native/log.rs index a2ae09a1431..ff6019a7d72 100644 --- a/src/native/log.rs +++ b/src/native/log.rs @@ -6,7 +6,7 @@ pub mod logger { use pyo3::types::PyDict; use pyo3::{exceptions::PyValueError, PyResult}; - use datadog_log::logger::{ + use libdd_log::logger::{ logger_configure_file, logger_configure_std, logger_disable_file, logger_disable_std, logger_set_log_level, FileConfig, LogEventLevel, StdConfig, StdTarget, }; diff --git a/tests/appsec/iast/conftest.py b/tests/appsec/iast/conftest.py index 7e5d57ba296..900b8d5fbb1 100644 --- a/tests/appsec/iast/conftest.py +++ b/tests/appsec/iast/conftest.py @@ -86,12 +86,18 @@ def iast_context_defaults(): @pytest.fixture def iast_context_deduplication_enabled(tracer): - yield from iast_context(dict(DD_IAST_ENABLED="true"), deduplication=True, vulnerabilities_per_requests=2) + yield from iast_context( + dict(DD_IAST_ENABLED="true", DD_IAST_REQUEST_SAMPLING="100.0"), + deduplication=True, + vulnerabilities_per_requests=2, + ) @pytest.fixture def iast_context_2_vulnerabilities_per_requests(tracer): - yield from iast_context(dict(DD_IAST_ENABLED="true"), vulnerabilities_per_requests=2) + yield from iast_context( + dict(DD_IAST_ENABLED="true", DD_IAST_REQUEST_SAMPLING="100.0"), vulnerabilities_per_requests=2 + ) @pytest.fixture diff --git a/tests/appsec/iast/taint_tracking/test_native_taint_range.py b/tests/appsec/iast/taint_tracking/test_native_taint_range.py index 4af8d439f4f..38e2056422d 100644 --- a/tests/appsec/iast/taint_tracking/test_native_taint_range.py +++ b/tests/appsec/iast/taint_tracking/test_native_taint_range.py @@ -602,13 +602,23 @@ def test_context_race_conditions_threads(caplog, telemetry_writer): destroying contexts """ _end_iast_context_and_oce() + # Clear telemetry logs from previous tests + telemetry_writer._logs.clear() + pool = ThreadPool(processes=3) results_async = [pool.apply_async(reset_contexts_loop) for _ in range(20)] results = [res.get() for res in results_async] + pool.close() + pool.join() + assert results.count(True) <= 2 log_messages = [record.message for record in caplog.get_records("call")] assert len([message for message in log_messages if IAST_VALID_LOG.search(message)]) == 0 - list_metrics_logs = list(telemetry_writer._logs) + + # Filter out telemetry connection errors which are expected in test environment + list_metrics_logs = [ + log for log in telemetry_writer._logs if not log["message"].startswith("failed to send, dropping") + ] assert len(list_metrics_logs) == 0 diff --git a/tests/appsec/iast/test_overhead_control_engine.py b/tests/appsec/iast/test_overhead_control_engine.py index 3c28e472bed..0b970cfc8f8 100644 --- a/tests/appsec/iast/test_overhead_control_engine.py +++ b/tests/appsec/iast/test_overhead_control_engine.py @@ -1,12 +1,15 @@ from time import sleep +from ddtrace.appsec._iast._iast_env import _get_iast_env from ddtrace.appsec._iast._iast_request_context import get_iast_reporter +from ddtrace.appsec._iast._iast_request_context_base import is_iast_request_enabled from ddtrace.appsec._iast._taint_tracking._context import clear_all_request_context_slots from ddtrace.appsec._iast._taint_tracking._context import debug_context_array_free_slots_number from ddtrace.appsec._iast._taint_tracking._context import debug_context_array_size from ddtrace.appsec._iast._taint_tracking._context import finish_request_context from ddtrace.appsec._iast._taint_tracking._context import start_request_context from ddtrace.appsec._iast.sampling.vulnerability_detection import reset_request_vulnerabilities +from ddtrace.appsec._iast.taint_sinks.weak_hash import WeakHash from ddtrace.internal.settings.asm import config as asm_config @@ -46,13 +49,36 @@ def function_with_vulnerabilities_1(tracer): def test_oce_max_vulnerabilities_per_request(iast_context_deduplication_enabled): import hashlib + # Reset deduplication cache to ensure clean state + WeakHash._prepare_report._reset_cache() + + # Verify IAST context is enabled + assert is_iast_request_enabled(), "IAST request context should be enabled" + m = hashlib.md5() m.update(b"Nobody inspects") - m.digest() - m.digest() - m.digest() - m.digest() + # Each digest() call must be on a different line to avoid deduplication + result1 = m.digest() # vulnerability 1 + result2 = m.digest() # vulnerability 2 + result3 = m.digest() # This should not be reported (exceeds max) + result4 = m.digest() # This should not be reported (exceeds max) + + # Ensure all digest calls completed + assert result1 is not None and result2 is not None and result3 is not None and result4 is not None + span_report = get_iast_reporter() + if span_report is None: + # Debug: check if any vulnerabilities were attempted + env = _get_iast_env() + if env: + print( + f"DEBUG: vulnerability_budget={env.vulnerability_budget}, " + f"vulnerabilities_request_limit={env.vulnerabilities_request_limit}" + ) + assert False, ( + f"IAST reporter should be initialized after vulnerability detection. " + f"IAST enabled: {is_iast_request_enabled()}, env: {env is not None}" + ) assert len(span_report.vulnerabilities) == asm_config._iast_max_vulnerabilities_per_requests @@ -60,16 +86,46 @@ def test_oce_max_vulnerabilities_per_request(iast_context_deduplication_enabled) def test_oce_reset_vulnerabilities_report(iast_context_deduplication_enabled): import hashlib + # Reset deduplication cache to ensure clean state + WeakHash._prepare_report._reset_cache() + + # Verify IAST context is enabled + assert is_iast_request_enabled(), "IAST request context should be enabled" + m = hashlib.md5() m.update(b"Nobody inspects") - m.digest() - m.digest() - m.digest() - reset_request_vulnerabilities() - m.digest() + # Each digest() call must be on a different line to avoid deduplication + result1 = m.digest() # vulnerability 1 + result2 = m.digest() # vulnerability 2 + result3 = m.digest() # This should not be reported (exceeds max) + + # Ensure all digest calls completed + assert result1 is not None and result2 is not None and result3 is not None + # Ensure reporter exists before reset span_report = get_iast_reporter() + if span_report is None: + # Debug: check if any vulnerabilities were attempted + env = _get_iast_env() + if env: + print( + f"DEBUG: vulnerability_budget={env.vulnerability_budget}, " + f"vulnerabilities_request_limit={env.vulnerabilities_request_limit}" + ) + assert ( + False + ), f"IAST reporter should exist before reset. IAST enabled: {is_iast_request_enabled()}, env: {env is not None}" + + initial_count = len(span_report.vulnerabilities) + assert initial_count == asm_config._iast_max_vulnerabilities_per_requests + reset_request_vulnerabilities() + result4 = m.digest() # vulnerability 3 (after reset) + assert result4 is not None + + span_report = get_iast_reporter() + assert span_report is not None, "IAST reporter should still exist after reset" + # After reset, we should have the original 2 vulnerabilities + 1 new one = 3 total assert len(span_report.vulnerabilities) == asm_config._iast_max_vulnerabilities_per_requests + 1 diff --git a/tests/appsec/iast/test_telemetry.py b/tests/appsec/iast/test_telemetry.py index 64ba623bc63..24df3c3051b 100644 --- a/tests/appsec/iast/test_telemetry.py +++ b/tests/appsec/iast/test_telemetry.py @@ -174,21 +174,29 @@ def test_metric_request_tainted(no_request_sampling, telemetry_writer): assert filtered_metrics == ["executed.source", "request.tainted"] assert len(filtered_metrics) == 2, "Expected 2 generate_metrics" assert span.get_metric(IAST_SPAN_TAGS.TELEMETRY_REQUEST_TAINTED) > 0 - assert span.get_metric(IAST_SPAN_TAGS.TELEMETRY_EXECUTED_SOURCE + ".http_request_parameter") > 0 def test_log_metric(telemetry_writer): - with override_global_config(dict(_iast_debug=True)): + # Clear any existing logs first + telemetry_writer._logs.clear() + # Reset the deduplication cache to ensure clean state + _set_iast_error_metric._reset_cache() + + with override_global_config( + dict(_iast_enabled=True, _iast_debug=True, _iast_deduplication_enabled=False, _iast_request_sampling=100.0) + ): _set_iast_error_metric("test_format_key_error_and_no_log_metric raises") list_metrics_logs = list(telemetry_writer._logs) - assert len(list_metrics_logs) == 1 + assert len(list_metrics_logs) == 1, f"Expected 1 log entry, got {len(list_metrics_logs)}" assert list_metrics_logs[0]["message"] == "test_format_key_error_and_no_log_metric raises" assert "stack_trace" not in list_metrics_logs[0].keys() def test_log_metric_debug_disabled(telemetry_writer): - with override_global_config(dict(_iast_debug=False)): + with override_global_config( + dict(_iast_enabled=True, _iast_debug=False, _iast_deduplication_enabled=False, _iast_request_sampling=100.0) + ): _set_iast_error_metric("test_log_metric_debug_disabled raises") list_metrics_logs = list(telemetry_writer._logs) @@ -196,12 +204,19 @@ def test_log_metric_debug_disabled(telemetry_writer): def test_log_metric_debug_deduplication(telemetry_writer): - with override_global_config(dict(_iast_debug=True)): + # Clear any existing logs first + telemetry_writer._logs.clear() + # Reset the deduplication cache to ensure clean state + _set_iast_error_metric._reset_cache() + + with override_global_config( + dict(_iast_enabled=True, _iast_debug=True, _iast_deduplication_enabled=False, _iast_request_sampling=100.0) + ): for i in range(10): _set_iast_error_metric("test_log_metric_debug_deduplication raises 2") list_metrics_logs = list(telemetry_writer._logs) - assert len(list_metrics_logs) == 1 + assert len(list_metrics_logs) == 1, f"Expected 1 log entry, got {len(list_metrics_logs)}" assert list_metrics_logs[0]["message"] == "test_log_metric_debug_deduplication raises 2" assert "stack_trace" not in list_metrics_logs[0].keys() @@ -216,12 +231,19 @@ def test_log_metric_debug_disabled_deduplication(telemetry_writer): def test_log_metric_debug_deduplication_different_messages(telemetry_writer): - with override_global_config(dict(_iast_debug=True)): + # Clear any existing logs first + telemetry_writer._logs.clear() + # Reset the deduplication cache to ensure clean state + _set_iast_error_metric._reset_cache() + + with override_global_config( + dict(_iast_enabled=True, _iast_debug=True, _iast_deduplication_enabled=False, _iast_request_sampling=100.0) + ): for i in range(10): _set_iast_error_metric(f"test_log_metric_debug_deduplication_different_messages raises {i}") list_metrics_logs = list(telemetry_writer._logs) - assert len(list_metrics_logs) == 10 + assert len(list_metrics_logs) == 10, f"Expected 10 log entries, got {len(list_metrics_logs)}" assert list_metrics_logs[0]["message"].startswith( "test_log_metric_debug_deduplication_different_messages raises" ) diff --git a/tests/internal/crashtracker/utils.py b/tests/internal/crashtracker/utils.py index 7ef880e1410..7581e7aeec5 100644 --- a/tests/internal/crashtracker/utils.py +++ b/tests/internal/crashtracker/utils.py @@ -146,14 +146,13 @@ def get_crash_report(test_agent_client: TestAgentClient) -> TestAgentRequest: # We want at least the crash report assert len(crash_messages) == 2, f"Expected at least 2 messages; got {len(crash_messages)}" - # Find the crash report (the one with "is_crash":"true") crash_report = None for message in crash_messages: - if b"is_crash:true" in message["body"]: + if b'"level":"ERROR"' in message["body"]: crash_report = message break + assert crash_report is not None, "Could not find crash report with level ERROR tag" - assert crash_report is not None, "Could not find crash report with 'is_crash:true' tag" return crash_report @@ -162,14 +161,13 @@ def get_crash_ping(test_agent_client: TestAgentClient) -> TestAgentRequest: crash_messages = get_all_crash_messages(test_agent_client) assert len(crash_messages) == 2, f"Expected at least 2 messages; got {len(crash_messages)}" - # Find the crash ping (the one with "is_crash_ping":"true") crash_ping = None for message in crash_messages: - if b"is_crash_ping:true" in message["body"]: + if b'"level":"DEBUG"' in message["body"]: crash_ping = message break + assert crash_ping is not None, "Could not find crash ping with level DEBUG tag" - assert crash_ping is not None, "Could not find crash ping with 'is_crash_ping:true' tag" return crash_ping