Skip to content

Improve /health endpoint to report dependency status #24

Description

@prodbycorne

Overview

The current /health endpoint returns a static { status: 'ok' }. It gives no insight into whether Redis is reachable, Horizon RPC is responsive, or price sources are functional — making it useless as a readiness probe or for on-call triage.

New Response Format

{
  "status": "degraded",
  "uptime_seconds": 3847,
  "checks": {
    "redis": { "status": "ok", "latency_ms": 2 },
    "horizon": { "status": "ok", "latency_ms": 89, "ledger": 52341200 },
    "coingecko": { "status": "ok", "circuit": "closed" },
    "coinmarketcap": { "status": "degraded", "circuit": "open", "reason": "rate_limited" },
    "stellar_dex": { "status": "ok", "circuit": "closed" }
  }
}

Status rules:

  • ok: all checks pass
  • degraded: at least one non-critical check failing (price source)
  • error: critical dependency (Redis) is unreachable

HTTP status codes:

  • ok → 200
  • degraded → 200 (load balancer keeps it in rotation)
  • error → 503

Implementation

  • Run all dependency checks in parallel with Promise.allSettled
  • Redis check: redis.ping() with 2s timeout
  • Horizon check: fetch / endpoint (returns ledger info) with 5s timeout
  • Price source check: report circuit breaker state (no live HTTP call)

Acceptance Criteria

  • /health returns dependency check map
  • All checks run in parallel (< 5s total)
  • Redis unreachable → 503 status
  • Price source circuit state included
  • Response includes uptime_seconds
  • Tests for ok, degraded, and error scenarios
  • Kubernetes readiness probe compatible

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignapiREST API design and endpointsobservabilityLogging, metrics, tracing, monitoring

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions