Skip to content

feat: query logging, retention policy, health checks, and service unit tests#160

Merged
Kevin737866 merged 5 commits into
Kevin737866:mainfrom
Mozez155:feature/query-logging-retention-health-tests
Jun 1, 2026
Merged

feat: query logging, retention policy, health checks, and service unit tests#160
Kevin737866 merged 5 commits into
Kevin737866:mainfrom
Mozez155:feature/query-logging-retention-health-tests

Conversation

@Mozez155
Copy link
Copy Markdown
Contributor

Summary

  • Implement logging for all database queries #130 — Add per-query debug logging (sql, paramCount, durationMs, rowCount) and error logging to DatabaseConnection.query() so every query is traceable at debug level.
  • Implement data retention policy #140 — Fix data retention service: batch-archive in 1000-row loops and delete only the archived IDs (preventing data loss); add cleanup for network_metrics, asset_metrics, and account_metrics using all seven RETENTION_PERIODS constants.
  • Add more comprehensive health checks #129 — Add GET /health/live (liveness probe, always 200) and GET /health/ready (readiness probe, 503 when Redis or PostgreSQL is unreachable) alongside the existing /health endpoint.
  • Add unit tests for all services #141 — Add unit tests for StellarService (SDK method chains, streaming, error handling), IndexerService (lifecycle, status shape, circuit-breaker reset), and RetentionService (compliance report, retention status, start/stop, all seven table categories).

Closes #130
Closes #140
Closes #129
Closes #141

Test plan

  • GET /health/live returns 200 { status: "alive" } while server is running
  • GET /health/ready returns 503 when Redis or Postgres is down, 200 when both are up
  • Debug logs appear for every DB query when LOG_LEVEL=debug
  • Retention service archives in batches and only deletes rows that were archived
  • pnpm test in packages/indexer — all three new test files pass

🤖 Generated with Claude Code

Mozez155 and others added 5 commits May 31, 2026 15:53
Log every database query at debug level (sql, paramCount, durationMs,
rowCount) and log failures at error level so timing data is available
for debugging without waiting for the slow-query threshold.

closes Kevin737866#130

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix archiveAndDelete to loop in 1000-record batches and delete only
the archived IDs instead of all rows at once, preventing data loss when
more than 1000 rows need archiving. Add deleteOldMetrics for tables
without an archive (network_metrics, asset_metrics, account_metrics).
Wire up all seven RETENTION_PERIODS entries in applyRetention.

closes Kevin737866#140

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add GET /health/live (always 200 while process is up) and
GET /health/ready (503 when either Redis or PostgreSQL is unreachable)
for Kubernetes-style probe support. The existing /health endpoint is
unchanged and continues to return the full HealthCheckResult.

closes Kevin737866#129

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…entionService

StellarService – verify Horizon SDK method chains (ledgers, transactions,
operations, accounts, streaming) and testConnection error handling.
IndexerService – verify constructor, getStatus shape, stop idempotency,
and resetCircuitBreaker using fully mocked dependencies.
RetentionService – verify RETENTION_PERIODS, compliance report,
retention status parsing, lifecycle (start/stop), and that all seven
table categories are processed during applyRetention.

closes Kevin737866#141

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Kevin737866 Kevin737866 merged commit e47aaee into Kevin737866:main Jun 1, 2026
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 unit tests for all services Implement data retention policy Implement logging for all database queries Add more comprehensive health checks

2 participants