Skip to content

feat(indexer): add structured batch start/completion logs - #658

Merged
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
KingDavid9999:fixes-issue-#648
Jul 26, 2026
Merged

feat(indexer): add structured batch start/completion logs#658
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
KingDavid9999:fixes-issue-#648

Conversation

@KingDavid9999

Copy link
Copy Markdown
Contributor

Summary

  • Adds structured batch-level logging to processIndexerChainEvents in src/utils/indexer-event-processor.utils.ts, the shared function that processes an incoming batch of chain events (currently only called by processTradeEvents).
  • Emits an info-level log (indexer_batch_started) before processing starts, with from_ledger, to_ledger (min/max ledger across the batch), and batch_size (raw event count received, before dedup).
  • Emits a debug-level log (indexer_batch_completed) after processing finishes, with from_ledger, to_ledger, events_processed (unique event count after dedup), and duration_ms (measured with the same monotonic clock helper already used for per-event timing).
  • Both logs fire exactly once per batch call — the existing per-event log inside the processing loop is untouched, so per-ledger logging isn't duplicated.
  • Updated docs/indexer/EVENT_PROCESSING.md with a new section documenting the two log shapes and field meanings.

Note on batch_size semantics: this server only receives events: ChainEvent[] — it has no visibility into the ledger range the external polling worker actually requested (see PIPELINE_REFERENCE.md). So from_ledger/to_ledger/batch_size are derived from the ledgers present on the events in the batch, not from an externally-supplied range. Flagging this in case the intended semantics were "ledger count in the requested range" rather than "event count in this call" — happy to add explicit range params if so.

Testing

  • pnpm lint
  • pnpm build
  • pnpm exec prisma generate — no schema changes
  • pnpm test -- indexer-event-processor.utils.test.ts — 8/8 passing, including 4 new tests for batch-start fields, batch-completion fields, single-log-per-batch, and the no-ledger edge case
  • pnpm test -- indexer-pipeline.integration.test.ts — unaffected, 3/3 passing

Checklist

Closes #648

Add per-batch structured logging to processIndexerChainEvents so
operators can see indexer throughput and batch size without querying
the database.

- Emit an info-level "indexer_batch_started" log before processing,
  with from_ledger, to_ledger (min/max ledger across the batch), and
  batch_size (raw event count before dedup).
- Emit a debug-level "indexer_batch_completed" log after processing,
  with from_ledger, to_ledger, events_processed (unique count after
  dedup), and duration_ms (wall-clock time via the existing monotonic
  clock helper).
- Both logs fire exactly once per batch call, not per individual
  ledger/event; the existing per-event log is untouched.

Closes accesslayerorg#648
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

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

@Chucks1093
Chucks1093 merged commit f9d3baf into accesslayerorg:main Jul 26, 2026
1 check 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.

Add structured log for each indexer batch start and completion with ledger range and event count

2 participants