Skip to content

AI-3307: skip successful /health lines in the access log - #2035

Merged
kanat merged 2 commits into
mainfrom
ai-3307-skip-health-log
Nov 16, 2026
Merged

kanat merged 2 commits into
mainfrom
ai-3307-skip-health-log

Conversation

@kanat

@kanat kanat commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What

withRequestLog no longer writes served a request for GET /health answered below 400 with no recorded error. Same rule as chat's shouldWriteAccessLog. Staging: 17,393 of 18,183 access lines in 24 h were /health.

GET /health  -> 200, no error   no line
GET /health  -> >=400 or error  line (503 at error level)
anything else                   line, as before

Matched by route (routeLabel == /health), not by path text. Activity record, metrics, spans and the panic line are untouched. The router has no /ready route, and HEAD/POST /health answer 405, so they log.

Tests (LogAppSuite)

Change Test
healthy /health is quiet TestASuccessfulHealthProbeWritesNoAccessLine
failing /health (closed store, 503) logs TestAFailingHealthProbeWritesItsAccessLine
200 with a recorded error logs TestAHealthProbeWithARecordedErrorWritesItsAccessLine
400 logs TestAHealthProbeAnsweredWithAClientErrorWritesItsAccessLine
/healthz, /v1/agents/health, /health/live, /ready, POST /health log TestOnlyAnswersFromTheHealthRouteAreQuiet
control: another 200 logs TestARequestThatIsNoHealthProbeIsLoggedWhenItSucceeds

Two tests that read a /health line now read /v1/account (logapp_test.go auth type, cmd/router/chatinbound_test.go release).

README's request-log section says successful /health is not logged. Mutation log: 7 mutants of the rule, all killed.

Unverified

  • Full integration run (CI).
  • An app's own successful /health is still counted in the activity record, under other (activity.Recorder.Record, internal/activity/activity.go:153). activity_unit_test.go:65 exempts /health only from the area check. Its test is TestASuccessfulHealthProbeIsStillCounted.

🤖 Generated with Claude Code

The load balancer and kubelet probe /health every few seconds, and 96% of
staging's access lines were those probes. Like chat, a probe answered below 400
with no recorded error is not logged; a failing one still is.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 6ba4be5 merged onto accelerate 1392d47c2c (the base has not moved). Touched suites pass. 15 mutants: 12 killed, 2 equivalent (path text instead of route; recorder.code instead of status()), 1 survived (R1.1).

CI at the time of reading: integration (internal/api) failed in TestAdmissionSuite/TestTwoRoutersStopAnLLMSessionTogether (admission_test.go:428, "An error is expected but got nil"). It is a cross-router credit test timed by sleeps, with no log line or /health in it, and it passed 3 of 3 runs locally on this head. Not counted against this PR.

Checked and sound:

  • A /health panic writes the same single a request panicked line on base and head. Neither writes an access line, because the code after next.ServeHTTP does not run.
  • HEAD /health (405), /health/ and /Health (404) still log.
  • The #2027 tests moved to /v1/account still fail under their mutants: the query fallback in auth.DeclaredAuthType, any type accepted from the query, and Release: release in cmd/router/main.go. The stream_auth_type cap is pinned by the header test, which this PR does not change.
  • An unwritten /health counts as the 200 net/http sends and stays quiet, while chat's rule logs status 0. That case cannot happen here: getHealth always writes 200 or 503.

Verdict: request changes, for R1.1 (a Should fix: one test plus a fix to the PR body).

}()
next.ServeHTTP(recorder, r)
s.recordActivity(routes, r, recorder, started)
if answeredHealthy(routes, r, recorder.status(), failure) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Should fix] R1.1 No test pins that a quiet /health is still counted in the activity record. Moving this return above s.recordActivity (line 1038) passes every touched suite (LogAppSuite, LogAppProxiedSuite, LogHandlerSuite, ActivitySuite). The move is not a no-op: activity.Recorder.Record (internal/activity/activity.go:153) skips only an empty AppID, and an app calling /health with its own credential is counted under area other. The PR body's note "changes nothing testable: /health is outside activity (activity_unit_test.go:65)" is wrong: staffOrPublic only exempts /health from the "every operation has an area" check.

Fix: add this to ActivitySuite (internal/api/activity_test.go). I checked it in a scratch copy: it passes on this head and fails with the return moved above recordActivity. Then correct the line in the PR body.

// Defect: the quiet health probe skipped the activity record along with its access line.
func (s *ActivitySuite) TestASuccessfulHealthProbeIsStillCounted() {
	s.Require().Equal(http.StatusOK, s.serverClient.with(clientHeader, store.AuditSourceCLI).
		do(http.MethodGet, "/health", nil, nil))

	s.countedOnce(activity.AreaOther, store.AuditSourceCLI)
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8058395: TestASuccessfulHealthProbeIsStillCounted (ActivitySuite). Mutation M9 (quiet return moved above s.recordActivity) fails it with "nothing was counted under other from cli"; restored, it passes. PR body line 31 corrected to match.

The access line skips a successful /health, but recordActivity must still
count it. Nothing pinned that order, so moving the quiet return above
recordActivity passed every suite.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@kanat
kanat marked this pull request as ready for review November 16, 2026 16:50
@kanat
kanat changed the base branch from accelerate to main November 16, 2026 17:01
@kanat

kanat commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

GO at 80583950f (orchestrator).

  • Round 1 (review above): NO-GO on R1.1. A successful /health was still counted in the activity record, but no test pinned it.
  • Fix 80583950f: ActivitySuite.TestASuccessfulHealthProbeIsStillCounted, which fails under mutant M9 (the quiet return moved above recordActivity). The wrong line in the PR body is corrected.
  • The delta touches only tests (delta-kind.sh: trivial), so the orchestrator checked it directly instead of running a second review.
  • Base retargeted from accelerate to main after Accelerate #2030. The PR still holds only its own 2 commits and merges cleanly. Merging once CI on main is green.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The request logger now omits /health access logs when the response status is below 400 and no request error was recorded. Other health responses and successful non-health requests remain logged. The health route uses a shared path constant. Tests cover logging conditions, request activity counting, and related request-path updates. The README documents the logging rules.

Merge Risk: Low · up to 80583

Successful health probes no longer write access-log lines, and failing probes still do. The logging rule looks sound. One test gap remains: no test would fail if the matching switched from route label to path text. Adding such a test is a small, low-risk follow-up.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

The configuration directory could not be loaded. This review used the available YAML and UI settings; directory instructions and checks were not evaluated.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 17a2b91 and 8058395.

Files selected for processing: 5

  • acceleration/README.md
  • acceleration/cmd/router/chatinbound_test.go
  • acceleration/internal/api/activity_test.go
  • acceleration/internal/api/logapp_test.go
  • acceleration/internal/api/server.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

// like the health check, or a method it does not serve, went unlogged.
func (s *LogAppSuite) TestOnlyAnswersFromTheHealthRouteAreQuiet() {
for _, path := range []string{"/healthz", "/v1/agents/health", "/health/live", "/ready"} {
line := s.servedAt(path, func(http.ResponseWriter, *http.Request) {})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial · Maintainability & Code Quality · Quick win

Test route identity separately from the request path.

Every supplied case uses the same literal route pattern and request path. Replacing routeLabel(routes, r) with r.URL.Path would still pass these tests.

Add a case that registers /{name}, requests /health, and requires an access line with operation_type=/{name}. This request must log because its route pattern is not healthPath.

As per path instructions, flag “tests that would still pass on a broken implementation.” The PR objective requires route-label matching, not path-text matching.

Source: Path instructions

@kanat
kanat merged commit d4b02b8 into main Nov 16, 2026
58 checks passed
@kanat
kanat deleted the ai-3307-skip-health-log branch November 16, 2026 17:21
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