Skip to content

Orc metrics - #87

Merged
jessicaochen merged 6 commits into
llm-d-incubation:mainfrom
jessicaochen:orc-metrics
Jul 16, 2026
Merged

Orc metrics#87
jessicaochen merged 6 commits into
llm-d-incubation:mainfrom
jessicaochen:orc-metrics

Conversation

@jessicaochen

@jessicaochen jessicaochen commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

MVP set of metrics for the orchestrator.

Why is this change needed?

How was this tested?

  • Unit tests added/updated
  • Integration/e2e tests added/updated
  • Manual testing performed - I do see all the metrics fill out

Checklist

  • Commits are signed off (git commit -s) per DCO
  • Code follows project contributing guidelines
  • Tests pass locally (make test)
  • Linters pass (make lint)
  • Documentation updated (if applicable)

Related Issues

Summary by CodeRabbit

  • New Features
    • Added Prometheus metrics for queue depth, lock acquire wait time, snapshot/restore operation duration, and deferred snapshots.
    • Exposed a dedicated HTTP /metrics endpoint on a configurable --metrics-port (default 8080), including Kubernetes service/deployment updates.
  • Bug Fixes
    • Improved graceful shutdown by stopping the metrics HTTP server with a timeout.
    • Refined metric recording to align with acquire/yield and reconciliation timing.
    • Cleaned up stale queue-depth metric series when groups are deleted.
  • Tests
    • Expanded metric assertions for queue depth transitions, acquire wait observations, operation-duration histograms, and deferred-snapshot counters.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cd8c8012-ba5d-4768-aa86-3977bb298310

📥 Commits

Reviewing files that changed from the base of the PR and between fdf4647 and 70c4146.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (11)
  • cmd/acceleratororchestrator/main.go
  • deploy/acceleratororchestrator/templates/deployment.yaml
  • deploy/acceleratororchestrator/templates/service.yaml
  • go.mod
  • pkg/accelerator-orchestrator/controller/controller.go
  • pkg/accelerator-orchestrator/controller/controller_internal_test.go
  • pkg/accelerator-orchestrator/controller/controller_test.go
  • pkg/accelerator-orchestrator/metrics/metrics.go
  • pkg/accelerator-orchestrator/server/server.go
  • pkg/accelerator-orchestrator/server/server_test.go
  • pkg/accelerator-orchestrator/store/group_store.go
🚧 Files skipped from review as they are similar to previous changes (9)
  • deploy/acceleratororchestrator/templates/service.yaml
  • pkg/accelerator-orchestrator/controller/controller_internal_test.go
  • deploy/acceleratororchestrator/templates/deployment.yaml
  • pkg/accelerator-orchestrator/controller/controller_test.go
  • go.mod
  • pkg/accelerator-orchestrator/store/group_store.go
  • pkg/accelerator-orchestrator/server/server.go
  • pkg/accelerator-orchestrator/metrics/metrics.go
  • cmd/acceleratororchestrator/main.go

📝 Walkthrough

Walkthrough

Adds Prometheus metrics definitions and registration, instruments controller and server operations, exposes a /metrics HTTP endpoint on port 8080, cleans up deleted-group queue metrics, updates deployment wiring and dependencies, and extends tests for metric recording.

Changes

Prometheus metrics instrumentation

Layer / File(s) Summary
Metrics definitions and lifecycle cleanup
pkg/accelerator-orchestrator/metrics/metrics.go, pkg/accelerator-orchestrator/store/group_store.go, go.mod
Defines and registers four Prometheus metrics, adds client dependencies, and removes queue-depth series when groups are deleted.
Controller instrumentation and operation tracking
pkg/accelerator-orchestrator/controller/controller.go, pkg/accelerator-orchestrator/controller/controller_internal_test.go, pkg/accelerator-orchestrator/controller/controller_test.go
Records queue depth and snapshot/restore operation duration, updates waitForOperation parameters, and extends controller tests.
Metrics endpoint and request instrumentation
pkg/accelerator-orchestrator/server/server.go, pkg/accelerator-orchestrator/server/server_test.go
Adds the /metrics HTTP server and graceful shutdown, records acquire and deferred-snapshot metrics, and validates them in server tests.
Startup and deployment wiring
cmd/acceleratororchestrator/main.go, deploy/acceleratororchestrator/templates/deployment.yaml, deploy/acceleratororchestrator/templates/service.yaml
Adds the --metrics-port flag, passes it to StartServer, and exposes port 8080 in deployment and service templates.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Main as acceleratororchestrator main
  participant Server as StartServer
  participant Controller as Controller
  participant Metrics as metrics package
  participant Prometheus as Prometheus scraper
  Main->>Metrics: Register metrics
  Main->>Server: StartServer with metricsPort
  Server->>Server: Serve /metrics
  Controller->>Metrics: Record queue and operation metrics
  Server->>Metrics: Record acquire and deferred snapshot metrics
  Prometheus->>Server: GET /metrics
  Server-->>Prometheus: Prometheus metrics
Loading

Suggested reviewers: aishukamal, edwinhr716

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is too vague to convey the main change; it only says metrics without specifying the orchestrator updates. Use a specific title like "Add orchestrator metrics and metrics endpoint" to describe the primary change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@jessicaochen
jessicaochen requested a review from aishukamal July 9, 2026 19:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
pkg/accelerator-orchestrator/server/server.go (1)

293-298: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Metrics server bind failure is only logged, not surfaced.

If httpServer.ListenAndServe() fails (e.g. port conflict), the error is logged but the process keeps running with gRPC serving normally while /metrics silently never comes up. Given metrics-port is now a required operational contract (Helm exposes it, scraping depends on it), consider surfacing this failure more visibly (e.g., via a startup health signal) rather than only a log line.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/accelerator-orchestrator/server/server.go` around lines 293 - 298, The
metrics server startup path in the anonymous goroutine around
httpServer.ListenAndServe only logs bind failures and lets the process continue,
so surface this as a startup-critical failure instead of a log-only event.
Update the server startup flow in server.go to propagate or signal the error
from ListenAndServe (for example via the main startup/health coordination used
by the server) and make sure the failure is visible to the orchestrator rather
than leaving gRPC running with metrics silently unavailable.
pkg/accelerator-orchestrator/server/server_test.go (1)

108-110: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Global metric assertion is order/isolation-dependent.

testutil.CollectAndCount(metrics.AcquireWaitDuration) checks a package-level singleton shared across all test cases/files in the binary. The == 0 check is tolerant to prior accumulation, but it can't detect regressions where this specific call fails to observe (since other tests/paths may have already incremented it). This is an inherent limitation of testing global Prometheus collectors without a per-test registry; acceptable here given the loose assertion, but worth keeping in mind if stricter counts are needed later.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/accelerator-orchestrator/server/server_test.go` around lines 108 - 110,
The assertion on metrics.AcquireWaitDuration is using the global Prometheus
collector, so it cannot reliably prove this test case recorded a new
observation. In server_test.go, either keep the loose presence check as-is and
avoid tightening it, or switch the test to a per-test registry/isolated
collector setup around the AcquireWaitDuration observation path so the check is
scoped to this test instead of shared process-wide state.
deploy/acceleratororchestrator/templates/deployment.yaml (1)

27-29: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Metrics port is hardcoded; consider making it configurable via .Values.

The grpc port on line 25 (50051) is also hardcoded, so this is consistent with existing chart style, but the gRPC service port on the Service side is templated via .Values.service.port while metrics is not on either side. Since main.go exposes --metrics-port as a configurable flag (default 8080), hardcoding it in the chart means operators can't change it without editing templates directly.

♻️ Proposed refactor
             - name: metrics
-              containerPort: 8080
+              containerPort: {{ .Values.metrics.port | default 8080 }}
               protocol: TCP
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@deploy/acceleratororchestrator/templates/deployment.yaml` around lines 27 -
29, The metrics container port in the deployment template is hardcoded, so wire
it through chart values instead of fixing it at 8080. Update the deployment spec
that defines the metrics port to read from .Values, and keep it aligned with the
configurable --metrics-port flag exposed by main.go. Use the existing port
templating pattern already used for the service port (for example, the
service.port value) and add a matching metrics value if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/accelerator-orchestrator/server/server.go`:
- Around line 285-292: Set the metrics HTTP server in server.go to use a full
timeout configuration, not just ReadHeaderTimeout. Update the http.Server
initialization in the metrics server setup to also define ReadTimeout,
WriteTimeout, and IdleTimeout alongside the existing ReadHeaderTimeout so slow
or malicious clients cannot keep connections open indefinitely. Use the
httpServer construction near the "/metrics" mux setup as the place to apply
these additional timeout fields.

---

Nitpick comments:
In `@deploy/acceleratororchestrator/templates/deployment.yaml`:
- Around line 27-29: The metrics container port in the deployment template is
hardcoded, so wire it through chart values instead of fixing it at 8080. Update
the deployment spec that defines the metrics port to read from .Values, and keep
it aligned with the configurable --metrics-port flag exposed by main.go. Use the
existing port templating pattern already used for the service port (for example,
the service.port value) and add a matching metrics value if needed.

In `@pkg/accelerator-orchestrator/server/server_test.go`:
- Around line 108-110: The assertion on metrics.AcquireWaitDuration is using the
global Prometheus collector, so it cannot reliably prove this test case recorded
a new observation. In server_test.go, either keep the loose presence check as-is
and avoid tightening it, or switch the test to a per-test registry/isolated
collector setup around the AcquireWaitDuration observation path so the check is
scoped to this test instead of shared process-wide state.

In `@pkg/accelerator-orchestrator/server/server.go`:
- Around line 293-298: The metrics server startup path in the anonymous
goroutine around httpServer.ListenAndServe only logs bind failures and lets the
process continue, so surface this as a startup-critical failure instead of a
log-only event. Update the server startup flow in server.go to propagate or
signal the error from ListenAndServe (for example via the main startup/health
coordination used by the server) and make sure the failure is visible to the
orchestrator rather than leaving gRPC running with metrics silently unavailable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8745f144-0a3b-4dea-a843-164bd2c409cd

📥 Commits

Reviewing files that changed from the base of the PR and between 7991854 and 7f880fe.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (10)
  • cmd/acceleratororchestrator/main.go
  • deploy/acceleratororchestrator/templates/deployment.yaml
  • deploy/acceleratororchestrator/templates/service.yaml
  • go.mod
  • pkg/accelerator-orchestrator/controller/controller.go
  • pkg/accelerator-orchestrator/controller/controller_internal_test.go
  • pkg/accelerator-orchestrator/controller/controller_test.go
  • pkg/accelerator-orchestrator/metrics/metrics.go
  • pkg/accelerator-orchestrator/server/server.go
  • pkg/accelerator-orchestrator/server/server_test.go

Comment thread pkg/accelerator-orchestrator/server/server.go
Comment thread pkg/accelerator-orchestrator/metrics/metrics.go Outdated
Comment thread pkg/accelerator-orchestrator/metrics/metrics.go
Comment thread pkg/accelerator-orchestrator/server/server.go
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Time-Slicing Project Tracker Jul 15, 2026
@aishukamal

Copy link
Copy Markdown
Collaborator

/approve

@aishukamal
aishukamal self-requested a review July 16, 2026 18:41
github-actions[bot]
github-actions Bot previously approved these changes Jul 16, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Time-Slicing Project Tracker Jul 16, 2026
@jessicaochen
jessicaochen merged commit 5aa6071 into llm-d-incubation:main Jul 16, 2026
9 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.

2 participants