Skip to content

Commit a9caaa0

Browse files
dubloomPROFeNoMbwoebi
authored
Adds process_tags to crashtracking tags (#3582)
* init process tags for APM Co-Authored-By: PROFeNoM <[email protected]> * feat(process_tags): add process_tags to tracing payloads * small auto review and fix test * bwoebi review * fix test * adds process tags to crashtracker tags * Move process tags assign Signed-off-by: Bob Weinand <[email protected]> * auto review * fix tests * fix crashtracker test * test only on 7.2+ * bump libdatadog and update tests * merge process_tags into existing tests --------- Signed-off-by: Bob Weinand <[email protected]> Co-authored-by: PROFeNoM <[email protected]> Co-authored-by: Bob Weinand <[email protected]>
1 parent 38115f9 commit a9caaa0

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

ext/sidecar.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "process_tags.h"
1616
#include "serializer.h"
1717
#include "remote_config.h"
18+
#include "process_tags.h"
1819
#ifndef _WIN32
1920
#include "coms.h"
2021
#endif
@@ -658,6 +659,11 @@ ddog_crasht_Metadata ddtrace_setup_crashtracking_metadata(ddog_Vec_Tag *tags) {
658659
const char *runtime_version = zend_get_module_version("Reflection");
659660
ddtrace_sidecar_push_tag(tags, DDOG_CHARSLICE_C("runtime_version"), (ddog_CharSlice) {.ptr = (char *) runtime_version, .len = strlen(runtime_version)});
660661

662+
zend_string *process_tags = ddtrace_process_tags_get_serialized();
663+
if (ZSTR_LEN(process_tags)) {
664+
ddtrace_sidecar_push_tag(tags, DDOG_CHARSLICE_C("process_tags"), (ddog_CharSlice) {.ptr = ZSTR_VAL(process_tags), .len = ZSTR_LEN(process_tags)});
665+
}
666+
661667
return (ddog_crasht_Metadata){
662668
.library_name = DDOG_CHARSLICE_C_BARE("dd-trace-php"),
663669
.library_version = DDOG_CHARSLICE_C_BARE(PHP_DDTRACE_VERSION),

tests/ext/crashtracker_segfault.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ include __DIR__ . '/includes/skipif_no_dev_env.inc';
1313
DD_TRACE_LOG_LEVEL=0
1414
DD_AGENT_HOST=request-replayer
1515
DD_TRACE_AGENT_PORT=80
16+
DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=1
1617
--INI--
1718
datadog.trace.agent_test_session_token=tests/ext/crashtracker_segfault.phpt
1819
--FILE--
@@ -43,6 +44,8 @@ $rr->waitForRequest(function ($request) {
4344
continue;
4445
}
4546

47+
echo $json["application"]["process_tags"], PHP_EOL;
48+
4649
foreach ($json["payload"]["logs"] as $payload) {
4750
$payload["message"] = json_decode($payload["message"], true);
4851
if (!isset($payload["message"]["metadata"])) {
@@ -63,6 +66,7 @@ $rr->waitForRequest(function ($request) {
6366
});
6467
?>
6568
--EXPECTF--
69+
%Aentrypoint.name:standard_input_code,entrypoint.type:script,entrypoint.workdir:%s,runtime.sapi:cli
6670
%A{
6771
"message": {
6872
%A

tests/ext/crashtracker_segfault_windows.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ include __DIR__ . '/includes/skipif_no_dev_env.inc';
1414
DD_TRACE_LOG_LEVEL=0
1515
DD_AGENT_HOST=request-replayer
1616
DD_TRACE_AGENT_PORT=3188
17+
DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=1
1718
--INI--
1819
datadog.trace.agent_test_session_token=tests/ext/crashtracker_segfault_windows.phpt
1920
--FILE--
@@ -56,6 +57,8 @@ $rr->waitForRequest(function ($request) {
5657
continue;
5758
}
5859

60+
echo $json["application"]["process_tags"], PHP_EOL;
61+
5962
foreach ($json["payload"]["logs"] as $payload) {
6063
$payload["message"] = json_decode($payload["message"], true);
6164
if (!isset($payload["message"]["metadata"])) {
@@ -73,6 +76,7 @@ $rr->waitForRequest(function ($request) {
7376
});
7477
?>
7578
--EXPECTF--
79+
%Aentrypoint.name:standard_input_code,entrypoint.type:script,entrypoint.workdir:%s,runtime.sapi:cli
7680
%A{
7781
"message": {
7882
"data_schema_version": "1.2",

0 commit comments

Comments
 (0)