Skip to content

feat: add healthcheck latency metrics and response fields#157

Open
paulobernardoaf wants to merge 1 commit into
mainfrom
feat/healthcheck-latency-metrics
Open

feat: add healthcheck latency metrics and response fields#157
paulobernardoaf wants to merge 1 commit into
mainfrom
feat/healthcheck-latency-metrics

Conversation

@paulobernardoaf

Copy link
Copy Markdown
Contributor

What

Adds Prometheus histogram metrics for Redis, MongoDB, and total healthcheck duration, extends the /healthcheck JSON response with the same latency data, and shares ping helpers between the HTTP handler and the gRPC health monitor. The gRPC binary now exposes /metrics so those observations are scrapeable.

Why

Operators need visibility into dependency ping latency to detect slow or failing Redis/MongoDB connections before they impact clients. Recording metrics only for dependencies that were actually checked avoids polluting histograms with false zero-second MongoDB samples when Redis fails early in the gRPC monitor.

Test plan

  • go test ./pkg/health/... ./pkg/metric/... ./pkg/websocket/ -run 'TestHealthStatus|TestRecordLatencies|TestObserveHealthcheck'
  • Hit GET /healthcheck and confirm redis_latency_seconds, mongo_db_latency_seconds, and total_latency_seconds in the JSON body
  • Scrape GET /metrics and confirm healthcheck_duration_seconds histogram with dependency label (redis, mongodb, total)
  • Verify gRPC pod exposes /metrics and records health monitor observations

Made with Cursor

Expose Redis, MongoDB, and total healthcheck durations as Prometheus
histograms and in the /healthcheck JSON response, with shared ping helpers
for HTTP and gRPC paths and accurate partial-failure metric recording.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants