Skip to content

task: propagate correlation and stream ids in lifecycle logs#318

Open
greatKhalifa-code wants to merge 2 commits into
Streampay-Org:mainfrom
greatKhalifa-code:task/correlated-lifecycle-logging
Open

task: propagate correlation and stream ids in lifecycle logs#318
greatKhalifa-code wants to merge 2 commits into
Streampay-Org:mainfrom
greatKhalifa-code:task/correlated-lifecycle-logging

Conversation

@greatKhalifa-code
Copy link
Copy Markdown

Implementation Details
This PR builds the necessary observability infrastructure from scratch and integrates it:

  • New Infrastructure:

    • app/lib/logger.ts: Implemented a centralized, structured JSON logger.
    • app/lib/correlation-middleware.ts: Implemented correlation ID propagation using AsyncLocalStorage to maintain request context.
    • app/lib/privacy.ts: Implemented a utility to automatically redact sensitive information (secrets, tokens, PII) from log objects.
  • Integration:

    • Updated all five stream lifecycle API routes (app/api/streams/[id]/) to emit structured info and warn logs.
    • Each log entry now includes the correlation_id, stream_id, action type, and status.
    • Logged stream data is passed through the redact() utility before being sent to the logger.

Key Features

  • Backend Observability: Every lifecycle transition is now traceable with correlated logs.
  • Security: Automated redaction ensures PII and secrets are not leaked to log aggregators.
  • Consistency: Structured JSON logging ensures logs are machine-readable for monitoring and alerting.

Testing & Coverage

  • Added unit tests for the new logging, privacy, and correlation infrastructure in app/lib/*.test.ts.

closes #242

- Add logger, privacy (redaction), and correlation-middleware utilities
- Integrate structured, correlated, and redacted logging into stream lifecycle routes (start, pause, stop, settle, withdraw)
- Add unit tests for new logging infrastructure
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@greatKhalifa-code 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

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.

Propagate correlation_id and stream_id through all stream lifecycle route logs

2 participants