Skip to content

Use native rust spans instead of manually serializing to msgpack #3194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jul 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6654d7e
feat(component-rs): add data-pipeline header
Leiyks Apr 8, 2025
880609e
Fix missing use
bwoebi Apr 9, 2025
dee721b
Update libdatadog
bwoebi Apr 9, 2025
e4f7c7c
feat(tracer): use rust span API
Leiyks Apr 9, 2025
fdb6bfa
chore: bump libdatadog
Leiyks Apr 16, 2025
27fcf1a
feat(tracer: serializer): complete replacement of rust span API in se…
Leiyks Apr 16, 2025
a44638f
feat(ext: tracer): add local API to use zendString instead of CharSlice
Leiyks Apr 18, 2025
7c708e4
feat(ext: tracer): apply PR feedbacks
Leiyks Apr 22, 2025
d5a86a9
feat(tracer): modify communication code between the tracer and sidecar
Leiyks Apr 28, 2025
bfce230
feat(tracer): add function to convert a rust span to a zval
Leiyks Apr 30, 2025
3f1bc8c
chore: fix tests
Leiyks Apr 30, 2025
a2f3cc9
chore: fix tests
Leiyks May 13, 2025
ec55185
Switch to new way to pass zend_strings
bwoebi May 15, 2025
42ba140
chore: fix tests
Leiyks Apr 30, 2025
a8ef660
chore: remove useless free statements
Leiyks May 20, 2025
38a5039
chore: fix remaining failing tests
Leiyks May 20, 2025
59fb6e1
test: fix windows compiling tests
Leiyks May 21, 2025
5b13f7e
feat: move rust span code to sidecar-ffi
Leiyks May 21, 2025
d4b2e7a
feat: improve serializer performance by using literal instead of Char…
Leiyks May 22, 2025
2b76f8f
chore: rebase with master
Leiyks Jun 18, 2025
beceee6
Merge master
bwoebi Jul 24, 2025
c3c9b98
Merge branch 'master' of github.com:DataDog/dd-trace-php into leiyks-…
bwoebi Jul 25, 2025
52b50d3
Merge branch 'master' of github.com:DataDog/dd-trace-php into leiyks-…
bwoebi Jul 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ generate_cbindgen: cbindgen_binary # Regenerate components-rs/ddtrace.h componen
mkdir -pv "$(BUILD_DIR)"; \
export CARGO_TARGET_DIR="$(BUILD_DIR)/target"; \
fi; \
cargo run -p tools -- $(PROJECT_ROOT)/components-rs/common.h $(PROJECT_ROOT)/components-rs/ddtrace.h $(PROJECT_ROOT)/components-rs/live-debugger.h $(PROJECT_ROOT)/components-rs/telemetry.h $(PROJECT_ROOT)/components-rs/sidecar.h $(PROJECT_ROOT)/components-rs/crashtracker.h $(PROJECT_ROOT)/components-rs/library-config.h \
cargo run -p tools -- $(PROJECT_ROOT)/components-rs/common.h $(PROJECT_ROOT)/components-rs/ddtrace.h $(PROJECT_ROOT)/components-rs/live-debugger.h $(PROJECT_ROOT)/components-rs/telemetry.h $(PROJECT_ROOT)/components-rs/sidecar.h $(PROJECT_ROOT)/components-rs/crashtracker.h $(PROJECT_ROOT)/components-rs/library-config.h \
)

cbindgen_binary:
Expand Down
9 changes: 5 additions & 4 deletions appsec/tests/extension/client_init_record_span_tags.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ echo "tags:\n";
ksort($tags);
print_r($tags);
echo "metrics:\n";
ksort($metrics);
print_r($metrics);

$helper->finished_with_commands();
Expand Down Expand Up @@ -104,12 +105,12 @@ metrics:
Array
(
[%s] => %d
[metric_1] => 2
[metric_2] => 10
[_dd.appsec.enabled] => 1
[_dd.agent_psr] => 1
[_sampling_priority_v1] => 1
[metric_1] => 2
[metric_2] => 10
[php.compilation.total_time_ms] => %f
[php.memory.peak_usage_bytes] => %f
[php.memory.peak_real_usage_bytes] => %f
[php.memory.peak_usage_bytes] => %f
[process_id] => %d
)
7 changes: 4 additions & 3 deletions appsec/tests/extension/ddtrace_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ echo 'sent trace id is the same as \DDTrace\trace_id(): ',
$trace_id == $sent_trace_id ? 'yes' : 'no', "\n";

echo "tags:\n";
ksort($tags);
print_r($tags);

mlog(DEBUG, "Call finished_with_commands");
Expand Down Expand Up @@ -101,8 +102,8 @@ sent trace id is the same as \DDTrace\trace_id(): yes
tags:
Array
(
[runtime-id] => %s
[ddappsec] => true
[_dd.p.dm] => -0
[_dd.p.tid] => %s
)
[ddappsec] => true
[runtime-id] => %s
)
9 changes: 5 additions & 4 deletions appsec/tests/extension/rinit_record_span_tags.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ echo "tags:\n";
ksort($tags);
print_r($tags);
echo "metrics:\n";
ksort($metrics);
print_r($metrics);

$helper->finished_with_commands();
Expand Down Expand Up @@ -98,11 +99,11 @@ metrics:
Array
(
[%s] => %d
[rshutdown_metric] => 2.1
[_dd.appsec.enabled] => 1
[_dd.agent_psr] => 1
[_sampling_priority_v1] => 1
[php.compilation.total_time_ms] => %f
[php.memory.peak_usage_bytes] => %f
[php.memory.peak_real_usage_bytes] => %f
)
[php.memory.peak_usage_bytes] => %f
[process_id] => %d
[rshutdown_metric] => 2.1
)
5 changes: 3 additions & 2 deletions appsec/tests/extension/rinit_record_span_tags_fail.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ $commands = $helper->get_commands();
$tags = $commands[0]['payload'][0][0]['meta'];

echo "tags:\n";
ksort($tags);
print_r($tags);

$helper->finished_with_commands();
Expand All @@ -52,7 +53,7 @@ bool(true)
tags:
Array
(
[runtime-id] => %s
[_dd.p.dm] => -0
[_dd.p.tid] => %s
)
[runtime-id] => %s
)
14 changes: 7 additions & 7 deletions appsec/tests/extension/root_span_add_tag.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,28 @@ array(1) {
string(3) "cli"
["meta"]=>
array(4) {
["runtime-id"]=>
string(%d) %s
["after"]=>
string(9) "root_span"
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["after"]=>
string(9) "root_span"
["runtime-id"]=>
string(%d) %s
}
["metrics"]=>
array(6) {
[%s"]=>
float(%d)
["_dd.agent_psr"]=>
float(1)
["_sampling_priority_v1"]=>
float(1)
["php.compilation.total_time_ms"]=>
float(%s)
["php.memory.peak_real_usage_bytes"]=>
float(%f)
["php.memory.peak_usage_bytes"]=>
float(%f)
["php.memory.peak_real_usage_bytes"]=>
["process_id"]=>
float(%f)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ echo "tags:\n";
ksort($tags);
print_r($tags);
echo "metrics:\n";
ksort($metrics);
print_r($metrics);

$helper->finished_with_commands();
Expand Down Expand Up @@ -77,11 +78,11 @@ Array
metrics:
Array
(
[process_id] => %d
[_dd.appsec.enabled] => 1
[_dd.agent_psr] => 1
[_dd.appsec.enabled] => 1
[_sampling_priority_v1] => 1
[php.compilation.total_time_ms] => %s
[php.memory.peak_usage_bytes] => %f
[php.memory.peak_real_usage_bytes] => %f
[php.memory.peak_usage_bytes] => %f
[process_id] => %d
)
4 changes: 4 additions & 0 deletions cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ language = "C"
tab_width = 2
include_guard = "DDTRACE_PHP_H"
style = "both"
header = """
struct _zend_string;
"""

no_includes = true
sys_includes = ["stdbool.h", "stddef.h", "stdint.h"]
Expand All @@ -17,6 +20,7 @@ rename_types = "PascalCase"
[export.rename]
"ParseTagsResult" = "ddog_Vec_Tag_ParseResult"
"PushTagResult" = "ddog_Vec_Tag_PushResult"
"ZendString" = "_zend_string"
"FILE" = "FILE"

[enum]
Expand Down
2 changes: 2 additions & 0 deletions components-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ datadog-ipc = { path = "../libdatadog/datadog-ipc" }
datadog-remote-config = { path = "../libdatadog/datadog-remote-config" }
datadog-sidecar = { path = "../libdatadog/datadog-sidecar" }
datadog-sidecar-ffi = { path = "../libdatadog/datadog-sidecar-ffi" }
tinybytes = { path = "../libdatadog/tinybytes" }
datadog-trace-utils = { path = "../libdatadog/datadog-trace-utils" }
datadog-crashtracker-ffi = { path = "../libdatadog/datadog-crashtracker-ffi", default-features = false, features = ["collector"] }
datadog-library-config-ffi = { path = "../libdatadog/datadog-library-config-ffi", default-features = false }
spawn_worker = { path = "../libdatadog/spawn_worker" }
Expand Down
Loading
Loading