← Back to Pull requests

[Bugfix][Router] Treat a /metrics scrape with no recognized vLLM metrics as a failed scrape #1226

Open
unknown opened this pull request with 291 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 20, 2026 07:01 UTC
Author

Fixes #1074

Problem

EngineStats.from_vllm_scrape() reads a fixed set of vllm: metrics and starts every field at zero. When a backend's /metrics contains none of them (a different engine, a relabeling proxy, or a vLLM version that renamed them), it still returns an all-zero EngineStats, and the scraper stores it as a successful scrape. The backend then looks idle, with a 0% prefix cache hit rate, and nothing is logged.

The issue describes the impact on load-aware routing. On current main the routers use the router's own in-flight request counts (since #1089 and #1108), so the remaining impact is on observability: the router's /metrics export (and the Grafana dashboard built on it) and the periodic engine-stats log line report false zeros for that backend.

Change

  • from_vllm_scrape() returns None when the scrape contains none of the recognized metrics, including an empty scrape. A scrape with at least one recognized metric is parsed exactly as before.

  • _scrape_one_endpoint() logs a warning naming the backend URL and returns None, the same path as a failed request. The backend is left out of engine_stats, and because the router clears its per-backend gauges before each export, its series disappear from the router's /metrics. Dashboards show "no data" for it instead of 0.

  • The warning is logged on every scrape interval, consistent with how failed scrapes are logged today.
  • Tests

    New src/tests/test_engine_stats_unrecognized.py:

  • unrecognized metrics → None

  • empty scrape → None

  • partial scrape (one recognized metric) is still parsed

  • _scrape_one_endpoint() returns None and warns with the backend URL

  • a recognized scrape does not warn
  • Three of these fail on main and pass with this change. The full src/tests suite passes (230 tests). black, isort, ruff (on src/tests) and codespell are clean.

    Possible follow-up (not in this PR)

    A backend that exports only some of the metrics still reports the missing ones as 0. A follow-up could make the EngineStats fields optional and skip unset values when exporting and logging, so the router only reports metrics it actually received. I'm happy to open that if it would be useful.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01LFWhq5wm3BF7aAhiqfmDGm

    Diff: 291 lines (+218 / -73) across 3 files Reviewer: chrikrah Review duration: 6211m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 291 lines diff across 3 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.340
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #1226"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.9% (MEDIUM) · Higher = larger blast radius
    44.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.9% · Safe to merge
    23.9%