Repository navigation
feat(observability): add structured request logging, request IDs and latency metrics - #1765
Merged
1nonlypiece merged 2 commits intoOct 24, 2026
Conversation
…e conflicts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #1700
Summary of Changes
Adds structured JSON request logging, request ID propagation, database latency tracking, and
Server-Timingheaders to the deployed API:apilib/log.mjs:LOG_LEVEL, and redaction for authorization, cookies, and secret/signedXdr fields.x-request-idheader (validates format and <= 64 chars) or generates a UUID, attaches child logger toreq.log, setsx-request-idheader on responses.finishwith method, route pattern (/vaults/:idinstead of raw URL to avoid cardinality and PII leaks), status, total latency, and store kind. Logs 5xx as error, 4xx as warn, 2xx/3xx as info.wrapPoolForTimingwraps pool and client queries to track cumulative DB duration per request and logs slow queries taking longer thanSLOW_QUERY_MS(default 500ms) with statement fingerprints omitting parameter values.Server-Timingheader emitted on responses (db;dur=..., total;dur=...).api/index.mjs:requestIdMiddleware().{ err: e }usingreq.log.error()and return{ error: 'Internal error', requestId }on 500 errors.apilib/store.mjs:wrapPoolForTiming..env.example:LOG_LEVELandSLOW_QUERY_MS.apilib/__tests__/log.test.mjs: Unit tests for request ID validation, access logs, pino capture redaction, fingerprinting, and slow query logging with a stubbed pool.api/__tests__/observability.test.mjs: HTTP-level integration tests for request ID echoing/replacement,Server-Timingheader, and 500 error correlation ID.