diff --git a/.gitlab/generate-tracer.php b/.gitlab/generate-tracer.php index 5e7488158ec..dc581481f49 100644 --- a/.gitlab/generate-tracer.php +++ b/.gitlab/generate-tracer.php @@ -152,7 +152,7 @@ function windows_test_c_job($job_name, $thread_safety, $targets) { docker exec ${CONTAINER_NAME} powershell.exe "cd app; switch-php ; C:\php\SDK\phpize.bat; .\configure.bat --enable-debug-pack; nmake" # Set test environment variables - docker exec ${CONTAINER_NAME} powershell.exe "setx DD_AUTOLOAD_NO_COMPILE true; setx DATADOG_HAVE_DEV_ENV 1; setx DD_TRACE_GIT_METADATA_ENABLED 0" + docker exec ${CONTAINER_NAME} powershell.exe "setx DD_AUTOLOAD_NO_COMPILE true; setx DATADOG_HAVE_DEV_ENV 1; setx DD_TRACE_GIT_METADATA_ENABLED 0; setx DD_TRACE_IGNORE_AGENT_SAMPLING_RATES 1; setx DD_TRACE_RATE_LIMIT 1000000" # Exclude tests that deadlock the php-cgi SKIPIF skip-task on Windows. +"macos test_c": + stage: test + tags: ["macos:tart"] + image: "486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/ci-platform-machine-images/tart-vm:shared-sonoma-latest" + variables: + PHP_MACOS_VERSION: "8.5.9" + PHP_INSTALL_DIR: "/tmp/php-macos-${PHP_MACOS_VERSION}" + _DD_DEBUG_SIDECAR_LOG_LEVEL: trace + _DD_DEBUG_SIDECAR_LOG_METHOD: "file://${CI_PROJECT_DIR}/artifacts/sidecar.log" + # Enables tests gated by tests/ext/includes/skipif_no_dev_env.inc (see request-replayer + # setup below), matching the Linux/Windows jobs' dev-env-dependent test coverage. + DATADOG_HAVE_DEV_ENV: 1 + PHP_CLI_SERVER_WORKERS: "16" + DD_REQUEST_DUMPER_FILE: dump.json + before_script: + # Strip the noisy DD_* env vars from the locally installed agent + - unset DD_SERVICE DD_ENV DD_TAGS DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED DD_AGENT_HOST DD_TRACE_AGENT_PORT DD_DOGSTATSD_PORT + - brew install pkg-config openssl re2c bison libxml2 oniguruma libzip libsodium php + - mkdir -p /tmp/php-build "${CI_PROJECT_DIR}/artifacts/tests" + - curl -fL "https://github.com/php/php-src/archive/refs/tags/php-${PHP_MACOS_VERSION}.tar.gz" | tar xz -C /tmp/php-build + - cd "/tmp/php-build/php-src-php-${PHP_MACOS_VERSION}" + - ./buildconf --force + - | + export PATH="$(brew --prefix bison)/bin:$(brew --prefix libxml2)/bin:${PATH}" + export PKG_CONFIG_PATH="$(brew --prefix libxml2)/lib/pkgconfig:${PKG_CONFIG_PATH:-}" + export LDFLAGS="-L$(brew --prefix libxml2)/lib ${LDFLAGS:-}" + export CPPFLAGS="-I$(brew --prefix libxml2)/include ${CPPFLAGS:-}" + ./configure \ + --prefix="${PHP_INSTALL_DIR}" \ + --enable-debug \ + --enable-zts \ + --enable-pcntl \ + --without-iconv \ + --with-openssl="$(brew --prefix openssl)" \ + --with-libxml \ + --enable-mbstring \ + --with-sodium \ + --with-curl \ + --enable-sockets \ + --with-ffi + - make -j"$(sysctl -n hw.ncpu)" + - make install + - cd "${CI_PROJECT_DIR}" + - rustup update stable && rustup default stable + - | + # There's no Docker service network on the macOS Tart runner (unlike the Linux/Windows + # jobs' "request-replayer" service container), so run request-replayer as a native + # background process on loopback instead, and alias its hostname via /etc/hosts so + # tests that hardcode "request-replayer" (see tests/Common/TracerTestTrait.php et al.) + # resolve it the same way. Uses brew's php (bundles curl + gmp, both required -- see + # dockerfiles/services/request-replayer/linux.Dockerfile and index.php's + # UnpackOptions::BIGINT_AS_GMP) rather than our from-source test build, which has + # neither and is a separate, unrelated PHP install. + grep -q '[[:space:]]request-replayer$' /etc/hosts || sudo bash -c 'echo "127.0.0.1 request-replayer" >> /etc/hosts' + REQUEST_REPLAYER_PHP="$(brew --prefix php)/bin/php" + "${REQUEST_REPLAYER_PHP}" -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" + "${REQUEST_REPLAYER_PHP}" /tmp/composer-setup.php --install-dir=/tmp --filename=composer.phar + (cd dockerfiles/services/request-replayer/src && "${REQUEST_REPLAYER_PHP}" /tmp/composer.phar install --no-interaction) + # `sudo -b` (not `sudo ... &`): a non-interactive shell's `&` doesn't put the + # backgrounded job in its own process group, so it stays in sudo's -- and sudo, + # with pty allocation (common on macOS), waits for the whole process group to exit + # before returning. `-b` is sudo's own flag for backgrounding the command, so sudo + # itself returns immediately instead of waiting on this long-lived server. Even so, + # explicitly kill the server in after_script below (via its captured PID) rather than + # relying purely on detachment: the job still hung once even with -b, most likely + # some other inherited handle back to the runner's own output pipe, and killing it + # outright sidesteps whatever that is rather than chasing it further. + sudo -b bash -c "cd '${CI_PROJECT_DIR}/dockerfiles/services/request-replayer/src' && PHP_CLI_SERVER_WORKERS='${PHP_CLI_SERVER_WORKERS}' DD_REQUEST_DUMPER_FILE='${DD_REQUEST_DUMPER_FILE}' nohup '${REQUEST_REPLAYER_PHP}' -S 127.0.0.1:80 index.php < /dev/null > '${CI_PROJECT_DIR}/artifacts/request-replayer.log' 2>&1 & echo \$! > '${CI_PROJECT_DIR}/artifacts/request-replayer.pid'" + script: + - export PATH="${PHP_INSTALL_DIR}/bin:${PATH}" + - export TEST_PHP_JUNIT="${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml" + - php --version + - make -j"$(sysctl -n hw.ncpu)" + - timeout 20m make test_c + # GitLab's "step_script" (before_script + script) itself doesn't return while + # request-replayer is still alive -- confirmed by a run where the test suite finished + # cleanly (0 failures) but the job then sat idle until GitLab's own 1h job timeout + # killed it, with after_script never even starting. So kill it here, at the end of + # script itself, not only in after_script (kept below as a backstop for a failing + # script: that never reaches this line). + - test -f "${CI_PROJECT_DIR}/artifacts/request-replayer.pid" && sudo kill -9 "$(cat "${CI_PROJECT_DIR}/artifacts/request-replayer.pid")" || true + after_script: + - mkdir -p "${CI_PROJECT_DIR}/artifacts/diffs" + - find . -type f \( -name '*.diff' -o -name '*.mem' \) -not -path '*/vendor/*' -exec cp '{}' "${CI_PROJECT_DIR}/artifacts/diffs/" \; || true + - test -f "${CI_PROJECT_DIR}/artifacts/request-replayer.pid" && sudo kill -9 "$(cat "${CI_PROJECT_DIR}/artifacts/request-replayer.pid")" || true + artifacts: + when: always + reports: + junit: "artifacts/tests/php-tests.xml" + paths: + - "artifacts/" + "Prepare code": stage: compile diff --git a/.gitlab/macos.yml b/.gitlab/macos.yml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/Cargo.lock b/Cargo.lock index a2ec5c0abf2..89c8002e20a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -310,7 +310,7 @@ dependencies = [ "cfg-if", "libc 0.2.186", "miniz_oxide 0.8.9", - "object 0.36.7", + "object", "rustc-demangle", "windows-targets 0.52.6", ] @@ -1544,16 +1544,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" -[[package]] -name = "duplicate" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0a4be4cd710e92098de6ad258e6e7c24af11c29c5142f3c6f2a545652480ff8" -dependencies = [ - "heck 0.4.1", - "proc-macro-error", -] - [[package]] name = "duplicate" version = "2.0.1" @@ -1768,7 +1758,6 @@ checksum = "bc74ac4d8359ae70623506d512209619e5cf8f347124910440dbc221714b328e" dependencies = [ "borrow-or-share", "ref-cast", - "serde", ] [[package]] @@ -2825,7 +2814,7 @@ dependencies = [ "futures-channel", "futures-util", "http 1.4.2", - "thiserror 1.0.69", + "thiserror 2.0.18", ] [[package]] @@ -2881,7 +2870,7 @@ dependencies = [ "serde", "static_assertions", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.18", "tokio", "tokio-rustls", "tower-service", @@ -2938,7 +2927,7 @@ dependencies = [ "symbolic-common", "symbolic-demangle", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.18", "tokio", "uuid", "windows 0.59.0", @@ -2973,7 +2962,7 @@ dependencies = [ "bytes", "clap", "criterion", - "duplicate 2.0.1", + "duplicate", "either", "futures", "getrandom 0.2.15", @@ -3029,7 +3018,7 @@ dependencies = [ "libdd-trace-obfuscation", "libdd-trace-utils", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.18", "zstd", ] @@ -3252,7 +3241,7 @@ dependencies = [ "cxx", "cxx-build", "futures", - "hashbrown 0.16.1", + "hashbrown 0.17.1", "http 1.4.2", "http-body-util", "httparse", @@ -3323,7 +3312,7 @@ dependencies = [ "sha2", "strum", "strum_macros", - "thiserror 1.0.69", + "thiserror 2.0.18", "time", "tokio", "tokio-util", @@ -3357,7 +3346,7 @@ dependencies = [ "bytes", "futures", "getrandom 0.2.15", - "hashbrown 0.15.2", + "hashbrown 0.17.1", "http 1.4.2", "httpmock", "libc 0.2.186", @@ -3417,7 +3406,7 @@ dependencies = [ "anyhow", "arbitrary", "criterion", - "duplicate 0.4.1", + "duplicate", "libdd-trace-protobuf", "rand 0.8.8", ] @@ -3428,7 +3417,7 @@ version = "8.0.0" dependencies = [ "anyhow", "criterion", - "duplicate 0.4.1", + "duplicate", "fluent-uri", "libdd-common", "libdd-tinybytes", @@ -3463,7 +3452,7 @@ dependencies = [ "async-trait", "criterion", "futures", - "hashbrown 0.15.2", + "hashbrown 0.17.1", "http 1.4.2", "httpmock", "libdd-capabilities", @@ -3496,6 +3485,7 @@ dependencies = [ "cargo-platform", "cargo_metadata", "criterion", + "crossbeam-channel", "flate2", "futures", "getrandom 0.2.15", @@ -3525,6 +3515,7 @@ dependencies = [ "serde_json", "tempfile", "thin-vec", + "thread_local", "tokio", "tracing", "urlencoding", @@ -3903,15 +3894,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nu-ansi-term" -version = "0.50.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "num-conv" version = "0.1.0" @@ -4098,24 +4080,15 @@ dependencies = [ "objc2-foundation", ] -[[package]] -name = "object" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" -dependencies = [ - "flate2", - "memchr", - "ruzstd", -] - [[package]] name = "object" version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ + "flate2", "memchr", + "ruzstd", ] [[package]] @@ -4152,7 +4125,6 @@ dependencies = [ "objc2", "objc2-foundation", "objc2-ui-kit", - "serde", "windows-sys 0.61.2", ] @@ -5227,12 +5199,10 @@ dependencies = [ [[package]] name = "ruzstd" -version = "0.3.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a15e661f0f9dac21f3494fe5d23a6338c0ac116a2d22c2b63010acd89467ffe" +checksum = "fad02996bfc73da3e301efe90b1837be9ed8f4a462b6ed410aa35d00381de89f" dependencies = [ - "byteorder", - "thiserror 1.0.69", "twox-hash", ] @@ -5632,7 +5602,7 @@ checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" name = "sidecar_mockgen" version = "0.1.0" dependencies = [ - "object 0.31.1", + "object", ] [[package]] @@ -6435,7 +6405,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" dependencies = [ "matchers", - "nu-ansi-term", "once_cell", "regex-automata", "serde", @@ -6445,7 +6414,6 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log", "tracing-serde", ] diff --git a/Cargo.toml b/Cargo.toml index 535898d16f8..902e2827919 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,8 +51,8 @@ libdd-common = { path = "libdatadog/libdd-common", features = ["cgroup_testing"] libdd-common-ffi = { path = "libdatadog/libdd-common-ffi", default-features = false } libdd-telemetry = { path = "libdatadog/libdd-telemetry" } libdd-telemetry-ffi = { path = "libdatadog/libdd-telemetry-ffi", default-features = false } -datadog-live-debugger = { package = "libdd-live-debugger", path = "libdatadog/libdd-live-debugger" } -datadog-live-debugger-ffi = { package = "libdd-live-debugger-ffi", path = "libdatadog/libdd-live-debugger-ffi", default-features = false } +libdd-live-debugger = { path = "libdatadog/libdd-live-debugger" } +libdd-live-debugger-ffi = { path = "libdatadog/libdd-live-debugger-ffi", default-features = false } libdd-ipc = { path = "libdatadog/libdd-ipc" } datadog-ffe = { package = "libdd-ffe", path = "libdatadog/libdd-ffe" } libdd-remote-config = { path = "libdatadog/libdd-remote-config" } @@ -155,44 +155,161 @@ inherits = "release" [workspace.dependencies] allocator-api2 = { version = "0.2.21", default-features = false } anyhow = { version = "1.0", default-features = false } +arbitrary = { version = "1.3", default-features = false } arc-swap = { version = "1.7.1", default-features = false } +arrayref = { version = "0.3.7", default-features = false } +assert_no_alloc = { version = "1.1.2", default-features = false } +async-trait = { version = "0.1", default-features = false } base64 = { version = "0.22", default-features = false } +bincode = { version = "1.3.3", default-features = false } +bitmaps = { version = "3.2.0", default-features = false } +blazesym = { version = "=0.2.3", default-features = false } bolero = { version = "0.13.4", default-features = false } +byteorder = { version = "1.5", default-features = false } bytes = { version = "1.11", default-features = false } +cadence = { version = "1.3.0", default-features = false } +cargo-platform = { version = "=0.1.7", default-features = false } +cargo_metadata = { version = "0.18.1", default-features = false } +cc = { version = "1.1.31", default-features = false } chrono = { version = "0.4.38", default-features = false } clap = { version = "4.3.21", default-features = false } +console-subscriber = { version = "0.5", default-features = false } +const_format = { version = "0.2.34", default-features = false } +constcat = { version = "0.4.1", default-features = false } criterion = { version = "0.5.1", default-features = true } +crossbeam-channel = { version = "0.5.15", default-features = false } +crossbeam-queue = { version = "0.3.11", default-features = false } +crossbeam-utils = { version = "0.8.21", default-features = false } +cxx = { version = "1.0", default-features = false } cxx-build = { version = "1.0", default-features = false } +derive_more = { version = "2.0.0", default-features = false } +duplicate = { version = "2.0.1", default-features = false } +either = { version = "1.13.0", default-features = false } elf = { version = "0.7", default-features = false } +errno = { version = "0.3", default-features = false } fastrand = { version = "2", default-features = false } +faststr = { version = "0.2.23", default-features = false } flate2 = { version = "1.0", default-features = false, features = ["rust_backend"] } +fluent-uri = { version = "0.4.1", default-features = false } +function_name = { version = "0.3.0", default-features = false } futures = { version = "0.3", default-features = false } +futures-channel = { version = "0.3", default-features = false } +futures-core = { version = "0.3.0", default-features = false } +futures-util = { version = "0.3.0", default-features = false } +getrandom = { version = "0.2", default-features = false } +glibc_version = { version = "0.1.2", default-features = false } +goblin = { version = "0.9.3", default-features = false } +h2 = { version = "0.4", default-features = false } +hashbrown = { version = "0.17", default-features = false } +heck = { version = "0.5", default-features = false } +hex = { version = "0.4", default-features = false } http = { version = "1.1", default-features = false } +http-body = { version = "1", default-features = false } http-body-util = { version = "0.1", default-features = false } httpmock = { version = "0.8.0-alpha.1", default-features = false, features = ["cookies"] } httparse = { version = "1.9", default-features = false } hyper = { version = "1.6", default-features = false } +hyper-rustls = { version = "0.27.7", default-features = false } hyper-util = { version = "0.1.10", default-features = false } +indexmap = { version = "2.11", default-features = false } io-lifetimes = { version = "1.0", default-features = false } +itoa = { version = "1.0", default-features = false } libc = { version = "0.2", default-features = true } +libdd-libunwind-sys = { version = "1.0.3", default-features = false } +log = { version = "0.4.21", default-features = false } +lru = { version = "0.16.3", default-features = false } +manual_future = { version = "0.1.1", default-features = false } +maplit = { version = "1.0", default-features = false } +md5 = { version = "0.7.0", default-features = false } +memfd = { version = "0.6", default-features = false } +memory-stats = { version = "1.2.0", default-features = false } +microseh = { version = "0.1.1", default-features = false } mime = { version = "0.3.16", default-features = false } +multer = { version = "3.1", default-features = false } +nix = { version = "0.29", default-features = false } +num-derive = { version = "0.4.2", default-features = false } +num-traits = { version = "0.2.19", default-features = false } +object = { version = "0.36", default-features = false } once_cell = { version = "1.18", default-features = false } +os_info = { version = "3.14.0", default-features = false } +page_size = { version = "0.6.0", default-features = false } +parking_lot = { version = "0.12", default-features = false } +paste = { version = "1", default-features = false } percent-encoding = { version = "2.1", default-features = false } +pin-project = { version = "1", default-features = false } +portable-atomic = { version = "1.6.0", default-features = false } +prctl = { version = "1.0.0", default-features = false } +pretty_assertions = { version = "1.3", default-features = false } +priority-queue = { version = "2.1.1", default-features = false } +proc-macro2 = { version = "1", default-features = false } +proptest = { version = "1", default-features = false } +prost = { version = "0.14.1", default-features = false } prost-build = { version = "0.14.1", default-features = false } protoc-bin-vendored = { version = "3.0.0", default-features = false } +pyo3 = { version = "0.28", default-features = false } +quote = { version = "1", default-features = false } +rand = { version = "0.8", default-features = false } +rand_chacha = { version = "0.3.1", default-features = false } regex = { version = "1.5", default-features = false } +regex-lite = { version = "0.1", default-features = false } reqwest = { version = "0.13", default-features = false } +ring = { version = "0.17", default-features = false } +rlimit = { version = "0.9", default-features = false } +rmp = { version = "0.8.14", default-features = false } +rmp-serde = { version = "1.3.0", default-features = false } +rmpv = { version = "1.3.0", default-features = false } +rustc-hash = { version = "2.1.1", default-features = false } rustls = { version = "0.23", default-features = false } +rustls-native-certs = { version = ">=0.8.1, <0.8.3", default-features = false } rustls-platform-verifier = { version = "0.6", default-features = false } +rustls-webpki = { version = ">=0.103.13", default-features = false } +schemars = { version = "0.8.21", default-features = false } +semver = { version = "1.0", default-features = false } +sendfd = { version = "0.4", default-features = false } serde = { version = "1.0", default-features = false } +serde-bool = { version = "0.1.3", default-features = false } +serde-transcode = { version = "1.1", default-features = false } +serde_bytes = { version = "0.11.9", default-features = false } serde_json = { version = "1.0", default-features = false, features = ["alloc"] } +serde_with = { version = "3.11.0", default-features = false } +serde_yaml = { version = "0.9.34", default-features = false } +serial_test = { version = "3.2", default-features = false } sha2 = { version = "0.10", default-features = false } +simd-json = { version = "=0.14", default-features = false } +smallvec = { version = "1.13.2", default-features = false } +static_assertions = { version = "1.1.0", default-features = false } +strum = { version = "0.26.2", default-features = false } +strum_macros = { version = "0.26", default-features = false } +symbolic-common = { version = "12.8.0", default-features = false } +symbolic-demangle = { version = "12.8.0", default-features = false } syn = { version = "^2", default-features = false } +sys-info = { version = "0.9.0", default-features = false } +target-triple = { version = "0.1.4", default-features = false } tempfile = { version = "3.13", default-features = false, features = ["getrandom"] } +test-case = { version = "2.2", default-features = false } +thin-vec = { version = "0.2", default-features = false } +thiserror = { version = "2.0.3", default-features = false } +thread_local = { version = "1.1", default-features = false } +time = { version = "0.3", default-features = false } tokio = { version = "1.36", default-features = false } +tokio-rustls = { version = "0.26", default-features = false } +tokio-util = { version = "0.7.11", default-features = false } +tonic = { version = "0.14", default-features = false } +tower-service = { version = "0.3", default-features = false } tracing = { version = "0.1", default-features = false } +tracing-appender = { version = "0.2.3", default-features = false } +tracing-log = { version = "0.2.0", default-features = false } +tracing-subscriber = { version = "0.3.22", default-features = false } +tuf = { package = "libdd-tuf", version = "0.3.1", default-features = false } +url = { version = "2.5.0", default-features = false } +urlencoding = { version = "2.1.3", default-features = false } uuid = { version = "1.7.0", default-features = false } +wasm-bindgen-futures = { version = "0.4", default-features = false } +web-time = { version = "1", default-features = false } +winver = { version = "1.0.0", default-features = false } +zrip = { version = "=0.6.0", default-features = false } zstd = { version = "0.13", default-features = false } +zwohash = { version = "0.1.2", default-features = false } [workspace.lints] diff --git a/Makefile b/Makefile index ec877d56f95..f76fcd7e7f2 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,12 @@ RUST_DEBUG_BUILD ?= $(shell [ -n "${DD_TRACE_DOCKER_DEBUG}" ] && echo 1) EXTRA_CONFIGURE_OPTIONS ?= ASSUME_COMPILED := ${DD_TRACE_ASSUME_COMPILED} MAX_TEST_PARALLELISM ?= $(shell nproc) -ALL_TEST_ENV_OVERRIDE := $(shell [ -n "${DD_TRACE_DOCKER_DEBUG}" ] && echo DD_TRACE_IGNORE_AGENT_SAMPLING_RATES=1) DD_TRACE_GIT_METADATA_ENABLED=0 DD_CRASHTRACKER_RECEIVER_TIMEOUT_MS=15000 +# macOS CI runs on bare-metal runners that leak GitLab's infra-monitoring DD_* env vars into the +# job, letting the sidecar reach a real agent and breaking test determinism (varying sample rates, +# non-empty "env"). Linux CI runs in Docker with no such stray agent, and some tests (e.g. +# tests/ext/background-sender/agent_sampling_sidecar.phpt) specifically need agent sampling rates +# to NOT be ignored, so keep this macOS-only. +ALL_TEST_ENV_OVERRIDE := $(if $(filter Darwin,$(shell uname -s)),DD_TRACE_IGNORE_AGENT_SAMPLING_RATES=1 DD_TRACE_RATE_LIMIT=1000000,$(shell [ -n "${DD_TRACE_DOCKER_DEBUG}" ] && echo DD_TRACE_IGNORE_AGENT_SAMPLING_RATES=1)) DD_TRACE_GIT_METADATA_ENABLED=0 DD_CRASHTRACKER_RECEIVER_TIMEOUT_MS=15000 VERSION := $(shell cat VERSION) @@ -44,7 +49,12 @@ TRACER_SOURCES_INI := -d datadog.trace.sources_path=$(TRACER_SOURCE_DIR) RUN_TESTS_IS_PARALLEL ?= $(shell test $(PHP_MAJOR_MINOR) -ge 74 && echo 1) # shuffle parallel tests to evenly distribute test load, avoiding a batch of 32 tests being request-replayer tests -RUN_TESTS_CMD := DD_SERVICE= DD_ENV= REPORT_EXIT_STATUS=1 TEST_PHP_SRCDIR=$(PROJECT_ROOT) USE_TRACKED_ALLOC=1 php -n -d 'memory_limit=-1' $(BUILD_DIR)/run-tests.php $(if $(QUIET_TESTS),,-g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP) $(if $(ASAN), --asan) --show-diff -n -p $(shell which php) -q $(if $(RUN_TESTS_IS_PARALLEL), --shuffle -j$(MAX_TEST_PARALLELISM)) +# +# On macOS CI, force a local, unreachable agent host/port so tests can't accidentally reach the +# real agent that GitLab's bare-metal runner env leakage would otherwise point them at (see +# ALL_TEST_ENV_OVERRIDE above). Linux tests that need a mock agent set DD_AGENT_HOST/DD_TRACE_AGENT_PORT +# explicitly via --ENV--, which a global -d override here would clobber. +RUN_TESTS_CMD := DD_SERVICE= DD_ENV= REPORT_EXIT_STATUS=1 TEST_PHP_SRCDIR=$(PROJECT_ROOT) USE_TRACKED_ALLOC=1 php -n -d 'memory_limit=-1' $(BUILD_DIR)/run-tests.php $(if $(QUIET_TESTS),,-g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP) $(if $(ASAN), --asan) --show-diff -n -p $(shell which php) -q $(if $(RUN_TESTS_IS_PARALLEL), --shuffle -j$(MAX_TEST_PARALLELISM)) $(if $(filter Darwin,$(shell uname -s)), -d datadog.agent_host=127.0.0.1 -d datadog.trace.agent_port=1) C_FILES = $(shell find components components-rs ext src/dogstatsd tracer zend_abstract_interface -name '*.c' -o -name '*.h' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' ) TEST_FILES = $(shell find tests/ext -name '*.php*' -o -name '*.inc' -o -name '*.json' -o -name '*.yaml' -o -name 'CONFLICTS' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' ) @@ -137,6 +147,7 @@ $(BUILD_DIR)/Makefile: $(BUILD_DIR)/configure $(BUILD_DIR)/.rust_files_list $(SO_FILE): $(if $(ASSUME_COMPILED),, $(ALL_OBJECT_FILES) $(BUILD_DIR)/compile_rust.sh) $(if $(ASSUME_COMPILED),,$(Q) $(MAKE) -C $(BUILD_DIR) -j) + $(if $(filter Darwin,$(shell uname -s)),$(Q) codesign --force --sign - $@,) $(AR_FILE): $(ALL_OBJECT_FILES) $(Q) $(MAKE) -C $(BUILD_DIR) -j ./modules/ddtrace.a all diff --git a/cbindgen.toml b/cbindgen.toml index 50508ed52bd..dd4223ffb7e 100644 --- a/cbindgen.toml +++ b/cbindgen.toml @@ -46,8 +46,8 @@ include = [ "datadog-crashtracker-ffi", "datadog-sidecar", "libdd-ipc", - "datadog-live-debugger", - "datadog-live-debugger-ffi", + "libdd-live-debugger", + "libdd-live-debugger-ffi", "libdd-remote-config", "uuid" ] diff --git a/components-rs/remote_config.rs b/components-rs/remote_config.rs index 2bed8f0d67a..eadb02b0173 100644 --- a/components-rs/remote_config.rs +++ b/components-rs/remote_config.rs @@ -1,11 +1,11 @@ use crate::bytes::{dangling_zend_string, OwnedZendString, ZendString}; use crate::sidecar::MaybeShmLimiter; use datadog_ffe::rules_based::{Configuration, UniversalFlagConfig}; -use datadog_live_debugger::debugger_defs::{DebuggerData, DebuggerPayload}; -use datadog_live_debugger::{FilterList, LiveDebuggingData, ServiceConfiguration}; -use datadog_live_debugger_ffi::data::Probe; -use datadog_live_debugger_ffi::evaluator::{ddog_register_expr_evaluator, Evaluator}; -use datadog_live_debugger_ffi::send_data::{ +use libdd_live_debugger::debugger_defs::{DebuggerData, DebuggerPayload}; +use libdd_live_debugger::{FilterList, LiveDebuggingData, ServiceConfiguration}; +use libdd_live_debugger_ffi::data::Probe; +use libdd_live_debugger_ffi::evaluator::{ddog_register_expr_evaluator, Evaluator}; +use libdd_live_debugger_ffi::send_data::{ ddog_debugger_diagnostics_create_unboxed, ddog_snapshot_redacted_type, }; use datadog_sidecar::service::blocking::SidecarTransport; diff --git a/ext/signals.c b/ext/signals.c index f883727dadc..da323eca14c 100644 --- a/ext/signals.c +++ b/ext/signals.c @@ -150,8 +150,8 @@ static zend_always_inline zend_string *dd_crasht_find_ini_by_tag(ddog_CharSlice // On PHP 8.0+ these INI should all exist, but guard against the NULL case // in case something goes wrong, or this changes in a future version. if (UNEXPECTED(!value)) { - LOG(WARN, - "crashtracker setup failed to find INI \"%.*s\"--is it removed in a newer version?", + LOG(TRACE, + "crashtracker setup: INI \"%.*s\" not found (maybe compiled out in this PHP build)", (int) ini.len, ini.ptr); } return value; diff --git a/libdatadog b/libdatadog index b3813948bfe..9d158d1d8a9 160000 --- a/libdatadog +++ b/libdatadog @@ -1 +1 @@ -Subproject commit b3813948bfe1c12223a5dbcafe10cff83857780e +Subproject commit 9d158d1d8a91c73f7e92779772cf32ac5fe5b10c diff --git a/tests/ext/background-sender/background_sender_ipv6_support.phpt b/tests/ext/background-sender/background_sender_ipv6_support.phpt index df66ad29d2f..497cae1f428 100644 --- a/tests/ext/background-sender/background_sender_ipv6_support.phpt +++ b/tests/ext/background-sender/background_sender_ipv6_support.phpt @@ -8,6 +8,7 @@ include_once __DIR__ . '/../startup_logging.inc'; $logs = dd_get_startup_logs([], [ 'DD_AGENT_HOST' => '::1', + 'DD_TRACE_AGENT_PORT' => '8126', 'DD_TRACE_DEBUG' => 1, 'DD_TRACE_AGENT_TIMEOUT' => 200, 'DD_TRACE_RETRY_INTERVAL' => 1, diff --git a/tests/ext/crashtracker_collect_all_threads.phpt b/tests/ext/crashtracker_collect_all_threads.phpt index 5fa111c08ee..f4c6502914d 100644 --- a/tests/ext/crashtracker_collect_all_threads.phpt +++ b/tests/ext/crashtracker_collect_all_threads.phpt @@ -10,6 +10,9 @@ if (PHP_VERSION_ID < 70200) die("skip: TEST_PHP_EXTRA_ARGS is only available on if (!extension_loaded('ffi')) die('skip: ffi extension required'); if (!trim(shell_exec('which cc 2>/dev/null') ?: shell_exec('which gcc 2>/dev/null') ?: '')) die('skip: C compiler not available'); include __DIR__ . '/includes/skipif_no_dev_env.inc'; +// Crashtracking isn't supported on macOS: the crash report never reaches the agent/ +// request-replayer the way it does on Linux (see also crashtracker_segfault.phpt's Darwin skip). +if (PHP_OS === "Darwin") die("skip: crashtracker is not supported on macOS"); ?> --ENV-- DD_TRACE_LOG_LEVEL=0 diff --git a/tests/ext/crashtracker_segfault.phpt b/tests/ext/crashtracker_segfault.phpt index 0171930d6eb..d57cf99dd62 100644 --- a/tests/ext/crashtracker_segfault.phpt +++ b/tests/ext/crashtracker_segfault.phpt @@ -8,6 +8,10 @@ if (getenv('PHP_PEAR_RUNTESTS') === '1') die("skip: pecl run-tests does not supp if (getenv('DD_TRACE_CLI_ENABLED') === '0') die("skip: tracer is disabled"); if (PHP_VERSION_ID < 70200) die("skip: TEST_PHP_EXTRA_ARGS is only available on PHP 7.2+"); include __DIR__ . '/includes/skipif_no_dev_env.inc'; +// Crashtracking isn't supported on macOS: the crash report never reaches the agent/ +// request-replayer the way it does on Linux (see also segfault_backtrace_disabled.phpt's +// Darwin skip, which covers the related run-tests.php-visible-signal side of the same gap). +if (PHP_OS === "Darwin") die("skip: crashtracker is not supported on macOS"); ?> --ENV-- DD_TRACE_LOG_LEVEL=0 diff --git a/tests/ext/crashtracker_segfault_disabled.phpt b/tests/ext/crashtracker_segfault_disabled.phpt index 79e754a9182..5d63c167deb 100644 --- a/tests/ext/crashtracker_segfault_disabled.phpt +++ b/tests/ext/crashtracker_segfault_disabled.phpt @@ -8,6 +8,11 @@ if (getenv('PHP_PEAR_RUNTESTS') === '1') die("skip: pecl run-tests does not supp if (getenv('DD_TRACE_CLI_ENABLED') === '0') die("skip: tracer is disabled"); if (PHP_VERSION_ID < 70200) die("skip: TEST_PHP_EXTRA_ARGS is only available on PHP 7.2+"); include __DIR__ . '/includes/skipif_no_dev_env.inc'; +// Crashtracking isn't supported on macOS. Separately, this test's own diff also picks up +// macOS /bin/sh's own "Segmentation fault: 11" job-control notice on stderr (not suppressed +// by the test's own "2>/dev/null", which only covers the child's stderr) -- either issue +// alone would fail this test there. +if (PHP_OS === "Darwin") die("skip: crashtracker is not supported on macOS"); ?> --ENV-- DD_TRACE_LOG_LEVEL=0 diff --git a/tests/ext/extract_server_values.phpt b/tests/ext/extract_server_values.phpt index 102f24d2d89..05f51ae9a07 100644 --- a/tests/ext/extract_server_values.phpt +++ b/tests/ext/extract_server_values.phpt @@ -1,7 +1,14 @@ --TEST-- Test invalid $_SERVER values are properly ignored --SKIPIF-- - +/cmdline exposes precisely and portably; macOS has no equivalent short of +// ext-ffi + sysctl(KERN_PROCARGS2). +if (PHP_OS === "Darwin") die('skip: re-exec via /proc//cmdline is Linux-only'); +?> --ENV-- DD_TRACE_AUTO_FLUSH_ENABLED=0 DD_TRACE_GENERATE_ROOT_SPAN=0 diff --git a/tests/ext/force_flush_traces.phpt b/tests/ext/force_flush_traces.phpt index a5cb2dd776b..252758568b3 100644 --- a/tests/ext/force_flush_traces.phpt +++ b/tests/ext/force_flush_traces.phpt @@ -3,6 +3,7 @@ Force flush the traces mid-way through a trace --SKIPIF-- + --ENV-- DD_TRACE_SIDECAR_CONNECTION_MODE=thread DD_TRACE_GENERATE_ROOT_SPAN=0 diff --git a/tests/ext/read_c_configuration.phpt b/tests/ext/read_c_configuration.phpt index 575a961b30e..01c77b3e191 100644 --- a/tests/ext/read_c_configuration.phpt +++ b/tests/ext/read_c_configuration.phpt @@ -7,8 +7,6 @@ DD_TRACE_MEMORY_LIMIT=9999 --EXPECT-- some_known_host -8126 FALSE FALSE 9999 diff --git a/tests/ext/remote_config/rc_trace_enabled_rinit.phpt b/tests/ext/remote_config/rc_trace_enabled_rinit.phpt index 4e7fc7e0cf2..a8cf3816b38 100644 --- a/tests/ext/remote_config/rc_trace_enabled_rinit.phpt +++ b/tests/ext/remote_config/rc_trace_enabled_rinit.phpt @@ -4,6 +4,10 @@ RC tracing_enabled=true during RINIT does not double-init request globals /cmdline exposes precisely and +// portably; macOS has no equivalent short of ext-ffi + sysctl(KERN_PROCARGS2). +if (PHP_OS === "Darwin") die('skip: re-exec via /proc//cmdline is Linux-only'); ?> --ENV-- DD_AGENT_HOST=request-replayer diff --git a/tests/ext/segfault_backtrace_disabled.phpt b/tests/ext/segfault_backtrace_disabled.phpt index 86430817ea7..7fcfc6cc077 100644 --- a/tests/ext/segfault_backtrace_disabled.phpt +++ b/tests/ext/segfault_backtrace_disabled.phpt @@ -5,6 +5,13 @@ Don't dump backtrace when segmentation fault signal is raised and config is defa if (!extension_loaded('posix')) die('skip: posix extension required'); if (getenv('SKIP_ASAN') || getenv('USE_ZEND_ALLOC') === '0') die("skip: intentionally causes segfaults"); if (file_exists("/etc/os-release") && preg_match("/alpine/i", file_get_contents("/etc/os-release"))) die("skip Unsupported LIBC"); +// With the default config (crashtracking enabled), SIGSEGV handling is delegated entirely to +// libdatadog's crashtracker (ext/signals.c's own handler only installs when crashtracking is +// disabled, see the mutual-exclusion check in ddtrace_signals_minit). On macOS the crashtracker's +// fork+receiver-process handling doesn't leave the process to die by/report the raw signal the +// way run-tests.php expects (neither "Segmentation fault" text nor a Termsig=11/exit-code-139 +// process result appears), unlike on Linux. +if (PHP_OS === "Darwin") die("skip: macOS crashtracker signal handling doesn't surface as Termsig=11/Segmentation fault the way run-tests.php expects"); ?> --ENV-- DD_LOG_BACKTRACE=0 diff --git a/tests/ext/startup_logging_diagnostics.phpt b/tests/ext/startup_logging_diagnostics.phpt index d278990e7c9..865e712df7d 100644 --- a/tests/ext/startup_logging_diagnostics.phpt +++ b/tests/ext/startup_logging_diagnostics.phpt @@ -14,6 +14,7 @@ $env = [ 'DD_TRACE_AGENT_TIMEOUT' => 200, 'DD_TRACE_RETRY_INTERVAL' => 1, 'DD_AGENT_HOST' => 'invalid_host', + 'DD_TRACE_AGENT_PORT' => '2', 'DD_SERVICE' => 'foo_service', 'DD_TAGS' => 'foo:tag', ]; @@ -33,7 +34,7 @@ var_dump(strncasecmp(PHP_OS, "WIN", 3) == 0 || isset($logs["agent_error"])); --EXPECTF-- open_basedir_sources_allowed: false service: "foo_service" -agent_url: "http://invalid_host:8126" +agent_url: "http://invalid_host:2" tags: {"foo":"tag"} d%s.sources_path: "%s/includes/" open_basedir_configured: true diff --git a/tests/ext/telemetry/composer.phpt b/tests/ext/telemetry/composer.phpt index 15b27be5b12..75e58b670ce 100644 --- a/tests/ext/telemetry/composer.phpt +++ b/tests/ext/telemetry/composer.phpt @@ -24,6 +24,7 @@ include __DIR__ . '/vendor/autoload.php'; DDTrace\close_span(); dd_trace_internal_fn("finalize_telemetry"); +$initial_deps = []; for ($i = 0; $i < 300; ++$i) { ("us" . "leep")(100000); @@ -33,8 +34,11 @@ for ($i = 0; $i < 300; ++$i) { $json = json_decode($l, true); $batch = $json["request_type"] == "message-batch" ? $json["payload"] : [$json]; foreach ($batch as $json) { + if ($json["request_type"] == "app-started") { + $initial_deps = $json["payload"]["dependencies"] ?? []; + } if ($json["request_type"] == "app-dependencies-loaded") { - print_r($json["payload"]); + print_r(array_merge($initial_deps, $json["payload"]["dependencies"])); break 3; } } @@ -51,26 +55,22 @@ if ($i == 300) { Included Array ( - [dependencies] => Array + [0] => Array ( - [0] => Array - ( - [name] => datadog/dd-trace - [version] => dev-master - [hash] => - [metadata] => - ) - - [1] => Array - ( - [name] => ext-Core - [version] => %s - [hash] => - [metadata] => - ) -%a + [name] => datadog/dd-trace + [version] => dev-master + [hash] => + [metadata] => ) + [1] => Array + ( + [name] => ext-Core + [version] => %s + [hash] => + [metadata] => + ) +%a ) --CLEAN-- Array + ( + [name] => DD_AGENT_HOST + [value] => 127.0.0.2 + [origin] => env_var + [config_id] => + [seq_id] => + ) + + [2] => Array + ( + [name] => DD_TRACE_AGENT_PORT + [value] => 3 + [origin] => env_var + [config_id] => + [seq_id] => + ) + + [3] => Array ( [name] => DD_INSTRUMENTATION_TELEMETRY_ENABLED [value] => 1 @@ -92,7 +112,7 @@ Array [seq_id] => ) - [2] => Array + [4] => Array ( [name] => DD_TRACE_GIT_METADATA_ENABLED [value] => 0 @@ -101,7 +121,7 @@ Array [seq_id] => ) - [3] => Array + [5] => Array ( [name] => DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED [value] => 0 @@ -110,7 +130,16 @@ Array [seq_id] => ) - [4] => Array + [6] => Array + ( + [name] => DD_TRACE_RATE_LIMIT + [value] => 1000000 + [origin] => env_var + [config_id] => + [seq_id] => + ) + + [7] => Array ( [name] => DD_TRACE_IGNORE_AGENT_SAMPLING_RATES [value] => 1 @@ -119,7 +148,7 @@ Array [seq_id] => ) - [5] => Array + [8] => Array ( [name] => DD_TRACE_GENERATE_ROOT_SPAN [value] => 0 @@ -128,7 +157,7 @@ Array [seq_id] => ) - [6] => Array + [9] => Array ( [name] => ssi_forced_injection_enabled [value] => False