Skip to content

test(router-proxy): pin the metrics endpoint to the llmkube registry - #1480

Merged
Defilan merged 1 commit into
defilantech:mainfrom
Defilan:fix/router-proxy-metrics-registry
Aug 10, 2026
Merged

test(router-proxy): pin the metrics endpoint to the llmkube registry#1480
Defilan merged 1 commit into
defilantech:mainfrom
Defilan:fix/router-proxy-metrics-registry

Conversation

@Defilan

@Defilan Defilan commented Aug 10, 2026

Copy link
Copy Markdown
Member

What

A regression test pinning the router-proxy metrics endpoint to the registry the
llmkube collectors actually register into, plus the small extraction that makes
it testable.

Why

Refs #1427

The fix this PR originally carried is already on main. #1393 landed it while
this was open, so all that remains, and the part that was missing, is a test.

The endpoint added in #1457 wired promhttp.Handler(), which serves
prometheus.DefaultGatherer, while internal/metrics registers every collector
into ctrlmetrics.Registry. Different registries, so it exposed none of
llmkube_router_* or llmkube_modelpool_*.

That is worth a test rather than care, because the failure is silent in every
direction: the scrape returns HTTP 200, the PodMonitor from #1473 reports a
healthy target, and the dashboards are just empty. It survived review and a
merge for exactly that reason. Measured on the built binaries at the time: 38
metric families under the default registry, 149 under controller-runtime's.

How

One detail is load-bearing. The test increments a real router counter before
scraping, because a labelled collector emits no family until it has a child
series, so an idle scrape is byte-identical under either registry and the
obvious version of this test passes on the bug.

I verified that by reintroducing promhttp.Handler() and confirming the test
fails, then restoring the fix and confirming it passes. A regression test nobody
has watched fail is not yet a regression test.

newMetricsHandler() is extracted from main() only so there is something to
assert against; the behaviour is unchanged from what #1393 landed.

Credit

The underlying bug was found by @sylvainsf while rebasing #1393. This PR was
opened to carry the fix separately, and has been repurposed to the test now that
their fix has merged.

Testing

go test ./cmd/router-proxy/, make lint 0 issues, and the fails-without-the-fix
check described above.

Checklist

  • Tests added/updated
  • make test passes locally
  • make lint passes locally
  • Commit messages follow conventional commits
  • All commits are signed off (git commit -s) per DCO
  • AI assistance (if any) is disclosed above
  • Documentation updated (if user-facing change) — none needed, no behaviour change

Assisted-by: Claude Code (wrote the test and the extraction, and ran the
two-binary comparison and the fails-without-the-fix validation)

The endpoint served the Prometheus default registry while every llmkube
collector registers into controller-runtime's, so it exposed none of the series
it exists for. That shipped in defilantech#1457 and was fixed in defilantech#1393; nothing stops it
regressing again.

The failure is silent, which is the reason it needs a test rather than care.
The scrape returns HTTP 200 with Go runtime and process metrics, the PodMonitor
from defilantech#1473 reports a healthy target, and the dashboards are simply empty.

Touching a real counter before scraping is load-bearing: a labelled collector
emits no family until it has a child series, so an idle scrape is identical
under either registry and the obvious version of this test passes on the bug.
Verified by reintroducing promhttp.Handler() and confirming the test fails,
rather than assuming a new test must catch something.

newMetricsHandler() is extracted from main() only so there is something to
assert against.

Co-authored-by: Sylvain Niles <540991+sylvainsf@users.noreply.github.com>
Signed-off-by: Christopher Maher <chris@mahercode.io>
@Defilan
Defilan force-pushed the fix/router-proxy-metrics-registry branch from e08f42a to 276b000 Compare August 10, 2026 00:10
@Defilan Defilan changed the title fix(router-proxy): serve the registry the llmkube collectors register into test(router-proxy): pin the metrics endpoint to the llmkube registry Aug 10, 2026
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/router-proxy/main.go 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Defilan
Defilan merged commit 8f2a1f3 into defilantech:main Aug 10, 2026
24 checks passed
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