Skip to content

Commit 6b7e259

Browse files
authored
Merge branch 'master' into MilanGarnier/propagation-behavior-extract
2 parents a156a10 + 36d5401 commit 6b7e259

139 files changed

Lines changed: 1192 additions & 551 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/prof_asan.yml

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Profiling ASAN Tests
1+
name: Profiling ASAN/UBSAN Tests
22

33
on:
44
pull_request:
@@ -55,11 +55,11 @@ jobs:
5555
switch-php ${{ matrix.php-build }}
5656
cd profiling
5757
export CC=clang-20
58-
export CFLAGS='-fsanitize=address -fno-omit-frame-pointer'
58+
export CFLAGS='-fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer'
5959
export LDFLAGS='-fsanitize=address -shared-libasan'
6060
export RUSTC_LINKER=lld-20
6161
triplet=$(uname -m)-unknown-linux-gnu
62-
RUSTFLAGS='-Zsanitizer=address' cargo +${RUST_TOOLCHAIN} build -Zbuild-std=std,panic_abort --target $triplet --profile profiler-release
62+
RUSTFLAGS='-Zsanitizer=address -C force-frame-pointers=yes' cargo +${RUST_TOOLCHAIN} build -Zbuild-std=std,panic_abort --target $triplet --profile profiler-release
6363
cp -v "$CARGO_TARGET_DIR/$triplet/profiler-release/libdatadog_php_profiling.so" "$(php-config --extension-dir)/datadog-profiling.so"
6464
6565
- name: Run phpt tests
@@ -69,4 +69,71 @@ jobs:
6969
cd profiling/tests
7070
cp -v $(php-config --prefix)/lib/php/build/run-tests.php .
7171
export DD_PROFILING_OUTPUT_PPROF=/tmp/pprof
72+
export ASAN_OPTIONS="${ASAN_OPTIONS:+$ASAN_OPTIONS:}abort_on_error=1:halt_on_error=1:detect_leaks=1:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:detect_container_overflow=1:detect_odr_violation=2:symbolize=1:disable_coredump=0:unmap_shadow_on_exit=1"
73+
export LSAN_OPTIONS="${LSAN_OPTIONS:+$LSAN_OPTIONS:}exitcode=23:print_suppressions=0:report_objects=1"
7274
php run-tests.php -j$(nproc) --show-diff --asan -d extension=datadog-profiling.so phpt
75+
76+
prof-ubsan:
77+
name: PHP 8.5 ${{ matrix.php-build }} UBSAN (${{ matrix.runner }})
78+
runs-on: ${{ matrix.runner }}
79+
strategy:
80+
matrix:
81+
php-build: [nts, zts]
82+
runner: [arm-8core-linux, ubuntu-8-core-latest]
83+
env:
84+
CARGO_HOME: /rust/cargo
85+
RUSTUP_HOME: /rust/rustup
86+
CARGO_TARGET_DIR: /tmp/build-cargo
87+
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
88+
container:
89+
image: datadog/dd-trace-ci:php-8.5_bookworm-8
90+
options: --user root
91+
92+
steps:
93+
- name: Checkout
94+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
95+
with:
96+
fetch-depth: 1
97+
submodules: true
98+
99+
- name: Cache Cargo dependencies
100+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
101+
with:
102+
path: |
103+
/rust/cargo/registry/index/
104+
/rust/cargo/registry/cache/
105+
/rust/cargo/registry/src/
106+
/rust/cargo/git/db/
107+
/rust/cargo/git/checkouts/
108+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-deps-c-ubsan-${{ hashFiles('**/Cargo.lock') }}
109+
110+
- name: Cache Cargo target
111+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
112+
with:
113+
path: /tmp/build-cargo/
114+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-target-c-ubsan-8.5-${{ matrix.php-build }}-${{ github.sha }}-${{ hashFiles('.github/workflows/prof_asan.yml') }}
115+
116+
- name: Build and install profiler
117+
run: |
118+
set -eux
119+
switch-php ${{ matrix.php-build }}
120+
cd profiling
121+
export CC=clang-20
122+
export CXX=clang++-20
123+
export CFLAGS='-fsanitize=undefined,local-bounds -fno-sanitize-recover=all -fno-omit-frame-pointer'
124+
export LDFLAGS='-fsanitize=undefined,local-bounds -fno-sanitize-recover=all'
125+
export RUSTC_LINKER=clang-20
126+
export RUSTFLAGS='-C link-arg=-fsanitize=undefined,local-bounds -C link-arg=-fno-sanitize-recover=all'
127+
cargo build --profile profiler-release
128+
cp -v "$CARGO_TARGET_DIR/profiler-release/libdatadog_php_profiling.so" "$(php-config --extension-dir)/datadog-profiling.so"
129+
130+
- name: Run phpt tests
131+
run: |
132+
set -eux
133+
switch-php ${{ matrix.php-build }}
134+
cd profiling/tests
135+
cp -v $(php-config --prefix)/lib/php/build/run-tests.php .
136+
export DD_PROFILING_OUTPUT_PPROF=/tmp/pprof
137+
ubsan_runtime=$(clang-20 -print-file-name=libclang_rt.ubsan_standalone-$(uname -m).so)
138+
export LD_PRELOAD="$ubsan_runtime${LD_PRELOAD:+:$LD_PRELOAD}"
139+
php run-tests.php -j$(nproc) --show-diff -d extension=datadog-profiling.so phpt

.github/workflows/prof_correctness.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ jobs:
103103
mkdir -p profiling/tests/correctness/"$test_case"/
104104
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof
105105
php -d extension="${PWD}/target/profiler-release/libdatadog_php_profiling.so" "profiling/tests/correctness/${test_case}.php"
106-
if [ -f "$DD_PROFILING_OUTPUT_PPROF".1.lz4 ]; then
107-
echo "File $DD_PROFILING_OUTPUT_PPROF.1.lz4 should not exist!"
106+
if compgen -G "$DD_PROFILING_OUTPUT_PPROF.*" > /dev/null; then
107+
echo "Profile output should not exist:"
108+
ls -l "$DD_PROFILING_OUTPUT_PPROF".*
108109
exit 1;
109110
fi
110111
done

Cargo.lock

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

components-rs/agent_info.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ use std::ffi::CString;
1818
fn info_to_concentrator_config(info: &AgentInfoStruct) {
1919
apply_concentrator_config(
2020
info.peer_tags.as_deref().unwrap_or(&[]).to_owned(),
21-
info.span_kinds_stats_computed.as_deref().unwrap_or(&[]).to_owned(),
22-
info.filter_tags.as_ref().and_then(|f| f.require.as_deref()).unwrap_or(&[]).to_owned(),
23-
info.filter_tags.as_ref().and_then(|f| f.reject.as_deref()).unwrap_or(&[]).to_owned(),
24-
info.filter_tags_regex.as_ref().and_then(|f| f.require.as_deref()).unwrap_or(&[]).to_owned(),
25-
info.filter_tags_regex.as_ref().and_then(|f| f.reject.as_deref()).unwrap_or(&[]).to_owned(),
26-
info.ignore_resources.as_deref().unwrap_or(&[]).to_owned(),
21+
info.span_kinds_stats_computed
22+
.as_deref()
23+
.unwrap_or(&[])
24+
.to_owned(),
25+
info.filter_tags.require.to_owned(),
26+
info.filter_tags.reject.to_owned(),
27+
info.filter_tags_regex.require.to_owned(),
28+
info.filter_tags_regex.reject.to_owned(),
29+
info.ignore_resources.to_owned(),
2730
info.client_drop_p0s.unwrap_or(false),
2831
info.version.as_deref(),
2932
);

components-rs/common.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -785,21 +785,6 @@ typedef const char *(*ddog_RootTagLookupFn)(const void *ctx,
785785
uintptr_t key_len,
786786
uintptr_t *out_len);
787787

788-
/**
789-
* Per-entry callback passed to `RootMetaIterFn`. Return `false` to stop iteration early.
790-
*/
791-
typedef bool (*ddog_MetaEntryCb)(void *iter_ctx,
792-
const char *key,
793-
uintptr_t key_len,
794-
const char *val,
795-
uintptr_t val_len);
796-
797-
/**
798-
* Slow-path meta iterator. `NULL` when no regex-key filter entries are present.
799-
* Iterates all string meta entries, calling `cb` for each; stops when `cb` returns `false`.
800-
*/
801-
typedef void (*ddog_RootMetaIterFn)(const void *ctx, void *iter_ctx, ddog_MetaEntryCb cb);
802-
803788
/**
804789
* A 128-bit (16 byte) buffer containing the UUID.
805790
*

components-rs/datadog.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,13 @@ bool ddog_sidecar_telemetry_are_endpoints_collected(ddog_ShmCacheMap *cache,
407407
* no stats). Filters are evaluated against the root span — the decision applies uniformly
408408
* to all spans of the trace.
409409
*
410-
* * **Common case**: `filter_tags` and literal-key `filter_tags_regex` entries — one O(1)
410+
* * **When configured**: `filter_tags` and `filter_tags_regex` entries — one
411411
* `lookup_fn` call per filter entry.
412-
* * **Rare case**: `filter_tags_regex` entries with regex key patterns — `iter_fn` is invoked
413-
* to scan all meta entries for those filters. Pass `NULL` when not needed.
414412
* * **Fast path**: returns `true` immediately when no filters are configured.
415413
*/
416414
bool ddog_check_stats_trace_filter(ddog_CharSlice resource,
417415
const void *root_span,
418-
ddog_RootTagLookupFn lookup_fn,
419-
ddog_RootMetaIterFn iter_fn);
416+
ddog_RootTagLookupFn lookup_fn);
420417

421418
void ddog_init_span_func(void (*free_func)(ddog_OwnedZendString),
422419
void (*addref_func)(struct _zend_string*),

0 commit comments

Comments
 (0)