Skip to content

Commit 34a17f8

Browse files
committed
test: failed capture-expression evaluation is reported, not dropped
Add tests/ext/live-debugger/debugger_capture_expression_error.phpt: a log probe with a capture expression that cannot evaluate (getmember on an int) now produces an evaluationErrors entry instead of no output.
1 parent 59a08a5 commit 34a17f8

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
--TEST--
2+
A failed capture-expression evaluation is reported, not silently dropped
3+
--SKIPIF--
4+
<?php include __DIR__ . '/../includes/skipif_no_dev_env.inc'; ?>
5+
--ENV--
6+
DD_AGENT_HOST=request-replayer
7+
DD_TRACE_AGENT_PORT=80
8+
DD_TRACE_GENERATE_ROOT_SPAN=0
9+
DD_DYNAMIC_INSTRUMENTATION_ENABLED=1
10+
DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS=0.1
11+
--INI--
12+
datadog.trace.agent_test_session_token=live-debugger/capture_expression_error
13+
--FILE--
14+
<?php
15+
16+
require __DIR__ . "/live_debugger.inc";
17+
18+
reset_request_replayer();
19+
20+
class Bar {
21+
function foo($arg1) {
22+
return $arg1;
23+
}
24+
}
25+
26+
await_probe_installation(function() {
27+
build_log_probe([
28+
"where" => ["typeName" => "Bar", "methodName" => "foo"],
29+
"segments" => [["str" => "log"]],
30+
"captureExpressions" => [
31+
// getmember on an int cannot evaluate -> per-expression error
32+
["name" => "bad", "expr" => ["json" => ["getmember" => [["ref" => "arg1"], "nope"]]]],
33+
],
34+
]);
35+
36+
\DDTrace\start_span(); // submit span data
37+
});
38+
39+
(new Bar)->foo(10);
40+
41+
$dlr = new DebuggerLogReplayer;
42+
$errors = null;
43+
for ($i = 0; $i < 3 && $errors === null; $i++) {
44+
$log = json_decode($dlr->waitForDebuggerDataAndReplay()["body"], true)[0];
45+
if (isset($log["debugger"]["snapshot"]["evaluationErrors"])) {
46+
$errors = $log["debugger"]["snapshot"]["evaluationErrors"];
47+
}
48+
}
49+
var_dump($errors);
50+
51+
?>
52+
--CLEAN--
53+
<?php
54+
require __DIR__ . "/live_debugger.inc";
55+
reset_request_replayer();
56+
?>
57+
--EXPECTF--
58+
array(1) {
59+
[0]=>
60+
array(2) {
61+
["expr"]=>
62+
string(%d) "%s"
63+
["message"]=>
64+
string(%d) "%s"
65+
}
66+
}

0 commit comments

Comments
 (0)