Skip to content

Commit 19f695e

Browse files
Reflexclaude
andcommitted
feat(loadtest): capture and report per-request errors
Match the TS loadtest's RequestResult by recording the exception message per request, and print a breakdown of the opaque network_error bucket so transport-level failures (timeouts, resets, pool exhaustion) are diagnosable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3d30178 commit 19f695e

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

loadtest/loadtest.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def build_client() -> AsyncRunloop:
4444
async def send_request(client: AsyncRunloop, index: int, run_id: str) -> dict[str, object]:
4545
start = time.perf_counter()
4646
status: int | None = None
47+
error: str | None = None
4748
try:
4849
await client.devboxes.create(
4950
blueprint_id="bp_nonexistent_loadtest_00000",
@@ -55,7 +56,13 @@ async def send_request(client: AsyncRunloop, index: int, run_id: str) -> dict[st
5556
status = 200
5657
except Exception as exc:
5758
status = getattr(exc, "status_code", None)
58-
return {"index": index, "latency_ms": (time.perf_counter() - start) * 1000, "status": status}
59+
error = str(exc) or type(exc).__name__
60+
return {
61+
"index": index,
62+
"latency_ms": (time.perf_counter() - start) * 1000,
63+
"status": status,
64+
"error": error,
65+
}
5966

6067

6168
def percentile(sorted_vals: list[float], p: float) -> float:
@@ -86,6 +93,18 @@ def print_metrics(results: list[dict[str, object]], wall_ms: float) -> None:
8693
for s, c in sorted(status_counts.items()):
8794
print(f" {s}: {c}")
8895

96+
# Break down the opaque "network_error" bucket by exception message so
97+
# transport-level failures (timeouts, resets, pool exhaustion) are diagnosable.
98+
error_counts: dict[str, int] = {}
99+
for r in results:
100+
if r["status"] is None and r["error"] is not None:
101+
msg = str(r["error"])
102+
error_counts[msg] = error_counts.get(msg, 0) + 1
103+
if error_counts:
104+
print("\nErrors (network_error breakdown):")
105+
for msg, c in sorted(error_counts.items(), key=lambda kv: kv[1], reverse=True):
106+
print(f" {c}x {msg}")
107+
89108

90109
async def main() -> None:
91110
fd_limit: int | None = None

0 commit comments

Comments
 (0)