Open
Conversation
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First PR in Stack B (server observability). Builds on Stack A's
taskIdpropagation (#389).
Adds a Hono middleware that emits one structured JSON log line per HTTP
request, capturing only metadata:
{level, msg, method, route, status, duration_ms, taskId?}. PullstaskIdfrom thex-pilo-task-idresponseheader set by the SSE/WS routes in A1, so log lines correlate with the
task they served.
Data sensitivity (enforced by tests)
The middleware never logs:
task,data,guardrails, credentials)Sentinel tests assert that a sentinel string placed in the URL query, body,
Authorizationheader, orCookieheader never appears in any log line.The matched-route pattern (e.g.
/users/:id) is logged instead of theconcrete path (
/users/abc123).Changes
packages/server/src/middleware/requestLog.ts- new middlewarepackages/server/src/index.ts- register middleware after Sentry + CORS,before routes
packages/server/test/middleware/requestLog.test.ts- 11 tests coveringlog shape, sensitive-data exclusions, taskId propagation, status codes,
and structured-line invariant
Sample log line
{"level":"info","msg":"request","method":"POST","route":"/pilo/run","status":200,"duration_ms":12,"taskId":"3f29...e0d4"}For SSE responses,
duration_msis the time until the handler returns thestreaming Response (typically a few ms), not the full task duration.
Per-task duration metrics are Stack C's territory.
Test plan
pnpm --filter pilo-server run test(94 passing: 83 prior + 11 new)pnpm --filter pilo-core run test(still green)pnpm run typecheckgreenpnpm run format:checkgreenNotes
mainlayer of sentinel coverage for the middleware itself