Skip to content

Commit d4ca060

Browse files
tylfinjpbempel
andauthored
test(debugger): budget limit for capture expressions (#7111)
Co-authored-by: jean-philippe bempel <jean-philippe.bempel@datadoghq.com>
1 parent edb74d8 commit d4ca060

5 files changed

Lines changed: 69 additions & 0 deletions

File tree

manifests/java.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,6 +3047,7 @@ manifest:
30473047
spring-boot-undertow: v1.38.0
30483048
spring-boot-wildfly: v1.38.0
30493049
uds-spring-boot: v1.38.0
3050+
tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_log_line_capture_expression_budgets: bug (DEBUG-5730)
30503051
tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_span_probe_expression_budgets: bug (DEBUG-3797)
30513052
tests/debugger/test_debugger_probe_snapshot.py::Test_Debugger_Line_Probe_Snaphots:
30523053
- weblog_declaration:

manifests/php.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ manifest:
577577
tests/debugger/test_debugger_pii.py::Test_Debugger_PII_Redaction::test_pii_redaction_method_full: v1.19.0
578578
tests/debugger/test_debugger_pii.py::Test_Debugger_PII_Redaction_Excluded_Identifiers: missing_feature (DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS config key not implemented; only REDACTED_IDENTIFIERS exists which adds names, not removes them from the built-in list)
579579
tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets: v1.13.0+4663b2fa7c20c6920f347d059b57dc2a419cb7f7
580+
tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_log_line_capture_expression_budgets: missing_feature
580581
tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_span_probe_expression_budgets: irrelevant
581582
tests/debugger/test_debugger_probe_snapshot.py::Test_Debugger_Line_Probe_Snaphots: missing_feature
582583
tests/debugger/test_debugger_probe_snapshot.py::Test_Debugger_Line_Probe_Snaphots::test_process_tags_snapshot: missing_feature (Not yet implemented)

manifests/python.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,7 @@ manifest:
12581258
- weblog_declaration:
12591259
"*": missing_feature
12601260
*flask: v2.11.0
1261+
tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_log_line_capture_expression_budgets: bug (DEBUG-5743)
12611262
tests/debugger/test_debugger_probe_budgets.py::Test_Debugger_Probe_Budgets::test_span_probe_expression_budgets: irrelevant (Python emits evaluation errors as span tags, not error snapshots to the debugger endpoint)
12621263
tests/debugger/test_debugger_probe_snapshot.py::Test_Debugger_Line_Probe_Snaphots:
12631264
- weblog_declaration:

tests/debugger/test_debugger_probe_budgets.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,41 @@ def test_log_line_budgets(self):
8989
f"Expected 1-20 snapshot with captures, got {snapshots_with_captures} in {self.total_request_time} seconds"
9090
)
9191

92+
def setup_log_line_capture_expression_budgets(self):
93+
self._setup(
94+
"probe_capture_expressions_budgets",
95+
"/debugger/budgets/150",
96+
lines=self.method_and_language_to_line_number("Budgets", self.get_tracer()["language"]),
97+
)
98+
99+
def test_log_line_capture_expression_budgets(self):
100+
self._assert()
101+
self._validate_snapshots()
102+
103+
snapshots_with_captures = 0
104+
for _id in self.probe_ids:
105+
for span in self.probe_snapshots[_id]:
106+
captures = span.get("debugger", {}).get("snapshot", {}).get("captures", None)
107+
if captures is None:
108+
continue
109+
110+
# Capture expressions live under captures.lines.{line}.captureExpressions for line probes.
111+
has_capture_expressions = any(
112+
isinstance(line_data, dict) and "captureExpressions" in line_data
113+
for line_data in captures.get("lines", {}).values()
114+
)
115+
if not has_capture_expressions:
116+
continue
117+
118+
snapshots_with_captures += 1
119+
120+
# Probe budgets aren't exact and can take time to be applied, so we allow a range of 1-20 snapshots with
121+
# capture expressions for 150 requests, matching the 1/s snapshot limit.
122+
assert 1 <= snapshots_with_captures <= 20, (
123+
f"Expected 1-20 snapshots with capture expressions, got {snapshots_with_captures} in "
124+
f"{self.total_request_time} seconds"
125+
)
126+
92127
def setup_span_probe_expression_budgets(self):
93128
self.initialize_weblog_remote_config()
94129

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[
2+
{
3+
"language": "",
4+
"type": "",
5+
"id": "",
6+
"version": 0,
7+
"where": {
8+
"typeName": null,
9+
"sourceFile": "ACTUAL_SOURCE_FILE",
10+
"lines": [
11+
"141"
12+
]
13+
},
14+
"captureSnapshot": false,
15+
"capture": {
16+
"maxReferenceDepth": 3
17+
},
18+
"captureExpressions": [
19+
{
20+
"name": "loops",
21+
"expr": {
22+
"dsl": "loops",
23+
"json": {"ref": "loops"}
24+
},
25+
"capture": {
26+
"maxReferenceDepth": 1
27+
}
28+
}
29+
]
30+
}
31+
]

0 commit comments

Comments
 (0)