Skip to content

fix(collector): surface per-query metric errors hidden in Refresh results - #1557

Open
JaredTan95 wants to merge 1 commit into
llm-d:mainfrom
JaredTan95:fix/1151-surface-result-errors
Open

fix(collector): surface per-query metric errors hidden in Refresh results#1557
JaredTan95 wants to merge 1 commit into
llm-d:mainfrom
JaredTan95:fix/1151-surface-result-errors

Conversation

@JaredTan95

@JaredTan95 JaredTan95 commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

MetricsSource.Refresh() returns err == nil even when Prometheus is down — query failures are only visible inside each MetricResult (#1151). Callers that only check the returned error treat a total outage as an empty-but-successful refresh, and failed non-critical queries were silently dropped (no log, no error counter).

Changes

  • PrometheusSource.Refresh: return a joined top-level error when all queries fail; partial failures stay per-result
  • collectReplicaMetrics: sweep per-query results — increment wva_metrics_collection_errors_total with the categorized reason + debug log; fail collection only when every query failed (KV-cache / queue-length severity unchanged)
  • CollectSchedulerQueueMetrics: count refresh and per-result failures under the new scheduler_queue query type
  • scale-from-zero: guard all_metrics for nil/HasError() — a failed scrape is no longer conflated with "no pending requests" (which silently pinned variants at zero replicas), and a missing entry no longer panics
  • Add registration.QueryTypeFor() (query name → counter label, incl. sglang/ prefixes) and new query types: scheduler_queue, dispatch_rate, token_metrics, latency, throughput

Test plan

  • go build ./...; unit tests for all touched packages, incl. new cases: all queries failing → Refresh errors and collection fails; single non-critical query failing → collection succeeds, counter increments under the right query type
  • envtest suites need CI coverage (no kubebuilder binaries locally; they fail identically on pristine main)

Fixes #1151

@github-actions

Copy link
Copy Markdown
Contributor

Unsigned commits detected! Please sign your commits.

For instructions on how to set up GPG/SSH signing and verify your commits, please see GitHub Documentation.

@JaredTan95
JaredTan95 force-pushed the fix/1151-surface-result-errors branch from 33cc4be to f6a5fa4 Compare September 11, 2026 09:20
…ults

MetricsSource.Refresh() defers per-query failures to each MetricResult and
returns err == nil even when the Prometheus backend is down. Callers that
only check the returned error therefore treat a total outage as an
empty-but-successful refresh, and failed non-critical queries were silently
dropped with no log line or error counter.

- PrometheusSource.Refresh: return a joined top-level error when every
  query fails; partial failures stay per-result so healthy queries flow
- collectReplicaMetrics: sweep per-query results, record categorized
  wva_metrics_collection_errors_total increments, and fail collection
  when all queries failed
- CollectSchedulerQueueMetrics: count refresh and per-result failures under
  the new scheduler_queue query type so a broken query is distinguishable
  from an absent flow-control metric
- scale-from-zero: guard the all_metrics result for nil/HasError so a
  failed scrape is no longer conflated with "no pending requests" and no
  longer panics on a missing entry
- registration.QueryTypeFor: map query names to counter labels (incl.
  sglang/ engine prefixes)

Fixes llm-d#1151

Signed-off-by: JaredTan95 <jian.tan@daocloud.io>
@JaredTan95
JaredTan95 force-pushed the fix/1151-surface-result-errors branch from f6a5fa4 to 3f9bf17 Compare September 11, 2026 09:37
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.

Bug: in checking errors from Prometheus query

1 participant