Skip to content

feat(npu): produce + emit worker metrics (#10697) - #10699

Merged
mrveiss merged 2 commits into
Dev_new_guifrom
issue-10697
Jun 29, 2026
Merged

mrveiss merged 2 commits into
Dev_new_guifrom
issue-10697

Conversation

@mrveiss

@mrveiss mrveiss commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Thinking Path

Subtask 6.4 of #10602 (umbrella #10603). npu.worker.metrics.updated had subscribers (api/websockets.py, npu_pipeline/invalidation) but no producer — and npu:worker:{id}:metrics was only read/deleted, never written. The verification initially suggested new counters were needed, but the heartbeat already reports total_tasks_completed/failed/uptime_seconds/current_load — enough for real metrics.

What Changed (additive — no existing behavior altered)

  • _build_worker_metrics() — derive NPUWorkerMetrics (real success_rate, requests_per_minute, peak_load) from the heartbeat counters.
  • _store_worker_metrics() — setex to npu:worker:{id}:metrics (mirrors _store_worker_status).
  • Heartbeat handler stores metrics + emits worker.metrics.updated (added to _WORKER_FULL_DATA_EVENTS so the payload carries the metrics). The existing _get_worker_metrics reader now returns real data.

avg_response_time_ms (needs per-worker latency aggregation) → follow-up #NNNN.

Verification

  • services/npu_worker_manager_pulse_test.py — real rate computation (90/10 → 90% success, 90/2min → 45 rpm), no-traffic defaults, correct Redis key (3 new; 13 existing pulse tests still pass).
  • flake8 --max-line-length=120 clean; black/isort clean.

Closes #10697. Part of #10602 / umbrella #10603.

Model Used

Claude Opus 4.8 (1M context)

npu.worker.metrics.updated had subscribers (live UI, cache invalidation) but no
producer — and npu:worker:{id}:metrics was only ever read/deleted, never written.

- _build_worker_metrics(): derive NPUWorkerMetrics from the heartbeat's task
  counters + uptime + load — real success_rate, requests_per_minute, peak_load.
- _store_worker_metrics(): setex to npu:worker:{id}:metrics (mirrors
  _store_worker_status).
- Heartbeat handler now stores metrics + emits worker.metrics.updated (added to
  _WORKER_FULL_DATA_EVENTS so the payload carries the metrics).

avg_response_time_ms needs per-worker latency aggregation → follow-up; this PR
emits the accurately-derivable subset.

Tests: real rate computation, no-traffic defaults, correct Redis key (3 new;
13 existing pulse tests still pass).

Closes #10697. Part of #10602 / umbrella #10603.
@github-actions

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No hardcoded values detected that have SSOT config equivalents!

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