Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions appsec/tests/extension/client_init_record_span_tags.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Array
[_dd.p.dm] => -0
[_dd.p.tid] => %s
[_dd.runtime_family] => php
[_dd.sdk.otlp_export] => false
[appsec.event] => true
[http.endpoint] => /foo
[http.method] => GET
Expand Down
1 change: 1 addition & 0 deletions appsec/tests/extension/ddtrace_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Array
(
[_dd.p.dm] => -0
[_dd.p.tid] => %s
[_dd.sdk.otlp_export] => false
[ddappsec] => true
[runtime-id] => %s
)
1 change: 1 addition & 0 deletions appsec/tests/extension/rinit_record_span_tags.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Array
[_dd.p.dm] => -0
[_dd.p.tid] => %s
[_dd.runtime_family] => php
[_dd.sdk.otlp_export] => false
[appsec.event] => true
[http.endpoint] => /foo
[http.method] => GET
Expand Down
1 change: 1 addition & 0 deletions appsec/tests/extension/rinit_record_span_tags_fail.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ Array
(
[_dd.p.dm] => -0
[_dd.p.tid] => %s
[_dd.sdk.otlp_export] => false
[runtime-id] => %s
)
1 change: 1 addition & 0 deletions appsec/tests/extension/rinit_root_span_add_tag.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Array
(
[_dd.p.dm] => -0
[_dd.p.tid] => %s
[_dd.sdk.otlp_export] => false
[ddappsec] => true
[env] => staging
[http.method] => GET
Expand Down
4 changes: 3 additions & 1 deletion appsec/tests/extension/root_span_add_tag.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ array(1) {
["type"]=>
string(3) "cli"
["meta"]=>
array(4) {
array(5) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["after"]=>
string(9) "root_span"
["runtime-id"]=>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Array
[_dd.p.dm] => -0
[_dd.p.tid] => %s
[_dd.runtime_family] => php
[_dd.sdk.otlp_export] => false
[after] => root_span
[before] => root_span
[runtime-id] => %s
Expand Down
3 changes: 3 additions & 0 deletions tests/Common/SnapshotTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ private function stopAndCompareSnapshotSession(
if (!in_array('meta._dd.svc_src', $fieldsToIgnore, true)) {
$fieldsToIgnore[] = 'meta._dd.svc_src';
}
if (!in_array('meta._dd.sdk.otlp_export', $fieldsToIgnore, true)) {
$fieldsToIgnore[] = 'meta._dd.sdk.otlp_export';
}
$url = self::$testAgentUrl . '/test/session/snapshot?ignores=' . implode(',', $fieldsToIgnore) .
'&test_session_token=' . $token;

Expand Down
5 changes: 5 additions & 0 deletions tests/Common/SpanChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public static function dumpSpansGraph(array $spansGraph, int $indent = 0)
if (isset($span['meta'])) {
unset($span['meta']['_dd.p.dm']);
unset($span['meta']['_dd.p.tid']);
unset($span['meta']['_dd.sdk.otlp_export']);
unset($span['meta']['http.client_ip']);
foreach ($span['meta'] as $k => $v) {
$out .= str_repeat(' ', $indent) . ' ' . $k . ' => ' . $v . "\n";
Expand Down Expand Up @@ -490,6 +491,10 @@ function ($key) use ($pattern) {
if (!isset($expectedTags['runtime-id'])) {
unset($filtered['runtime-id']);
}
// Ignore _dd.sdk.otlp_export unless explicitly tested
if (!isset($expectedTags['_dd.sdk.otlp_export'])) {
unset($filtered['_dd.sdk.otlp_export']);
}
// http.client_ip is present depending on target SAPI and not helpful here to test
if (!isset($expectedTags['http.client_ip'])) {
unset($filtered['http.client_ip']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function largeBaseConvert($numString, $fromBase, $toBase)

function dump_spans() {
foreach (dd_trace_serialize_closed_spans() as $span) {
unset($span["meta"]["process_id"], $span["meta"]["runtime-id"], $span["meta"]["_dd.p.dm"], $span["meta"]["_dd.tags.process"]);
unset($span["meta"]["process_id"], $span["meta"]["runtime-id"], $span["meta"]["_dd.p.dm"], $span["meta"]["_dd.tags.process"], $span["meta"]["_dd.sdk.otlp_export"]);
echo "parent: ", $span["parent_id"] ?? 0, ", trace: {$span["trace_id"]}, meta: " . json_encode($span["meta"] ?? []) . "\n";
}
return $span;
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/extract_server_values.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ var_dump(dd_trace_serialize_closed_spans()[0]["meta"]);

?>
--EXPECTF--
array(5) {
array(6) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["http.request.headers.0"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/referrer_extraction_01.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ $spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']);
?>
--EXPECTF--
array(8) {
array(9) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["http.method"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/referrer_extraction_02.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ $spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']);
?>
--EXPECTF--
array(9) {
array(10) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["http.method"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/referrer_extraction_03.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ $spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']);
?>
--EXPECTF--
array(8) {
array(9) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["http.method"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/referrer_extraction_04.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ $spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']);
?>
--EXPECTF--
array(8) {
array(9) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["http.method"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/referrer_extraction_05.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ $spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']);
?>
--EXPECTF--
array(9) {
array(10) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["http.method"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/root_span_url_as_resource_names.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ $spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']);
?>
--EXPECTF--
array(8) {
array(9) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["http.method"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/root_span_url_as_resource_names_no_host.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ $spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']);
?>
--EXPECTF--
array(8) {
array(9) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["http.method"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/root_span_url_with_post_no_param.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ $spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']);
?>
--EXPECTF--
array(4) {
array(5) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["runtime-id"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/ext/root_span_url_with_post_no_param_set.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ $spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']);
?>
--EXPECTF--
array(4) {
array(5) {
["_dd.p.dm"]=>
string(2) "-0"
["_dd.p.tid"]=>
string(16) "%s"
["_dd.sdk.otlp_export"]=>
string(5) "false"
["_dd.tags.process"]=>
string(%d) "%s"
["runtime-id"]=>
Expand Down
2 changes: 2 additions & 0 deletions tests/ext/sandbox/dd_dumper.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function dd_dump_spans($skipMeta = false)
echo PHP_EOL;
unset($span["meta"]["runtime-id"]);
unset($span["meta"]["_dd.tags.process"]);
unset($span["meta"]["_dd.sdk.otlp_export"]);
foreach ($span['meta'] as $k => $v) {
echo str_repeat(' ', $indent) . ' ' . $k . ' => ' . $v . PHP_EOL;
}
Expand Down Expand Up @@ -82,6 +83,7 @@ function dd_clean_spans() {
foreach ($spans as &$span) {
if (isset($span['meta'])) {
unset($span['meta']['_dd.tags.process']);
unset($span['meta']['_dd.sdk.otlp_export']);
if (empty($span['meta'])) {
unset($span['meta']);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ext/sandbox/safe_to_string_metadata.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $allTheTypes[0][1] = &$allTheTypes[0];
call_user_func_array('meta_to_string', $allTheTypes);

list($span) = dd_trace_serialize_closed_spans();
unset($span['meta']['process_id'], $span['meta']['_dd.tags.process']);
unset($span['meta']['process_id'], $span['meta']['_dd.tags.process'], $span['meta']['_dd.sdk.otlp_export']);
$last = -1;
foreach ($span['meta'] as $key => $value) {
$index = (int)substr($key, 4);
Expand Down
32 changes: 32 additions & 0 deletions tests/ext/sdk_otlp_export_marker.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
_dd.sdk.otlp_export marker is set to "false" on the first span of each trace chunk only
--ENV--
DD_TRACE_GENERATE_ROOT_SPAN=0
DD_TRACE_AUTO_FLUSH_ENABLED=0
--FILE--
<?php
for ($i = 0; $i < 2; $i++) {
\DDTrace\start_trace_span()->name = "root_$i";
\DDTrace\start_span()->name = "child_$i";
\DDTrace\start_span()->name = "grandchild_$i";
\DDTrace\close_span();
\DDTrace\close_span();
\DDTrace\close_span();
}

$seen = [];
foreach (dd_trace_serialize_closed_spans() as $span) {
$first = !isset($seen[$span['trace_id']]);
$seen[$span['trace_id']] = true;
echo ($first ? "first" : "other"), ": ", var_export($span['meta']['_dd.sdk.otlp_export'] ?? null, true), "\n";
}
echo count($seen), " chunks\n";
?>
--EXPECT--
first: 'false'
other: NULL
other: NULL
first: 'false'
other: NULL
other: NULL
2 chunks
2 changes: 2 additions & 0 deletions tracer/serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,8 @@ ddog_SpanBytes *ddtrace_serialize_span_to_rust_span(ddtrace_span_data *span, ddo
ddog_set_span_duration(rust_span, span->duration);

if (is_first_span) {
ddog_add_str_span_meta_str(rust_span, "_dd.sdk.otlp_export", "false");

zend_string *process_tags = datadog_process_tags_get_serialized();
if (ZSTR_LEN(process_tags)) {
const char *svc_tag_appendix = NULL;
Expand Down
Loading