Skip to content

Commit 9010299

Browse files
committed
Fix PHP debugger test issues
- Add DD_APPSEC_ENABLED=0 to DebuggerScenario to prevent appsec fields from appearing in exception replay snapshot comparisons - Convert PHP line probes to method probes in set_probes() since PHP does not support line-level instrumentation - Add PHP /debugger/init request in send_rc_apm_tracing_and_probes() to ensure RC is processed before the test request fires the probe
1 parent 226bc3d commit 9010299

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

tests/debugger/utils.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,30 @@ def __get_probe_type(probe_id: str):
248248
go_build_dir = {"uds-echo": "echo"}.get(variant, variant)
249249
source_file = f"{go_build_dir}/debugger.go"
250250
elif language == "php":
251-
source_file = "debugger.php"
252-
253-
if uppercase_source_files:
254-
source_file = source_file.upper()
255-
if path_prefix:
256-
source_file = os.path.join(path_prefix, source_file)
257-
if use_backslashes:
258-
source_file = source_file.replace("/", "\\")
251+
# PHP does not support line probes; convert to a method probe.
252+
php_line_to_method = {
253+
"20": "LogProbe",
254+
"71": "expression",
255+
}
256+
lines = probe["where"].get("lines", [])
257+
method = next((php_line_to_method[line] for line in lines if line in php_line_to_method), None)
258+
if method:
259+
probe["where"]["typeName"] = "DebuggerController"
260+
probe["where"]["methodName"] = method
261+
probe["where"]["sourceFile"] = None
262+
probe["where"]["lines"] = []
263+
probe["evaluateAt"] = "EXIT"
264+
else:
265+
source_file = "debugger.php"
259266

260-
probe["where"]["sourceFile"] = source_file
267+
if source_file != "":
268+
if uppercase_source_files:
269+
source_file = source_file.upper()
270+
if path_prefix:
271+
source_file = os.path.join(path_prefix, source_file)
272+
if use_backslashes:
273+
source_file = source_file.replace("/", "\\")
274+
probe["where"]["sourceFile"] = source_file
261275

262276
# Go system-probe requires methodName for line probes to identify the function.
263277
# Other languages resolve this from sourceFile+line, but the eBPF-based
@@ -373,6 +387,10 @@ def send_rc_apm_tracing_and_probes(
373387
)
374388
)
375389

390+
# PHP tracer requires a request to /debugger/* to process RC before the test request.
391+
if context.library == "php":
392+
weblog.get("/debugger/init")
393+
376394
def send_rc_symdb(self, *, reset: bool = True) -> None:
377395
BaseDebuggerTest._rc_version += 1
378396
if reset:

utils/_context/_scenarios/debugger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def __init__(self, name: str, doc: str, weblog_env: dict[str, str | None]) -> No
1111
base_weblog_env: dict[str, str | None] = {
1212
"DD_REMOTE_CONFIG_ENABLED": "1",
1313
"DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS": "1",
14+
"DD_APPSEC_ENABLED": "0",
1415
# added temporarily to troubleshoot debugger test flakiness
1516
"JAVA_OPTS": " -Ddatadog.slf4j.simpleLogger.log.com.datadog.debugger=debug ",
1617
}

0 commit comments

Comments
 (0)