Skip to content

feat: Add comprehensive health check endpoints with real-time monitoring - #18

Merged
virajbhartiya merged 2 commits into
mainfrom
feature/health-check-endpoints
Jul 20, 2025
Merged

feat: Add comprehensive health check endpoints with real-time monitoring#18
virajbhartiya merged 2 commits into
mainfrom
feature/health-check-endpoints

Conversation

@virajbhartiya

Copy link
Copy Markdown
Member

Health Check Implementation

This PR adds comprehensive health monitoring capabilities to the parity client with real-time data collection and service connectivity testing.

Features Added

HTTP Health Endpoints

  • /health - Basic health check with service configuration status
  • /health/detailed - Detailed health information with live service connectivity tests
  • /health/ready - Kubernetes readiness probe with dependency validation
  • /health/live - Kubernetes liveness probe for application status

CLI Health Command

  • parity-client health - Command line health check
  • parity-client health --detailed - Detailed health information
  • parity-client health --endpoint <url> - Custom endpoint support
  • parity-client health --timeout <duration> - Configurable timeout

Real-Time Data Collection

  • Uptime tracking since application start
  • Version information from git tags and build metadata
  • Live connectivity tests to blockchain, IPFS, and runner services
  • Latency measurements for each service
  • Real configuration values from environment

Technical Implementation

Service Health Checks

  • Blockchain: Uses ethclient.Dial() and BlockNumber() for connectivity
  • IPFS: Uses shell.Version() for IPFS API connectivity
  • Runner: HTTP health check to runner service endpoint
  • Error handling with detailed error messages

Version Management

  • Version package for centralized version management
  • Build-time injection of git tags, commit SHA, and build timestamp
  • Runtime platform and Go version information

Kubernetes Integration

  • Readiness probe returns 503 if dependencies unavailable
  • Liveness probe for application status check
  • Proper HTTP status codes for monitoring systems

Usage Examples

Command Line

# Basic health check
parity-client health

# Detailed health information
parity-client health --detailed

# Custom endpoint with timeout
parity-client health --endpoint http://localhost:8080 --timeout 30s

HTTP API

# Basic health check
curl http://localhost:3000/health

# Detailed health information
curl http://localhost:3000/health/detailed

# Kubernetes probes
curl http://localhost:3000/health/ready
curl http://localhost:3000/health/live

Response Format

Basic Health Check

{
  "status": "healthy",
  "timestamp": "2024-01-15T10:30:00Z",
  "version": "v1.0.0",
  "uptime": "2h30m15s",
  "services": {
    "blockchain": "configured",
    "ipfs": "configured",
    "runner": "configured"
  }
}

Detailed Health Check

{
  "status": "healthy",
  "timestamp": "2024-01-15T10:30:00Z",
  "version": "v1.0.0",
  "uptime": "2h30m15s",
  "services": {
    "blockchain": {
      "status": "healthy",
      "last_check": "2024-01-15T10:29:55Z",
      "latency": "125ms"
    },
    "ipfs": {
      "status": "healthy",
      "last_check": "2024-01-15T10:29:58Z",
      "latency": "45ms"
    },
    "runner": {
      "status": "healthy",
      "last_check": "2024-01-15T10:30:00Z",
      "latency": "78ms"
    }
  },
  "config": {
    "server_host": "0.0.0.0",
    "server_port": 3000,
    "blockchain_rpc": "https://your-blockchain-node.com",
    "ipfs_endpoint": "http://localhost:5001",
    "runner_url": "http://localhost:8080"
  }
}

- Add health check command to CLI for checking the health status of the parity client and its services.
- Introduce health handler with endpoints for basic health, detailed health, readiness, and liveness checks.
- Update Makefile to include versioning information during build.
- Enhance README with comprehensive health monitoring documentation and usage examples.
- Refactor router to handle health check endpoints.
@virajbhartiya virajbhartiya self-assigned this Jul 20, 2025
@virajbhartiya
virajbhartiya merged commit ca4c946 into main Jul 20, 2025
1 check passed
@virajbhartiya
virajbhartiya deleted the feature/health-check-endpoints branch July 20, 2025 10:28
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.

1 participant