Skip to content

Commit b3bdafd

Browse files
committed
Merge branch 'master' of github.com:DataDog/dd-trace-php into glopes/http-endpoint
Signed-off-by: Bob Weinand <[email protected]>
2 parents f224364 + 67cc5cd commit b3bdafd

File tree

161 files changed

+2335
-5043
lines changed

Some content is hidden

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

161 files changed

+2335
-5043
lines changed

.github/workflows/prof_correctness.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-24.04
1111
strategy:
1212
matrix:
13-
php-version: [8.0, 8.1, 8.2, 8.3, 8.4]
13+
php-version: [8.0, 8.1, 8.2, 8.3, 8.4, 8.5]
1414
phpts: [nts, zts]
1515
include:
1616
- phpts: zts
@@ -24,7 +24,7 @@ jobs:
2424
submodules: true
2525

2626
- name: Setup PHP
27-
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
27+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2.35.5
2828
with:
2929
php-version: ${{ matrix.php-version }}
3030
extensions: ${{ matrix.extensions }}

.gitlab/generate-tracer.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ function before_script_steps() {
129129

130130
mkdir dumps
131131

132-
# Start the container
132+
$names = @('httpbin-integration','request-replayer', $env:CONTAINER_NAME)
133+
foreach ($n in $names) { try { docker rm -f $n | Out-Null } catch {} }
134+
try { docker network rm net | Out-Null } catch {}
135+
136+
# Start the container network and services
133137
docker network create -d "nat" -o com.docker.network.windowsshim.dnsservers="1.1.1.1" net
134138
docker run --network net -d --name httpbin-integration registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:httpbin-windows
135139
docker run --network net -d --name request-replayer registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-request-replayer-2.0-windows
@@ -150,6 +154,13 @@ function before_script_steps() {
150154
- |
151155
docker exec php cmd.exe /s /c xcopy /y /c /s /e C:\ProgramData\Microsoft\Windows\WER\ReportQueue .\app\dumps\
152156
exit 0
157+
- 'powershell -NoProfile -Command "try { docker logs request-replayer } catch {}"'
158+
- 'powershell -NoProfile -Command "try { docker logs httpbin-integration } catch {}"'
159+
- 'powershell -NoProfile -Command "try { docker stop -t 5 request-replayer } catch {}"'
160+
- 'powershell -NoProfile -Command "try { docker rm -f request-replayer } catch {}"'
161+
- 'powershell -NoProfile -Command "try { docker stop -t 5 httpbin-integration } catch {}"'
162+
- 'powershell -NoProfile -Command "try { docker rm -f httpbin-integration } catch {}"'
163+
- 'powershell -NoProfile -Command "try { docker network rm net } catch {}"'
153164
artifacts:
154165
paths:
155166
- sidecar.log

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ ALL_TEST_ENV_OVERRIDE := $(shell [ -n "${DD_TRACE_DOCKER_DEBUG}" ] && echo DD_TR
3737

3838
VERSION := $(shell cat VERSION)
3939

40-
INI_FILE := $(shell ASAN_OPTIONS=detect_leaks=0 php -d ddtrace.disable=1 -i | awk -F"=>" '/Scan this dir for additional .ini files/ {print $$2}')/ddtrace.ini
40+
INI_DIR := $(shell ASAN_OPTIONS=detect_leaks=0 php -d ddtrace.disable=1 -i | awk -F"=>" '/Scan this dir for additional .ini files/ {print $$2}')
41+
INI_FILE := $(INI_DIR)/ddtrace.ini
4142
TRACER_SOURCES_INI := -d datadog.trace.sources_path=$(TRACER_SOURCE_DIR)
4243

4344
RUN_TESTS_IS_PARALLEL ?= $(shell test $(PHP_MAJOR_MINOR) -ge 74 && echo 1)
@@ -378,6 +379,13 @@ prod:
378379
strict:
379380
$(eval CFLAGS=-Wall -Werror -Wextra)
380381

382+
compile_profiler:
383+
(cd profiling; CARGO_TARGET_DIR=$(PROJECT_ROOT)/tmp/build_profiler cargo build --release --features trigger_time_sample)
384+
385+
install_profiler: compile_profiler
386+
cp $(PROJECT_ROOT)/tmp/build_profiler/release/libdatadog_php_profiling.so $(PHP_EXTENSION_DIR)/datadog-profiling.so
387+
$(Q) echo "extension=datadog-profiling.so" | $(SUDO) tee $(INI_DIR)/datadog-profiling.ini
388+
381389
clang_find_files_to_lint:
382390
@find . \( \
383391
-path ./.git -prune -o \

aggregated_tested_versions.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cakephp/cakephp": [
33
"3.10.5",
44
"4.6.2",
5-
"5.2.6"
5+
"5.2.7"
66
],
77
"drupal/drupal": [
88
"10.1.3",
@@ -90,7 +90,7 @@
9090
"6.0.0"
9191
],
9292
"google/cloud-spanner": [
93-
"1.104.0"
93+
"1.105.0"
9494
],
9595
"guzzlehttp/guzzle": [
9696
"5.3.4",
@@ -110,9 +110,9 @@
110110
"3.8.0"
111111
],
112112
"laravel/framework": [
113-
"10.48.29",
114-
"11.45.2",
115-
"12.25.0",
113+
"10.49.0",
114+
"11.46.0",
115+
"12.30.1",
116116
"4.2.22",
117117
"5.7.29",
118118
"5.8.38",
@@ -128,7 +128,7 @@
128128
"9.1.6"
129129
],
130130
"laravel/octane": [
131-
"2.12.1"
131+
"2.12.2"
132132
],
133133
"magento/magento2": [
134134
"2.3.7",
@@ -152,7 +152,7 @@
152152
"3.2.7"
153153
],
154154
"openai-php/client": [
155-
"0.15.0"
155+
"0.16.1"
156156
],
157157
"php-amqplib/php-amqplib": [
158158
"2.12.1",
@@ -181,7 +181,7 @@
181181
"symfony/console": [
182182
"5.2.14",
183183
"6.2.13",
184-
"7.3.2"
184+
"7.3.3"
185185
],
186186
"symfony/framework-bundle": [
187187
"2.3.42",
@@ -196,13 +196,13 @@
196196
"5.1.11",
197197
"5.2.12",
198198
"6.2.13",
199-
"7.3.2"
199+
"7.3.3"
200200
],
201201
"symfony/messenger": [
202202
"4.4.49",
203203
"5.2.12",
204204
"6.2.13",
205-
"7.3.2"
205+
"7.3.3"
206206
],
207207
"wordpress": [
208208
"4.8.10",

components-rs/common.h

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,8 +1511,28 @@ typedef enum ddog_LibraryConfigSource {
15111511
DDOG_LIBRARY_CONFIG_SOURCE_FLEET_STABLE_CONFIG = 1,
15121512
} ddog_LibraryConfigSource;
15131513

1514+
/**
1515+
* Represents the types of metadata that can be set on a `TracerMetadata` object.
1516+
*/
1517+
typedef enum ddog_MetadataKind {
1518+
DDOG_METADATA_KIND_RUNTIME_ID = 0,
1519+
DDOG_METADATA_KIND_TRACER_LANGUAGE = 1,
1520+
DDOG_METADATA_KIND_TRACER_VERSION = 2,
1521+
DDOG_METADATA_KIND_HOSTNAME = 3,
1522+
DDOG_METADATA_KIND_SERVICE_NAME = 4,
1523+
DDOG_METADATA_KIND_SERVICE_ENV = 5,
1524+
DDOG_METADATA_KIND_SERVICE_VERSION = 6,
1525+
DDOG_METADATA_KIND_PROCESS_TAGS = 7,
1526+
DDOG_METADATA_KIND_CONTAINER_ID = 8,
1527+
} ddog_MetadataKind;
1528+
15141529
typedef struct ddog_Configurator ddog_Configurator;
15151530

1531+
/**
1532+
* This struct MUST be backward compatible.
1533+
*/
1534+
typedef struct ddog_TracerMetadata ddog_TracerMetadata;
1535+
15161536
/**
15171537
* Ffi safe type representing a borrowed null-terminated C array
15181538
* Equivalent to a std::ffi::CStr
@@ -1581,25 +1601,29 @@ typedef struct ddog_Vec_LibraryConfig {
15811601
} ddog_Vec_LibraryConfig;
15821602

15831603
/**
1584-
* A generic result type for when an operation may fail,
1585-
* or may return <T> in case of success.
1604+
* A result type that includes debug/log messages along with the data
15861605
*/
1587-
typedef enum ddog_Result_VecLibraryConfig_Tag {
1588-
DDOG_RESULT_VEC_LIBRARY_CONFIG_OK_VEC_LIBRARY_CONFIG,
1589-
DDOG_RESULT_VEC_LIBRARY_CONFIG_ERR_VEC_LIBRARY_CONFIG,
1590-
} ddog_Result_VecLibraryConfig_Tag;
1591-
1592-
typedef struct ddog_Result_VecLibraryConfig {
1593-
ddog_Result_VecLibraryConfig_Tag tag;
1606+
typedef struct ddog_OkResult {
1607+
struct ddog_Vec_LibraryConfig value;
1608+
struct ddog_CString logs;
1609+
} ddog_OkResult;
1610+
1611+
typedef enum ddog_LibraryConfigLoggedResult_Tag {
1612+
DDOG_LIBRARY_CONFIG_LOGGED_RESULT_OK,
1613+
DDOG_LIBRARY_CONFIG_LOGGED_RESULT_ERR,
1614+
} ddog_LibraryConfigLoggedResult_Tag;
1615+
1616+
typedef struct ddog_LibraryConfigLoggedResult {
1617+
ddog_LibraryConfigLoggedResult_Tag tag;
15941618
union {
15951619
struct {
1596-
struct ddog_Vec_LibraryConfig ok;
1620+
struct ddog_OkResult ok;
15971621
};
15981622
struct {
15991623
struct ddog_Error err;
16001624
};
16011625
};
1602-
} ddog_Result_VecLibraryConfig;
1626+
} ddog_LibraryConfigLoggedResult;
16031627

16041628
/**
16051629
* C-compatible representation of an anonymous file handle

components-rs/library-config.h

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,6 @@
99

1010
#include "common.h"
1111

12-
/**
13-
* A result type that includes debug/log messages along with the data
14-
*/
15-
typedef struct ddog_OkResult {
16-
struct ddog_Vec_LibraryConfig value;
17-
struct ddog_CString logs;
18-
} ddog_OkResult;
19-
20-
typedef enum ddog_LibraryConfigLoggedResult_Tag {
21-
DDOG_LIBRARY_CONFIG_LOGGED_RESULT_OK,
22-
DDOG_LIBRARY_CONFIG_LOGGED_RESULT_ERR,
23-
} ddog_LibraryConfigLoggedResult_Tag;
24-
25-
typedef struct ddog_LibraryConfigLoggedResult {
26-
ddog_LibraryConfigLoggedResult_Tag tag;
27-
union {
28-
struct {
29-
struct ddog_OkResult ok;
30-
};
31-
struct {
32-
struct ddog_Error err;
33-
};
34-
};
35-
} ddog_LibraryConfigLoggedResult;
36-
3712
#ifdef __cplusplus
3813
extern "C" {
3914
#endif // __cplusplus
@@ -76,20 +51,60 @@ struct ddog_CStr ddog_library_config_local_stable_config_path(void);
7651
void ddog_library_config_drop(struct ddog_LibraryConfigLoggedResult config_result);
7752

7853
/**
79-
* Store tracer metadata to a file handle
54+
* Allocates and returns a pointer to a new `TracerMetadata` object on the heap.
8055
*
8156
* # Safety
57+
* This function returns a raw pointer. The caller is responsible for calling
58+
* `ddog_tracer_metadata_free` to deallocate the memory.
59+
*
60+
* # Returns
61+
* A non-null pointer to a newly allocated `TracerMetadata` instance.
62+
*/
63+
struct ddog_TracerMetadata *ddog_tracer_metadata_new(void);
64+
65+
/**
66+
* Frees a `TracerMetadata` instance previously allocated with `ddog_tracer_metadata_new`.
67+
*
68+
* # Safety
69+
* - `ptr` must be a pointer previously returned by `ddog_tracer_metadata_new`.
70+
* - Double-freeing or passing an invalid pointer results in undefined behavior.
71+
* - Passing a null pointer is safe and does nothing.
72+
*/
73+
void ddog_tracer_metadata_free(struct ddog_TracerMetadata *ptr);
74+
75+
/**
76+
* Sets a field of the `TracerMetadata` object pointed to by `ptr`.
77+
*
78+
* # Arguments
79+
* - `ptr`: Pointer to a `TracerMetadata` instance.
80+
* - `kind`: The metadata field to set (as defined in `MetadataKind`).
81+
* - `value`: A null-terminated C string representing the value to set.
82+
*
83+
* # Safety
84+
* - Both `ptr` and `value` must be non-null.
85+
* - `value` must point to a valid UTF-8 null-terminated string.
86+
* - If the string is not valid UTF-8, the function does nothing.
87+
*/
88+
void ddog_tracer_metadata_set(struct ddog_TracerMetadata *ptr,
89+
enum ddog_MetadataKind kind,
90+
const char *value);
91+
92+
/**
93+
* Serializes the `TracerMetadata` into a platform-specific memory handle (e.g., memfd on Linux).
94+
*
95+
* # Safety
96+
* - `ptr` must be a valid, non-null pointer to a `TracerMetadata`.
97+
*
98+
* # Returns
99+
* - On Linux: a `TracerMemfdHandle` containing a raw file descriptor to a memory file.
100+
* - On unsupported platforms: an error.
101+
* - On failure: propagates any internal errors from the metadata storage process.
82102
*
83-
* Accepts raw C-compatible strings
103+
* # Platform Support
104+
* This function currently only supports Linux via `memfd`. On other platforms,
105+
* it will return an error.
84106
*/
85-
struct ddog_Result_TracerMemfdHandle ddog_store_tracer_metadata(uint8_t schema_version,
86-
ddog_CharSlice runtime_id,
87-
ddog_CharSlice tracer_language,
88-
ddog_CharSlice tracer_version,
89-
ddog_CharSlice hostname,
90-
ddog_CharSlice service_name,
91-
ddog_CharSlice service_env,
92-
ddog_CharSlice service_version);
107+
struct ddog_Result_TracerMemfdHandle ddog_tracer_metadata_store(struct ddog_TracerMetadata *ptr);
93108

94109
#ifdef __cplusplus
95110
} // extern "C"

config.m4

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ if test "$PHP_DDTRACE" != "no"; then
231231
zend_abstract_interface/headers/headers.c \
232232
zend_abstract_interface/hook/hook.c \
233233
zend_abstract_interface/json/json.c \
234-
zend_abstract_interface/symbols/lookup.c \
235-
zend_abstract_interface/symbols/call.c \
234+
zend_abstract_interface/sandbox/call.c \
236235
zend_abstract_interface/uri_normalization/uri_normalization.c \
237236
zend_abstract_interface/zai_string/string.c \
238237
"
@@ -296,7 +295,6 @@ EOT
296295

297296
PHP_ADD_INCLUDE([$ext_srcdir/zend_abstract_interface])
298297
PHP_ADD_BUILD_DIR([$ext_builddir/zend_abstract_interface])
299-
PHP_ADD_BUILD_DIR([$ext_builddir/zend_abstract_interface/symbols])
300298
PHP_ADD_BUILD_DIR([$ext_builddir/zend_abstract_interface/config])
301299
PHP_ADD_BUILD_DIR([$ext_builddir/zend_abstract_interface/env])
302300
PHP_ADD_BUILD_DIR([$ext_builddir/zend_abstract_interface/exceptions])

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ if (PHP_DDTRACE != 'no') {
106106
ADD_SOURCES(zai_dirname + "/headers", "headers.c", "ddtrace");
107107
ADD_SOURCES(zai_dirname + "/hook", "hook.c", "ddtrace");
108108
ADD_SOURCES(zai_dirname + "/json", "json.c", "ddtrace");
109+
ADD_SOURCES(zai_dirname + "/sandbox", "call.c", "ddtrace");
109110
ADD_SOURCES(zai_dirname + "/zai_string", "string.c", "ddtrace");
110-
ADD_SOURCES(zai_dirname + "/symbols", "call.c lookup.c", "ddtrace");
111111
ADD_SOURCES(zai_dirname + "/uri_normalization", "uri_normalization.c", "ddtrace");
112112
if (version < 800) {
113113
ADD_SOURCES(zai_dirname + "/sandbox/php7", "sandbox.c", "ddtrace");

ext/autoload_php_files.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "telemetry.h"
1515
#include <components/log/log.h>
1616
#include <sandbox/sandbox.h>
17-
#include <symbols/symbols.h>
1817

1918
ZEND_EXTERN_MODULE_GLOBALS(ddtrace);
2019

0 commit comments

Comments
 (0)