Skip to content

Commit f09d4f8

Browse files
committed
More stability?
1 parent 8adef10 commit f09d4f8

15 files changed

Lines changed: 109 additions & 154 deletions

tests/debugger/test_debugger_exception_replay.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ def __scrub(
356356
"_dd.appsec.fp.session",
357357
"_dd.svc_src",
358358
"_dd.tags.process", # varies by PHP SAPI (apache vs fpm)
359+
"_dd.p.dm", # trace sampling decision, varies by tracer version
360+
"_dd.p.ksr", # keep sample rate, not present in all versions
359361
}:
360362
keys_to_remove.append(meta_key)
361363
elif meta_key.endswith(("id", "hash", "version")) or meta_key in {
@@ -367,7 +369,10 @@ def __scrub(
367369
}:
368370
span_meta[meta_key] = "<scrubbed>"
369371
elif meta_key == "error.stack":
370-
span_meta[meta_key] = meta_value[:128] + "<scrubbed>"
372+
stack = meta_value[:128]
373+
if self.get_tracer()["language"] == "php":
374+
stack = re.sub(r"\.php\(\d+\)", ".php(<scrubbed>)", stack)
375+
span_meta[meta_key] = stack + "<scrubbed>"
371376
elif type(meta_value) in (float, int):
372377
keys_to_remove.append(meta_key)
373378

tests/debugger/test_debugger_inproduct_enablement.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import time
99

1010
TIMEOUT = 5
11+
DEFAULT_ENVVARS = {
12+
"DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS": "0.2",
13+
}
1114

1215

1316
@features.debugger_inproduct_enablement

tests/debugger/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,11 @@ def send_rc_probes(self, *, reset: bool = True) -> None:
308308
remote_config.send_debugger_command(probes=self.probe_definitions, version=BaseDebuggerTest._rc_version)
309309
)
310310

311-
# PHP tracer requires a request to /debugger/* to start logging the probe information.
312-
# Two calls ensure the sidecar has had time to poll the new RC (poll interval: 100ms).
311+
# PHP tracer requires requests to /debugger/* to process RC and resolve probe hooks.
312+
# Pass probe IDs so the PHP endpoint polls until they appear in the loaded RC state.
313313
if context.library == "php":
314-
weblog.get("/debugger/init")
315-
weblog.get("/debugger/init")
314+
probe_ids = ",".join(p["id"] for p in self.probe_definitions if "id" in p)
315+
weblog.get(f"/debugger/init?probes={probe_ids}")
316316

317317
def send_rc_apm_tracing(
318318
self,
@@ -389,11 +389,11 @@ def send_rc_apm_tracing_and_probes(
389389
)
390390
)
391391

392-
# PHP tracer requires a request to /debugger/* to process RC before the test request.
393-
# Two calls ensure the sidecar has had time to poll the new RC (poll interval: 100ms).
392+
# PHP tracer requires requests to /debugger/* to process RC before the test request.
393+
# Pass probe IDs so the PHP endpoint polls until they appear in the loaded RC state.
394394
if context.library == "php":
395-
weblog.get("/debugger/init")
396-
weblog.get("/debugger/init")
395+
probe_ids = ",".join(p["id"] for p in self.probe_definitions if "id" in p)
396+
weblog.get(f"/debugger/init?probes={probe_ids}")
397397

398398
def send_rc_symdb(self, *, reset: bool = True) -> None:
399399
BaseDebuggerTest._rc_version += 1

tests/debugger/utils/approvals/php/1.18.0/exception_replay_async_spans_expected.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
"_dd.debug.error.1.snapshot_id": "<scrubbed>",
88
"_dd.debug.error.exception_hash": "<scrubbed>",
99
"_dd.debug.error.exception_id": "<scrubbed>",
10-
"_dd.p.dm": "-1",
11-
"_dd.p.ksr": "1",
1210
"_dd.p.tid": "<scrubbed>",
1311
"env": "system-tests",
1412
"error.debug_info_captured": "true",
1513
"error.message": "Caught RuntimeException (500): async exception in /var/www/html/debugger.php:206",
16-
"error.stack": "#0 /var/www/html/debugger.php(342): DebuggerController->exceptionReplayAsync()\n#1 {main}<scrubbed>",
14+
"error.stack": "#0 /var/www/html/debugger.php(<scrubbed>): DebuggerController->exceptionReplayAsync()\n#1 {main}<scrubbed>",
1715
"error.type": "RuntimeException",
1816
"http.method": "GET",
1917
"http.request.headers.user-agent": "<scrubbed>",
@@ -43,13 +41,11 @@
4341
"_dd.debug.error.1.snapshot_id": "<scrubbed>",
4442
"_dd.debug.error.exception_hash": "<scrubbed>",
4543
"_dd.debug.error.exception_id": "<scrubbed>",
46-
"_dd.p.dm": "-1",
47-
"_dd.p.ksr": "1",
4844
"_dd.p.tid": "<scrubbed>",
4945
"env": "system-tests",
5046
"error.debug_info_captured": "true",
5147
"error.message": "Caught RuntimeException (500): async exception in /var/www/html/debugger.php:206",
52-
"error.stack": "#0 /var/www/html/debugger.php(342): DebuggerController->exceptionReplayAsync()\n#1 {main}<scrubbed>",
48+
"error.stack": "#0 /var/www/html/debugger.php(<scrubbed>): DebuggerController->exceptionReplayAsync()\n#1 {main}<scrubbed>",
5349
"error.type": "RuntimeException",
5450
"http.method": "GET",
5551
"http.request.headers.user-agent": "<scrubbed>",

tests/debugger/utils/approvals/php/1.18.0/exception_replay_inner_spans_expected.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
"_dd.debug.error.1.snapshot_id": "<scrubbed>",
88
"_dd.debug.error.exception_hash": "<scrubbed>",
99
"_dd.debug.error.exception_id": "<scrubbed>",
10-
"_dd.p.dm": "-1",
11-
"_dd.p.ksr": "1",
1210
"_dd.p.tid": "<scrubbed>",
1311
"env": "system-tests",
1412
"error.debug_info_captured": "true",
1513
"error.message": "Caught RuntimeException (500): inner exception in /var/www/html/debugger.php:170",
16-
"error.stack": "#0 /var/www/html/debugger.php(332): DebuggerController->exceptionReplayInner()\n#1 {main}\n\nNext RuntimeException: outer exception<scrubbed>",
14+
"error.stack": "#0 /var/www/html/debugger.php(<scrubbed>): DebuggerController->exceptionReplayInner()\n#1 {main}\n\nNext RuntimeException: outer exception<scrubbed>",
1715
"error.type": "RuntimeException",
1816
"http.method": "GET",
1917
"http.request.headers.user-agent": "<scrubbed>",
@@ -43,13 +41,11 @@
4341
"_dd.debug.error.1.snapshot_id": "<scrubbed>",
4442
"_dd.debug.error.exception_hash": "<scrubbed>",
4543
"_dd.debug.error.exception_id": "<scrubbed>",
46-
"_dd.p.dm": "-1",
47-
"_dd.p.ksr": "1",
4844
"_dd.p.tid": "<scrubbed>",
4945
"env": "system-tests",
5046
"error.debug_info_captured": "true",
5147
"error.message": "Caught RuntimeException (500): inner exception in /var/www/html/debugger.php:170",
52-
"error.stack": "#0 /var/www/html/debugger.php(332): DebuggerController->exceptionReplayInner()\n#1 {main}\n\nNext RuntimeException: outer exception<scrubbed>",
48+
"error.stack": "#0 /var/www/html/debugger.php(<scrubbed>): DebuggerController->exceptionReplayInner()\n#1 {main}\n\nNext RuntimeException: outer exception<scrubbed>",
5349
"error.type": "RuntimeException",
5450
"http.method": "GET",
5551
"http.request.headers.user-agent": "<scrubbed>",

tests/debugger/utils/approvals/php/1.18.0/exception_replay_multiframe_spans_expected.json

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
"_dd.debug.error.4.snapshot_id": "<scrubbed>",
1111
"_dd.debug.error.exception_hash": "<scrubbed>",
1212
"_dd.debug.error.exception_id": "<scrubbed>",
13-
"_dd.p.dm": "-1",
14-
"_dd.p.ksr": "1",
1513
"_dd.p.tid": "<scrubbed>",
1614
"env": "system-tests",
1715
"error.debug_info_captured": "true",
1816
"error.message": "Caught RuntimeException (500): multiple stack frames exception in /var/www/html/debugger.php:197",
19-
"error.stack": "#0 /var/www/html/debugger.php(193): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(189): DebuggerContr<scrubbed>",
17+
"error.stack": "#0 /var/www/html/debugger.php(<scrubbed>): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(<scrubbed>): DebuggerContr<scrubbed>",
2018
"error.type": "RuntimeException",
2119
"http.method": "GET",
2220
"http.request.headers.user-agent": "<scrubbed>",
@@ -49,13 +47,11 @@
4947
"_dd.debug.error.4.snapshot_id": "<scrubbed>",
5048
"_dd.debug.error.exception_hash": "<scrubbed>",
5149
"_dd.debug.error.exception_id": "<scrubbed>",
52-
"_dd.p.dm": "-1",
53-
"_dd.p.ksr": "1",
5450
"_dd.p.tid": "<scrubbed>",
5551
"env": "system-tests",
5652
"error.debug_info_captured": "true",
5753
"error.message": "Caught RuntimeException (500): multiple stack frames exception in /var/www/html/debugger.php:197",
58-
"error.stack": "#0 /var/www/html/debugger.php(193): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(189): DebuggerContr<scrubbed>",
54+
"error.stack": "#0 /var/www/html/debugger.php(<scrubbed>): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(<scrubbed>): DebuggerContr<scrubbed>",
5955
"error.type": "RuntimeException",
6056
"http.method": "GET",
6157
"http.request.headers.user-agent": "<scrubbed>",
@@ -88,13 +84,11 @@
8884
"_dd.debug.error.4.snapshot_id": "<scrubbed>",
8985
"_dd.debug.error.exception_hash": "<scrubbed>",
9086
"_dd.debug.error.exception_id": "<scrubbed>",
91-
"_dd.p.dm": "-1",
92-
"_dd.p.ksr": "1",
9387
"_dd.p.tid": "<scrubbed>",
9488
"env": "system-tests",
9589
"error.debug_info_captured": "true",
9690
"error.message": "Caught RuntimeException (500): multiple stack frames exception in /var/www/html/debugger.php:197",
97-
"error.stack": "#0 /var/www/html/debugger.php(193): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(189): DebuggerContr<scrubbed>",
91+
"error.stack": "#0 /var/www/html/debugger.php(<scrubbed>): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(<scrubbed>): DebuggerContr<scrubbed>",
9892
"error.type": "RuntimeException",
9993
"http.method": "GET",
10094
"http.request.headers.user-agent": "<scrubbed>",
@@ -127,13 +121,11 @@
127121
"_dd.debug.error.4.snapshot_id": "<scrubbed>",
128122
"_dd.debug.error.exception_hash": "<scrubbed>",
129123
"_dd.debug.error.exception_id": "<scrubbed>",
130-
"_dd.p.dm": "-1",
131-
"_dd.p.ksr": "1",
132124
"_dd.p.tid": "<scrubbed>",
133125
"env": "system-tests",
134126
"error.debug_info_captured": "true",
135127
"error.message": "Caught RuntimeException (500): multiple stack frames exception in /var/www/html/debugger.php:197",
136-
"error.stack": "#0 /var/www/html/debugger.php(193): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(189): DebuggerContr<scrubbed>",
128+
"error.stack": "#0 /var/www/html/debugger.php(<scrubbed>): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(<scrubbed>): DebuggerContr<scrubbed>",
137129
"error.type": "RuntimeException",
138130
"http.method": "GET",
139131
"http.request.headers.user-agent": "<scrubbed>",
@@ -166,13 +158,11 @@
166158
"_dd.debug.error.4.snapshot_id": "<scrubbed>",
167159
"_dd.debug.error.exception_hash": "<scrubbed>",
168160
"_dd.debug.error.exception_id": "<scrubbed>",
169-
"_dd.p.dm": "-1",
170-
"_dd.p.ksr": "1",
171161
"_dd.p.tid": "<scrubbed>",
172162
"env": "system-tests",
173163
"error.debug_info_captured": "true",
174164
"error.message": "Caught RuntimeException (500): multiple stack frames exception in /var/www/html/debugger.php:197",
175-
"error.stack": "#0 /var/www/html/debugger.php(193): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(189): DebuggerContr<scrubbed>",
165+
"error.stack": "#0 /var/www/html/debugger.php(<scrubbed>): DebuggerController->exceptionReplayDeepC()\n#1 /var/www/html/debugger.php(<scrubbed>): DebuggerContr<scrubbed>",
176166
"error.type": "RuntimeException",
177167
"http.method": "GET",
178168
"http.request.headers.user-agent": "<scrubbed>",

0 commit comments

Comments
 (0)