Skip to content

🌱 Add bounded metrics for device-tracker scan cycles - #23350

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
telemetry/device-tracker-scan-metrics
Open

🌱 Add bounded metrics for device-tracker scan cycles#23350
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
telemetry/device-tracker-scan-metrics

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Fixes #23349

What

DeviceTracker.scanDevices (pkg/agent/workers/workers_device_tracker.go) runs a 60s scan loop across all managed clusters entirely outside the HTTP request path, and had no observability: no cycle counter, no duration histogram, and ListClusters/GetNodes failures were only ever visible as a single rate-limited slog.Info line.

Change

Adds, in pkg/agent/workers/device_tracker_metrics.go, following the existing bounded self-metrics pattern (see pkg/api/metrics/metrics.go's stellar/gpu sweep counters):

  • kc_device_tracker_scan_cycles_total (counter)
  • kc_device_tracker_scan_duration_seconds (histogram)
  • kc_device_tracker_scan_errors_total{stage} (counter; stage{list_clusters, get_nodes} — fixed, bounded set, never a cluster/node identifier)

Registered alongside the existing prediction metrics in InitPredictionMetrics() and exposed via the agent's existing /metrics endpoint. No exporter or new external data flow is introduced — this is pull-only self-observability.

Testing

  • go build ./pkg/agent/...
  • go test ./pkg/agent/workers/... — passes
  • gofmt / go vet clean

— hive: agent=telemetry backend=copilot model=claude-sonnet-4-6

The device-tracker background loop (pkg/agent/workers) runs a 60s scan
across all managed clusters entirely outside the HTTP request path, and
had no observability: no cycle counter, no duration histogram, and
ListClusters/GetNodes failures were only ever visible as a single
rate-limited slog line.

Add kc_device_tracker_scan_cycles_total, kc_device_tracker_scan_duration_seconds,
and kc_device_tracker_scan_errors_total{stage}, following the same bounded,
pull-only pattern already used for the stellar/gpu sweep loops in
pkg/api/metrics/metrics.go. stage is a fixed two-value set
(list_clusters, get_nodes) — no cluster or node identifiers are used as
labels. Metrics are exposed via the agent's existing /metrics endpoint;
no exporter or new external data flow is introduced.

Fixes #23349

Signed-off-by: kubestellar-hive[bot] <223556219+Copilot@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 13, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Sep 13, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit b021916
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6aa62d961c115400083e6f3e

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @kubestellar-hive[bot] — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@github-actions github-actions Bot added tier/2-standard ai-generated Pull request generated by AI labels Sep 13, 2026
@kubestellar-prow kubestellar-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 13, 2026
@kubestellar-hive kubestellar-hive Bot added the hold Blocked — do not touch label Sep 13, 2026
@kubestellar-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human sign-off on the direction, not on the code.

This PR's only tracked rationale is #23349, which the hive filed itself — issue #23349 was filed by kubestellar-hive[bot] and no human has acknowledged it. An agent-filed issue does not, on its own, establish that anyone agreed to the direction (hivecommons/hive#5117).

The change may well be right; nothing here is a review of it. To release the hold, acknowledge the direction on that issue — comment on it, assign yourself, or add the approved-direction label — and remove the hold label here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. hold Blocked — do not touch size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[telemetry] device-tracker scan loop (pkg/agent/workers) has no cycle/duration/error metrics

1 participant