feat: add circuit breaker, error handler, Prometheus metrics, and Dockerfile improvements - #325
Merged
abayomicornelius merged 2 commits intoJul 30, 2026
Conversation
…kerfile improvements - Circuit breaker (Heliobond#200): Add CIRCUIT_BREAKER_THRESHOLD and CIRCUIT_BREAKER_COOLDOWN_MS env vars, use structured logger for state transitions instead of console.warn - Error handler (Heliobond#199): Use structured logger for server-side error logging, return INTERNAL_ERROR code in JSON response, verify async error handling with Express 5 - Prometheus metrics (Heliobond#201): Add prom-client with /metrics endpoint exposing HTTP request duration/count, Stellar RPC call duration/success/failure, cron job duration/success/failure, and transaction submission metrics - Dockerfile (Heliobond#198): Use Node.js 20 alpine, fix port to 3001, add non-root user, update docker-compose with required env vars, expand .dockerignore Closes Heliobond#198, Closes Heliobond#199, Closes Heliobond#200, Closes Heliobond#201
|
@Odkinggjnr 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! 🚀 |
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.
Description
This PR implements four production-readiness improvements for the Heliobond backend:
1. Circuit Breaker for Stellar RPC Calls (Closes #200)
CIRCUIT_BREAKER_THRESHOLDandCIRCUIT_BREAKER_COOLDOWN_MSconfigurable environment variables (with backward-compatible fallbacks to existingRPC_BREAKER_*vars)console.warnwith structuredlogger.warnfor circuit state transitions (CLOSED → OPEN → HALF_OPEN), including metadata for observability.env.examplewith new circuit breaker env var documentation2. Express Error-Handling Middleware (Closes #199)
logger.errorfor server-side logging instead ofconsole.errorINTERNAL_ERROR(uppercase) matching the issue's acceptance criteria format:{"error":{"code":"INTERNAL_ERROR","message":"..."}}3. Prometheus Metrics Endpoint (Closes #201)
prom-clientand createdsrc/lib/prometheus.tswith metrics registry/metricsendpoint returning Prometheus text formathttp_request_duration_secondshistogram andhttp_requests_totalcounter (labeled by method, route, status_code)stellar_rpc_call_duration_secondshistogram andstellar_rpc_calls_totalcounter (labeled by operation, result)cron_job_duration_secondshistogram andcron_job_runs_totalcounter (labeled by job, result)stellar_tx_submissions_totalcounter andcircuit_breaker_stategaugeprometheusMiddlewarefor automatic HTTP request instrumentation/metricsendpoint4. Dockerfile for Containerized Deployment (Closes #198)
config.PORTdefault)appuser) for security best practicedocker-compose.ymlwith required env vars (ADMIN_SECRET_KEY,PROJECT_REGISTRY_CONTRACT_ID).dockerignoreto exclude test files, docs, and dev configsType of change
Testing checklist
Related issues
Closes #198, Closes #199, Closes #200, Closes #201
Notes
bun.lockfile may need to be regenerated withbun installto include the newprom-clientdependency before CI passes with--frozen-lockfile