Skip to content

Enhancement #241: Improved /health endpoint with structured JSON, MB …#254

Open
jikrana1 wants to merge 1 commit into
AnthropicBots:mainfrom
jikrana1:enhancement/issue-241-health-endpoint
Open

Enhancement #241: Improved /health endpoint with structured JSON, MB …#254
jikrana1 wants to merge 1 commit into
AnthropicBots:mainfrom
jikrana1:enhancement/issue-241-health-endpoint

Conversation

@jikrana1

@jikrana1 jikrana1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📋 Pull Request — Improve Health Endpoint with Structured Health Checks

🔗 Related Issue

Closes #241Improve Health Endpoint with Structured Health Checks and Dependency Status

✅ Changes Made

  • Structured JSON Response: Grouped response into application, system, and dependencies sections for better monitoring compatibility.
  • Application Section: Added name and version read directly from package.json, environment, startTime, uptime, processId, and nodeVersion.
  • System Section: Converted raw memoryUsage (bytes) to readable MB format. Added platform and arch details from os module.
  • Dependency Section (Database): Added MongoDB connection state and a dynamic latency check (ping command) for production monitoring.
  • Overall Health Status: Implemented a unified status flag (OK, DEGRADED, UNHEALTHY). If the DB is disconnected, the status becomes UNHEALTHY and returns HTTP 503. If the DB ping fails, it returns DEGRADED and HTTP 200.
  • Security: Ensured no sensitive configurations are exposed in the response.

🧪 Testing Checklist

  • Server starts successfully.
  • Navigating to /health returns a structured JSON with all required sections.
  • Memory values are correctly displayed in MB.
  • DB latency is calculated and displayed as Xms when the database is connected.
  • App status returns UNHEALTHY (HTTP 503) if MongoDB is deliberately disconnected.
  • App status remains OK (HTTP 200) when all dependencies are healthy.

📌 Benefits Achieved

  • Better production monitoring – Clear, structured data for tools like Datadog/New Relic.
  • Easier debugging – Detailed DB state and process info included.
  • More maintainable API – Meets modern structured health-check standards.

…red JSON, MB memory, DB latency, and application/OS details
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Mohit Yadav's projects Team on Vercel.

A member of the Team first needs to authorize it.

@BHUVANSH855 BHUVANSH855 added SSoC26 Program label for Social Summer of Code Season 5. Merge Conflicts labels Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merge Conflicts SSoC26 Program label for Social Summer of Code Season 5.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Health Endpoint with Structured Health Checks and Dependency Status

2 participants