Skip to content

log the client-facing status on completed requests - #253

Merged
thushan merged 6 commits into
mainfrom
fix/log-backend-status
Oct 27, 2026
Merged

thushan merged 6 commits into
mainfrom
fix/log-backend-status

Conversation

@thushan

@thushan thushan commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Review as a unit or squash: the head commit a627411 is prefixed WIP: by mistake. It passes make ready.

Summary

The per-request Request completed line did not say what status the client got, so a backend returning 502 or 503 read the same as a success.

It now carries http_status on every proxy route (/olla/proxy/, provider routes and the Anthropic route; passthrough and translation; streaming included). A backend 5xx is logged at WARN; a 4xx stays at INFO. The status comes from responseStartedWriter (retry.go), which also records the implicit 200 on flush. Failed requests write the error response before logging so they carry their status. Olla's own rejections are unchanged and still go through the sampled Request rejected line; a rejected request no longer also writes an INFO Request received line.

Type of change

  • Bug fix
  • Documentation

How was this tested?

New tests:

  • TestResponseStartedWriter_Status, TestResponseStartedWriter_FlushStatus
  • TestRequestCompleted_CarriesBackendStatus (in handler_proxy_completed_status_test.go)
  • TestRequestRejected_NotDuplicatedByCompletion
  • TestLogRequestResult_FailureCarriesHTTPStatus
  • TestRequestFailed_CarriesWrittenErrorStatus

Tested together with the other October follow-up branches on a local integration branch at 0c25e0a:

  • make ready and make test-race pass at 0c25e0a
  • /olla-validate --quick: 42 pass, 0 fail (warnings and skips are nightly-only items)
  • tei-routing validation area: Section A 12/12, Section B B1 to B6 pass
  • /test-sticky-sessions: no new failures (the 7 provider-route 404s are the known shared-mock-URL limitation)
  • /claude-code-e2e against real Ollama: Tier A 16/0 on both the passthrough and translation legs, same as main
  • curl checks per feature against real Ollama and ollamock; log scan shows no panics, races or per-request WARN floods

Checklist

  • make ready passes at a627411
  • Tests added or updated for the change
  • Documentation updated: docs/content/configuration/practices/monitoring.md, v0.0.30 release note
  • No new dependencies added

Summary by CodeRabbit

  • Logging
    • Proxy completion logs now include the HTTP status returned to the client.
    • Backend errors are logged by severity: 5xx responses at warning level and 4xx responses at info level.
    • Requests rejected by Olla are logged once as sampled rejection events, without a separate request-received entry.
  • Documentation
    • Updated monitoring guidance to explain proxy status reporting and rejection logging.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

Proxy completion logs now include the client-visible HTTP status. Backend 5xx completions log at WARN, while other completions log at INFO. Olla refusals retain sampled rejection logging and no longer produce a separate INFO received line.

Changes

Proxy status logging

Layer / File(s) Summary
Track committed response status
internal/adapter/proxy/core/retry.go, internal/adapter/proxy/core/retry_safety_test.go
ResponseStartedWriter records explicit and inferred response statuses. Tests cover response writes, interim statuses, and supported or unsupported flushes.
Capture and log proxy response status
internal/app/handlers/handler_proxy.go, internal/app/handlers/handler_translation.go, internal/app/handlers/handler_proxy_completed_status_test.go, docs/content/about/release-notes.md, docs/content/configuration/practices/monitoring.md
Proxy handlers capture the tracked status before logging results. Completion logs include known http_status values and use WARN for backend 5xx responses. Tests cover route and engine combinations, refusals, and connection failures. The monitoring guide and release notes describe the logging behaviour.

Priority: Not assessed

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ProxyHandler
  participant Backend
  participant ResponseStartedWriter
  participant RequestLogger
  ProxyHandler->>Backend: Send proxy request
  Backend->>ResponseStartedWriter: Write response status and body
  ResponseStartedWriter->>Client: Write client response
  ProxyHandler->>ResponseStartedWriter: Read Status()
  ProxyHandler->>RequestLogger: Log result with http_status
Loading

Possibly related PRs

  • thushan/olla#237: Defines sampled Request rejected logging, which this change retains while avoiding duplicate received or completion logs.
  • thushan/olla#236: Defines a capability refusal response and its single rejection warning; this change logs the status written to the client while retaining that rejection path.
Merge Risk: Minimal · up to 29d87

The proxy logging change is mergeable after normal checks; no blocking issue was identified.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thushan
thushan merged commit 116477f into main Oct 27, 2026
7 of 8 checks passed
@thushan
thushan deleted the fix/log-backend-status branch October 27, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant