Skip to content

feat(health): add /health/dependencies with onchain_rpc_ms latency check#344

Closed
Preciousuche wants to merge 3 commits into
ChainForgee:mainfrom
Preciousuche:feat/health-dependencies-onchain-latency
Closed

feat(health): add /health/dependencies with onchain_rpc_ms latency check#344
Preciousuche wants to merge 3 commits into
ChainForgee:mainfrom
Preciousuche:feat/health-dependencies-onchain-latency

Conversation

@Preciousuche

@Preciousuche Preciousuche commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Closes #287

Summary

Adds a new GET /api/v1/health/dependencies endpoint that measures on-chain RPC latency and reports it as onchain_rpc_ms.

  • If the call exceeds the 5s threshold, overall status is degraded (still HTTP 200 — the service is alive, just slow, so monitoring can see the number).
  • If the call fails, status is down (HTTP 503).
  • The timing logic mirrors the existing checkOnchainContract() pattern in HealthService.

Note on getAdmin(): the issue references a getAdmin() RPC call, but OnchainAdapter doesn't currently expose one. I used the existing read-only getContractMetadata() call to measure latency and left a comment on the issue asking whether a dedicated getAdmin() method is preferred. Swapping it is a one-line change if so.

Testing

  • pnpm build (backend) passes — clean type-check.
  • pnpm test:e2e health passes:
PASS  test/health.e2e-spec.ts
  Health dependencies (e2e)
    √ /health/dependencies (GET) reports onchain_rpc_ms
Tests:       1 passed, 1 total

The e2e test overrides the on-chain adapter with a fast fake, so it verifies the endpoint's behaviour without touching a live network.

Checklist

  • Tests added for new behavior
  • Build passes locally
  • Follows existing code patterns

@Preciousuche

Copy link
Copy Markdown
Contributor Author

Closing in favor of #357, which is a cleaned-up version with unrelated files removed.

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.

Health check that proves the on-chain adapter is reachable at boot

2 participants