Skip to content

Add structured observability foundation - #231

Merged
Obiajulu-gif merged 1 commit into
Chainmove:mainfrom
OkeyAmy:build-performance-optimization-program
Aug 30, 2026
Merged

Add structured observability foundation#231
Obiajulu-gif merged 1 commit into
Chainmove:mainfrom
OkeyAmy:build-performance-optimization-program

Conversation

@OkeyAmy

@OkeyAmy OkeyAmy commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Provide a safe, structured observability foundation so requests can be traced (correlation ids), high-level metrics are captured, and sensitive data is never leaked in logs.
  • Instrument core API and DB connection points to measure latency, error counts, and database query shapes for development without exposing secrets.

Description

  • Add a JSON-lines logger with recursive redaction of sensitive keys and bounded error serialization in lib/observability/logger.ts and a small LogContext shape.
  • Add an in-process low-cardinality metrics collector in lib/observability/metrics.ts and use it to count requests/errors and record latencies.
  • Instrument the shared route wrapper in lib/api/route-handler.ts to record request duration, increment http.requests/http.errors counters, record http.duration, and emit structured completion logs with X-Correlation-Id.
  • Instrument lib/dbConnect.ts to measure DB connect latency, record DB operation counters, log connection failures, and enable a development-only mongoose debug hook that emits query shapes (no values).
  • Add a safe readiness/liveness endpoint at GET /api/health that returns X-Correlation-Id and omits configuration/secrets (app/api/health/route.ts).
  • Add documentation for the observability conventions in docs/observability.md.
  • Add unit tests for redaction/error serialization (lib/observability/logger.test.ts) and the health endpoint readiness/secret-omission behavior (app/api/health/route.test.ts).

Testing

  • Ran unit tests: npm test -- --run lib/observability/logger.test.ts app/api/health/route.test.ts, results: 2 logger tests + 1 health test passed (3 tests total, all green).
  • Static checks: npm run typecheck completed without errors.
  • Linting: npm run lint completed without errors.
  • Git/diff validation: git diff --check returned clean.

Close #79 , #80 , #84

@OkeyAmy

OkeyAmy commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

#80

@OkeyAmy

OkeyAmy commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

#84

@Obiajulu-gif
Obiajulu-gif merged commit 1ea5593 into Chainmove:main Aug 30, 2026
1 of 2 checks passed
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.

[HARD][SUPPLY CHAIN] Add dependency governance, SBOM, secret scanning, and release security gates

2 participants