Skip to content

feat(backend): propagate correlationId to background jobs#1181

Merged
Devsol-01 merged 2 commits into
Devsol-01:mainfrom
Musab1258:feat/1142-correlation-id-background-jobs
Jul 1, 2026
Merged

feat(backend): propagate correlationId to background jobs#1181
Devsol-01 merged 2 commits into
Devsol-01:mainfrom
Musab1258:feat/1142-correlation-id-background-jobs

Conversation

@Musab1258

Copy link
Copy Markdown
Contributor

Linked issue

Closes #1142

What changed and why

This PR ensures that correlationId propagates from the initial HTTP request all the way down to background job processing, allowing logs and traces to reliably connect request-level activity to queued tasks. It achieves this by pulling the correlationId via a controller decorator, passing it through the service layers, appending it to the 7 defined job data payloads in job-queue.service.ts, and automatically extracting it in the processors to prepend to all execution, failure, and completion logs.

Test plan

  • Existing tests pass (pnpm test)
  • New tests added for new behaviour
  • Typechecks pass (pnpm -r typecheck)
  • Manually tested against testnet / mainnet (describe what you tested)

Test Notes:

  • Added 7 new test cases in job-queue.service.spec.ts verifying correlationId is included in the data passed to queue.add().
  • Added 3 new tests in report.processor.spec.ts to ensure processors function correctly, prepend [correlationId] to debug log messages, and gracefully omit the prefix when the ID is absent.

Breaking changes

None

Notes for reviewers

All 7 job data interfaces (NotificationJobData, EmailJobData, BlockchainJobData, ReportJobData, DisputeEvidenceJobData, AvatarJobData, AuditLogExportJobData) were updated to support the optional correlationId property. Since the parameter is optional in the queue insertion methods, this safely handles any legacy code paths that might queue jobs without a request context.

Adds optional correlationId to all 7 job data interfaces in job-queue.service.ts, embedding it into the queue payload. Updates all job processors to extract correlationId and prepend it to log messages for distributed tracing. Incorporates the @CorrelationId() decorator across multiple controllers (reports, audit logs, disputes, users) to pass the context down to the queue. Includes tests verifying data propagation and log message prefixing.

Closes Devsol-01#114
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
nestera Skipped Skipped Jun 30, 2026 9:30am

@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@Musab1258 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

@Devsol-01 Devsol-01 merged commit 62fe8c3 into Devsol-01:main Jul 1, 2026
3 of 6 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.

[Backend] -- Add Consistent CorrelationId Propagation Into Background Jobs

2 participants