P1: Structured JSON logging with request correlation ids (#172)#190
Open
dkijania wants to merge 1 commit into
Open
P1: Structured JSON logging with request correlation ids (#172)#190dkijania wants to merge 1 commit into
dkijania wants to merge 1 commit into
Conversation
Logging used `console.info/error` and an `inspect(..., {colors:true})` error
dump — TTY-oriented, not aggregation-friendly — with no request ids, and was
entangled with the Jaeger toggle.
- Add a pino-based structured logger (`logger.ts`): JSON lines, ISO timestamps,
level from `LOG_LEVEL` (invalid values fall back to `info` instead of
throwing), independent of tracing.
- Add a `useRequestLogging` plugin that assigns each request a correlation id
(honouring an inbound `X-Request-Id`) and emits one structured access line per
request with method, path, status, and duration. Probe endpoints
(`/healthcheck`, `/readiness`) are skipped to avoid orchestrator noise.
- GraphQL execution errors now log as structured JSON tagged with the same
`requestId`; `console.*` in the entry point replaced with the logger.
Unit tests cover level parsing/fallback and prove (through Yoga) the access
line shape, X-Request-Id correlation, and probe-path suppression.
Closes #172.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSuak9smCHbp4N17xjjLF6
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.
What & why
Part of the production-readiness epic (#163). Closes #172.
Logging used
console.info/errorand aninspect(..., {colors:true})error dump — TTY-oriented, not aggregation-friendly — with no request ids, and was entangled with the Jaeger toggle.Changes
logger.ts— a pino structured logger: JSON lines, ISO timestamps, level fromLOG_LEVEL(invalid values fall back toinfoinstead of throwing at startup), independent of tracing.useRequestLoggingplugin — assigns each request a correlation id (honouring an inboundX-Request-Id) and emits one structured access line per request withmethod,path,status,durationMs. Probe endpoints (/healthcheck,/readiness) are skipped to avoid orchestrator noise.requestId.console.*in the entry point replaced with the logger.New dependency:
pino.Testing
npm run build— cleannpm run test:unit— all pass; new tests cover level parsing/fallback and prove (through Yoga) the access-line shape,X-Request-Idcorrelation, and probe-path suppressionnpm run lint/npx prettier --debug-check .— clean🤖 Generated with Claude Code