feat: request timing middleware and /debug/timing page#204
Conversation
Add TimingMiddleware that measures per-request duration and stores results in a TimingBuffer. Slow requests (>500ms) are logged as WARNING. A new /debug/timing page displays the last 200 requests sorted by duration, with color-coded rows for slow/very-slow requests. Closes #203 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@claude review. Focus on critical issues: bugs, security vulnerabilities, logical errors, data loss risks, performance problems. Do NOT nitpick style, naming conventions, minor formatting, or subjective preferences — only flag issues that could break functionality or cause real harm in production. |
|
Claude finished @axisrow's task in 2m 5s —— View job Code Review: feat/request-timing-debug
Overall the implementation is clean and correct. No security vulnerabilities, data loss risks, or logic errors found. Two issues worth addressing and one minor observation: Issue 1: Unhandled exception leaves timing gap (
|
…tatic check
- Use try/finally so timing is always recorded even when call_next raises
(e.g. connection resets, streaming errors); status defaults to 500 in
error case
- Remove redundant `path.startswith("/static")` — is_public_path already
covers /static/ paths, keeping public-path logic in one place
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Observation: /debug/timing records itself — acknowledged. Under current usage (manually opened page) this is harmless noise in the circular buffer. If auto-refresh is ever added to this page, the self-recording entries should be excluded at that point. No change made now. |
|
@claude review. Focus on critical issues: bugs, security vulnerabilities, logical errors, data loss risks, performance problems. Do NOT nitpick style, naming conventions, minor formatting, or subjective preferences — only flag issues that could break functionality or cause real harm in production. |
|
Claude finished @axisrow's task in 1m 33s —— View job Code Review: feat/request-timing-debug
Both issues from the previous review have been addressed in commit Issue 1 (try/finally) — Fixed. Issue 2 (redundant static check) — Fixed. The One dead-code note (
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
TimingMiddlewarethat wraps every request and records duration viatime.monotonic()TimingBuffer(circular buffer, 200 entries) to store per-request timing records/debug/timingpage showing last 200 requests sorted by duration descending; rows >1000ms highlighted red, 500–999ms yellowWARNING: SLOW ...for requests exceeding 500msTest plan
python -m src.main serve/channels,/dashboard,/analytics)/debug/timing— verify table populates with correct method/path/status/ms/static/and/healthrequests are excluded from the bufferWARNING: SLOW ...appears in/debug/logsCloses #203
🤖 Generated with Claude Code