Skip to content

Commit ed128c8

Browse files
Leiyksbwoebi
andauthored
Use native rust spans instead of manually serializing to msgpack (#3194)
* feat(component-rs): add data-pipeline header Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * Fix missing use Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com> * Update libdatadog Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com> * feat(tracer): use rust span API Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * chore: bump libdatadog Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * feat(tracer: serializer): complete replacement of rust span API in serialization method Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * feat(ext: tracer): add local API to use zendString instead of CharSlice Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * feat(ext: tracer): apply PR feedbacks Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * feat(tracer): modify communication code between the tracer and sidecar Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * feat(tracer): add function to convert a rust span to a zval Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * chore: fix tests Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * chore: fix tests Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * Switch to new way to pass zend_strings Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com> * chore: fix tests Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * chore: remove useless free statements Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * chore: fix remaining failing tests Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * test: fix windows compiling tests Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * feat: move rust span code to sidecar-ffi Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * feat: improve serializer performance by using literal instead of CharSlice Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> * chore: rebase with master Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> --------- Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com> Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com> Co-authored-by: Bob Weinand <bob.weinand@datadoghq.com>
1 parent 91222ad commit ed128c8

96 files changed

Lines changed: 1617 additions & 1282 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.

Cargo.lock

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

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ generate_cbindgen: cbindgen_binary # Regenerate components-rs/ddtrace.h componen
437437
mkdir -pv "$(BUILD_DIR)"; \
438438
export CARGO_TARGET_DIR="$(BUILD_DIR)/target"; \
439439
fi; \
440-
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 \
440+
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 \
441441
)
442442

443443
cbindgen_binary:

appsec/tests/extension/client_init_record_span_tags.phpt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ echo "tags:\n";
6161
ksort($tags);
6262
print_r($tags);
6363
echo "metrics:\n";
64+
ksort($metrics);
6465
print_r($metrics);
6566

6667
$helper->finished_with_commands();
@@ -104,12 +105,12 @@ metrics:
104105
Array
105106
(
106107
[%s] => %d
107-
[metric_1] => 2
108-
[metric_2] => 10
109108
[_dd.appsec.enabled] => 1
110-
[_dd.agent_psr] => 1
111109
[_sampling_priority_v1] => 1
110+
[metric_1] => 2
111+
[metric_2] => 10
112112
[php.compilation.total_time_ms] => %f
113-
[php.memory.peak_usage_bytes] => %f
114113
[php.memory.peak_real_usage_bytes] => %f
114+
[php.memory.peak_usage_bytes] => %f
115+
[process_id] => %d
115116
)

appsec/tests/extension/ddtrace_basic.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ echo 'sent trace id is the same as \DDTrace\trace_id(): ',
7070
$trace_id == $sent_trace_id ? 'yes' : 'no', "\n";
7171

7272
echo "tags:\n";
73+
ksort($tags);
7374
print_r($tags);
7475

7576
mlog(DEBUG, "Call finished_with_commands");
@@ -101,8 +102,8 @@ sent trace id is the same as \DDTrace\trace_id(): yes
101102
tags:
102103
Array
103104
(
104-
[runtime-id] => %s
105-
[ddappsec] => true
106105
[_dd.p.dm] => -0
107106
[_dd.p.tid] => %s
108-
)
107+
[ddappsec] => true
108+
[runtime-id] => %s
109+
)

appsec/tests/extension/rinit_record_span_tags.phpt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ echo "tags:\n";
5656
ksort($tags);
5757
print_r($tags);
5858
echo "metrics:\n";
59+
ksort($metrics);
5960
print_r($metrics);
6061

6162
$helper->finished_with_commands();
@@ -98,11 +99,11 @@ metrics:
9899
Array
99100
(
100101
[%s] => %d
101-
[rshutdown_metric] => 2.1
102102
[_dd.appsec.enabled] => 1
103-
[_dd.agent_psr] => 1
104103
[_sampling_priority_v1] => 1
105104
[php.compilation.total_time_ms] => %f
106-
[php.memory.peak_usage_bytes] => %f
107105
[php.memory.peak_real_usage_bytes] => %f
108-
)
106+
[php.memory.peak_usage_bytes] => %f
107+
[process_id] => %d
108+
[rshutdown_metric] => 2.1
109+
)

appsec/tests/extension/rinit_record_span_tags_fail.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ $commands = $helper->get_commands();
3737
$tags = $commands[0]['payload'][0][0]['meta'];
3838

3939
echo "tags:\n";
40+
ksort($tags);
4041
print_r($tags);
4142

4243
$helper->finished_with_commands();
@@ -52,7 +53,7 @@ bool(true)
5253
tags:
5354
Array
5455
(
55-
[runtime-id] => %s
5656
[_dd.p.dm] => -0
5757
[_dd.p.tid] => %s
58-
)
58+
[runtime-id] => %s
59+
)

appsec/tests/extension/root_span_add_tag.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,28 @@ array(1) {
4747
string(3) "cli"
4848
["meta"]=>
4949
array(4) {
50-
["runtime-id"]=>
51-
string(%d) %s
52-
["after"]=>
53-
string(9) "root_span"
5450
["_dd.p.dm"]=>
5551
string(2) "-0"
5652
["_dd.p.tid"]=>
5753
string(16) "%s"
54+
["after"]=>
55+
string(9) "root_span"
56+
["runtime-id"]=>
57+
string(%d) %s
5858
}
5959
["metrics"]=>
6060
array(6) {
6161
[%s"]=>
6262
float(%d)
63-
["_dd.agent_psr"]=>
64-
float(1)
6563
["_sampling_priority_v1"]=>
6664
float(1)
6765
["php.compilation.total_time_ms"]=>
6866
float(%s)
67+
["php.memory.peak_real_usage_bytes"]=>
68+
float(%f)
6969
["php.memory.peak_usage_bytes"]=>
7070
float(%f)
71-
["php.memory.peak_real_usage_bytes"]=>
71+
["process_id"]=>
7272
float(%f)
7373
}
7474
}

appsec/tests/extension/root_span_add_tag_with_intermediate_spans.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ echo "tags:\n";
4949
ksort($tags);
5050
print_r($tags);
5151
echo "metrics:\n";
52+
ksort($metrics);
5253
print_r($metrics);
5354

5455
$helper->finished_with_commands();
@@ -77,11 +78,11 @@ Array
7778
metrics:
7879
Array
7980
(
80-
[process_id] => %d
81-
[_dd.appsec.enabled] => 1
8281
[_dd.agent_psr] => 1
82+
[_dd.appsec.enabled] => 1
8383
[_sampling_priority_v1] => 1
8484
[php.compilation.total_time_ms] => %s
85-
[php.memory.peak_usage_bytes] => %f
8685
[php.memory.peak_real_usage_bytes] => %f
86+
[php.memory.peak_usage_bytes] => %f
87+
[process_id] => %d
8788
)

cbindgen.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ language = "C"
22
tab_width = 2
33
include_guard = "DDTRACE_PHP_H"
44
style = "both"
5+
header = """
6+
struct _zend_string;
7+
"""
58

69
no_includes = true
710
sys_includes = ["stdbool.h", "stddef.h", "stdint.h"]
@@ -17,6 +20,7 @@ rename_types = "PascalCase"
1720
[export.rename]
1821
"ParseTagsResult" = "ddog_Vec_Tag_ParseResult"
1922
"PushTagResult" = "ddog_Vec_Tag_PushResult"
23+
"ZendString" = "_zend_string"
2024
"FILE" = "FILE"
2125

2226
[enum]

components-rs/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ datadog-ipc = { path = "../libdatadog/datadog-ipc" }
1818
datadog-remote-config = { path = "../libdatadog/datadog-remote-config" }
1919
datadog-sidecar = { path = "../libdatadog/datadog-sidecar" }
2020
datadog-sidecar-ffi = { path = "../libdatadog/datadog-sidecar-ffi" }
21+
tinybytes = { path = "../libdatadog/tinybytes" }
22+
datadog-trace-utils = { path = "../libdatadog/datadog-trace-utils" }
2123
datadog-crashtracker-ffi = { path = "../libdatadog/datadog-crashtracker-ffi", default-features = false, features = ["collector"] }
2224
datadog-library-config-ffi = { path = "../libdatadog/datadog-library-config-ffi", default-features = false }
2325
spawn_worker = { path = "../libdatadog/spawn_worker" }

0 commit comments

Comments
 (0)