Skip to content

Add structured JSON access logs for /api/health - #973

Merged
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
DANTE-1903:feature/health-access-log
Jul 28, 2026
Merged

Add structured JSON access logs for /api/health#973
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
DANTE-1903:feature/health-access-log

Conversation

@DANTE-1903

Copy link
Copy Markdown

Summary

Add structured JSON access logs for the /api/health endpoint with fields: req-id, latency, status, size.

Changes

  • src/middleware/accessLog.ts: Added createHealthAccessLogMiddleware that logs structured JSON with requestId, latencyMs, status, and responseBytes fields
  • src/routes/health.ts: Wired the healthAccessLog middleware into the health router via router.use
  • src/middleware/accessLog.test.ts: Added 6 focused tests covering:
    • Structured log output with correct fields (req-id, latency, status, size)
    • Warn level logging for 4xx responses
    • Error level logging for 5xx responses
    • x-request-id header set on response
    • UUID generation when no request ID is provided
    • Request ID extraction from x-request-id header

Testing

PASS src/middleware/accessLog.test.ts (0.928 s)
Tests: 10 passed (4 existing + 6 new)

Closes #928

- Add createHealthAccessLogMiddleware to src/middleware/accessLog.ts
  that logs req-id, latency, status, and response size
- Wire healthAccessLog into src/routes/health.ts via router.use
- Add 6 focused unit tests covering: structured log shape, 4xx/5xx
  status levels, x-request-id header, UUID fallback, header extraction

Closes CalloraOrg#928
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@DANTE-1903 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit 73450e2 into CalloraOrg:main Jul 28, 2026
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

LGTM — nicely done, thanks for the contribution 🙌

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.

Add structured JSON access logs for /api/health [b#063]

2 participants