Skip to content

fix(ratelimiter): log metrics server bind failures at error level - #1096

Draft
rootkiller6788 wants to merge 1 commit into
NVIDIA:mainfrom
rootkiller6788:fix-ratelimiter-metrics-error-log
Draft

fix(ratelimiter): log metrics server bind failures at error level#1096
rootkiller6788 wants to merge 1 commit into
NVIDIA:mainfrom
rootkiller6788:fix-ratelimiter-metrics-error-log

Conversation

@rootkiller6788

Copy link
Copy Markdown

What

setupMetrics in src/invocation-plane-services/ratelimiter/cmd/main.go discarded the http.ListenAndServe error in an empty branch:

err := http.ListenAndServe("0.0.0.0:7776", mux)
if err != nil {

}

If the Prometheus listener cannot bind, the service keeps running with no metrics and logs nothing — scrapes fail with connection refused and there is no signal in the pod logs. This fixes #540.

Change

  • Log the bind/serve failure at error level, matching the sibling setupPprof and setupOlricStats servers in the same file.
  • Add metrics_test.go: a regression test that occupies 0.0.0.0:7776 so the bind fails deterministically, swaps the global logger for a zaptest/observer, and asserts the metrics server failed log line is emitted.
  • Wire metrics_test.go into the cmd_test bazel target.

Verification

  • go build ./cmd/... passes.
  • go vet ./cmd/ passes.
  • go test ./cmd/ -run TestSetupMetricsLogsServeFailure -count=1 passes.

The empty branch is the only code path the fix touches; the error log uses the same zap.L().Error(...) idiom already used by the other two servers in the file.

setupMetrics discards the http.ListenAndServe error in an empty branch,
so a Prometheus listener that fails to bind leaves the service running
with no metrics and no signal in the pod logs. Log the failure at error
level, matching setupPprof and setupOlricStats in the same file.

Add a regression test that occupies the metrics port so the bind fails
deterministically, and asserts the error-level log line is emitted.
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 18c434bf-41f2-426f-bd95-f8e2f0ca9d7f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

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.

ratelimiter: metrics server failure is swallowed by an empty error branch

1 participant