Skip to content

fix(metrics): serve lightweight /healthz on metrics port - #12

Open
azgms wants to merge 1 commit into
feat/websocket-supportfrom
fix/metrics-port-lightweight-healthz
Open

fix(metrics): serve lightweight /healthz on metrics port#12
azgms wants to merge 1 commit into
feat/websocket-supportfrom
fix/metrics-port-lightweight-healthz

Conversation

@azgms

@azgms azgms commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • Mount a mux on the metrics port so /healthz and /health return a cheap 200 OK without calling Prometheus Gather.
  • Keep /metrics (and / for back-compat) as promhttp.Handler().

Why

Prod DaemonSet probes hit :4001/healthz. That port used promhttp.Handler() as the root handler, so every path returned the full exposition. On hot pods (PreferSameNode skew) that payload is 14–26MB / 80–137k series. Concurrent Gather with Prometheus scrapes pushed scrape duration to 5–10s, exceeding kubelet timeoutSeconds: 5 and causing liveness kills (internal-erpc-zczc4, probe failures on frd5n).

Real :4000/healthcheck stays healthy at ~4–13ms during the same windows — the process was fine; the probe target was wrong/expensive.

Test plan

  • go test ./erpc/ -run TestNewMetricsHandler
  • After merge + image bump: curl :4001/healthz returns OK in <10ms and is not a Prometheus dump
  • :4001/metrics still scrapes normally
  • Pair with charts PR that moves kube probes to :4000 (defense in depth either way)

Made with Cursor

promhttp was mounted as the root handler, so kubelet probes to /healthz
on :4001 received the full Prometheus exposition (10-26MB on hot pods).
Concurrent Gather with scrapes exceeded probe timeouts and restarted
pods. Route /healthz|/health to a cheap 200 OK; keep /metrics (and /)
as the exposition.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
File Lines Key changes Risk
🔵 init.go +23/-1 newMetricsHandler
1 test files +57

xray — see through AI slop with deterministic architecture PR diff reviews

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