845 backend background indexer worker logs carry no correlation - #1173
Open
jotel-dev wants to merge 6 commits into
Open
Conversation
…epo and CI workflow
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.
Description
Background Soroban event worker poll cycles and admin replays previously ran outside any
requestContext, leaving worker log lines (including per-event error logs) without a shared correlation ID (requestId).This PR wraps every worker poll cycle and admin replay batch in
requestContext.run({ requestId: ... }, ...)viaAsyncLocalStorage. All logs emitted within a cycle now share a unifiedrequestId, and the correlation ID is returned in the response of the admin replay endpoint (POST /v1/admin/indexer/replay).Type of Change
Related Issues
Closes #845
Changes Made
backend/src/workers/soroban-event-worker.ts:poll()cycles andtriggerPoll()inrequestContext.run({ requestId }, ...).fetchAndProcessEvents()to guarantee all RPC calls, event processing steps, and error logs carry therequestId.backend/src/services/indexerService.ts:replayFromLedger()to accept an optionalcustomRequestId, bind execution insiderequestContext, passrequestIdtotriggerPoll(), and return therequestId.backend/src/routes/v1/admin.routes.ts:POST /v1/admin/indexer/replayendpoint to return{ ok: true, replayingFrom: ledger, requestId: "..." }.Logging & Observabilitysections todocs/ARCHITECTURE.mdandbackend/README.md.backend/tests/worker-correlation-id.test.tsto test correlation ID binding across worker poll cycles and replay requests.Testing
Test Coverage
Test Steps
npm test(all 51 test suites / 355 tests pass).POST /v1/admin/indexer/replay?from_ledger=<ledger>and verify the HTTP response contains therequestIdfield.requestId.Breaking Changes
None.
Checklist
closes #845