Fix/metrics indexer improvements#456
Open
OxDev-max wants to merge 4 commits into
Open
Conversation
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.
Summary
closes #361
closes #362
closes #363
closes #364
The computeStatus method was computing lag as latestLedger - 0 whenever no ledger checkpoint existed in Redis (cache miss), producing a lag in the millions and triggering a false critical alert on every cold start. Fixed by tracking whether a checkpoint exists (hasCheckpoint) and short-circuiting to healthy when it doesn't — the indexer simply hasn't started tracking yet.
Added two new runtime gauges to DbMetricsService:
Both are included in the existing snapshot() response. Wired IndexerMonitorService into MetricsModule and added a new GET /metrics/indexer endpoint (auth-gated with x-internal-key) alongside the existing GET /metrics/db.
Added an end-to-end test suite that spins up a real NestJS application with SwapsController + SwapsService and a mocked SwapsRepository. Tests cover: paginated responses, empty results, pool/wallet filtering, default pagination, feeAmount and transactionHash field mapping, totalPages computation, and error propagation on repository failure.
Added an integration test suite that replaces the flat mock Prisma client with an in-memory store (Maps per table) that actually applies upsert semantics. Tests verify end-to-end data flow for all five event types — pool created, swap processed, fees collected, position minted, position burned — including ledger checkpoint advancement, idempotency, placeholder pool creation on out-of-order swaps, zero-liquidity position closure, and that a failed write never advances the ledger checkpoint prematurely.
Related issue
Type of change
Checklist