Skip to content

docs: per-object state metrics#3104

Open
yoks wants to merge 3 commits into
NVIDIA:mainfrom
yoks:metric-per-object-design
Open

docs: per-object state metrics#3104
yoks wants to merge 3 commits into
NVIDIA:mainfrom
yoks:metric-per-object-design

Conversation

@yoks

@yoks yoks commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Design describing #2186 implementation.

https://github.com/yoks/bare-metal-manager-core/blob/d7497715d555d0bdc120766a8ebda0c77d56ffb0/docs/design/per-object-state-metrics.md

Related issues

#2186

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

Signed-off-by: ianisimov <ianisimov@nvidia.com>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • Documentation
    • Added a design proposal for per-object state progress observability with bounded cardinality.
    • Defines new per-object gauges for current-state timestamps, per-state SLA seconds, and a manual-intervention-needed signal with controlled reason labels.
    • Specifies an opt-in metrics endpoint for these series, plus join-friendly object info and association mapping gauges for multi-unit hosts.
    • Includes example PromQL queries for SLA breach detection and triage workflows.

Walkthrough

This PR adds a design document for per-object state progress metrics. It defines the metric set, endpoint behavior, cardinality limits, query patterns, exclusions, and implementation approach.

Changes

Per-object state metrics design proposal

Layer / File(s) Summary
Problem statement and existing building blocks
docs/design/per-object-state-metrics.md
Documents the limits of aggregate-only metrics, the per-object questions the design addresses, and the existing state mapping, SLA resolution, and registry pieces it reuses.
Metric catalog and design specification
docs/design/per-object-state-metrics.md
Defines the dedicated endpoint, gauge-only metric set, fixed label shapes, cardinality budget, and the new state-entry, SLA, object-info, and association metrics.
Query examples and non-goals
docs/design/per-object-state-metrics.md
Shows PromQL patterns for SLA breach detection, manual-intervention triage, and join-based suppression, then lists the excluded metric categories and shapes.
Implementation approach
docs/design/per-object-state-metrics.md
Describes extending PerObjectMetricsRegistry, routing per-object gauges to the dedicated endpoint, and feeding the metrics from the generic processor and machine-controller handler.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Related Issues: Not specified.

Related PRs: Not specified.

Suggested labels: documentation, design-proposal

Suggested reviewers: Not specified.

Poem:
A metric plan, precise and lean,
With bounded labels kept unseen;
For every object, state is clear,
Yet series count stays calm all year.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the new design document about per-object state metrics.
Description check ✅ Passed The description is directly related, referencing the design document and issue #2186.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🔍 Container Scan Summary

No Grype artifacts were found to aggregate.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
docs/design/per-object-state-metrics.md (1)

222-248: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Call out the registry API break explicitly.

PerObjectMetricsRegistry is currently classification-specific and registers one hard-coded gauge on the supplied meter. The implementation plan should say this is a breaking expansion, not a drop-in reuse, so the existing health metric and the new state/_info gauges stay clearly separated.

Suggested text change
- We extend it rather than adding a sibling:
+ We extend it rather than adding a sibling, but this is a breaking API expansion: the current classification-only gauge stays intact while new handles are added for state and `_info` metrics:
🤖 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 `@docs/design/per-object-state-metrics.md` around lines 222 - 248, The plan
should explicitly state that reusing PerObjectMetricsRegistry is a breaking API
expansion, not a drop-in reuse, because it is currently classification-specific
and only registers one hard-coded gauge. Update the description around
PerObjectMetricsRegistry, gauge(name, description), and the processor.rs hookup
to call out that the registry shape and handle API must change, while keeping
the existing health metric separate from the new state and _info gauges on the
per-object meter.
🤖 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 `@docs/design/per-object-state-metrics.md`:
- Around line 119-135: The `carbide_machine_instance_info` example currently
includes free-form `tenant_org`, which violates the bounded-label rule for
`_info` metrics. Update the documentation around the `carbide_object_info` and
`carbide_machine_instance_info` examples to remove the raw tenant string and, if
tenant attribution is needed, describe using a stable internal tenant ID/code
instead; keep the label set limited to closed-set traits plus object IDs.
- Around line 55-59: Qualify the scrape-interval guidance in the design doc so
it only applies to the state-transition series, since the `_info` and
association metrics can still change on inventory or topology updates. Update
the wording around the scrape advice near the `run.rs::create_metrics()`
discussion to explicitly distinguish the slow-changing state series from the
freshness-sensitive metrics, and avoid implying that all of the new metrics can
safely be scraped every 60–120s.

---

Nitpick comments:
In `@docs/design/per-object-state-metrics.md`:
- Around line 222-248: The plan should explicitly state that reusing
PerObjectMetricsRegistry is a breaking API expansion, not a drop-in reuse,
because it is currently classification-specific and only registers one
hard-coded gauge. Update the description around PerObjectMetricsRegistry,
gauge(name, description), and the processor.rs hookup to call out that the
registry shape and handle API must change, while keeping the existing health
metric separate from the new state and _info gauges on the per-object meter.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 10f87234-fdf5-450f-b024-f03862a708d3

📥 Commits

Reviewing files that changed from the base of the PR and between 7a199a7 and d749771.

📒 Files selected for processing (1)
  • docs/design/per-object-state-metrics.md

Comment thread docs/design/per-object-state-metrics.md
Comment thread docs/design/per-object-state-metrics.md

@polarweasel polarweasel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All minor stuff, but hopefully worth thinking about...

Comment thread docs/design/per-object-state-metrics.md Outdated
Comment thread docs/design/per-object-state-metrics.md Outdated
Comment thread docs/design/per-object-state-metrics.md Outdated
Comment thread docs/design/per-object-state-metrics.md Outdated
Comment thread docs/design/per-object-state-metrics.md Outdated
Comment thread docs/design/per-object-state-metrics.md Outdated
"machine_id", "$1", "object_id", "(.*)")
```

**Stuck-and-unhealthy — is it hardware?** (join with the #2168 metric):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Uh... GitHub issue numbers directly in docs? I'd prefer this at least be a real URL to the issue, and even better, a one-liner explanation from said issue (with a link).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is design doc, i do not think they are rendered in docs? At least i think they should not be. If there is wrong place, where we put design (RFC)?

Comment thread docs/design/per-object-state-metrics.md Outdated
Comment on lines +237 to +238
endpoint (moving it is a scrape-config-visible change; do it as a later,
separately announced step).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This feels like an internal note. If there's a plan to make the change, maybe link to the issue for tracking? And if there's no plan yet, I'd be inclined to remove.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is more about RFC/Design, not docs, so i think it is justified here

Comment thread docs/design/per-object-state-metrics.md Outdated
Comment thread docs/design/per-object-state-metrics.md Outdated
Comment on lines +244 to +247
Wiring mirrors #2168: constructed in `setup.rs`, registered on the per-object
meter, threaded via the controller builder. `carbide_object_info` and
associations are recorded from the machine-controller handler, which already
loads rack/SKU/DPU/instance data next to the existing per-object health call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again, add a real URL at least, but probably better to add real description (and also possibly a link to the issue/PR).

Suggested change
Wiring mirrors #2168: constructed in `setup.rs`, registered on the per-object
meter, threaded via the controller builder. `carbide_object_info` and
associations are recorded from the machine-controller handler, which already
loads rack/SKU/DPU/instance data next to the existing per-object health call.
This wiring mirrors #2168: constructed in `setup.rs`, registered on the
per-object meter, threaded via the controller builder. `carbide_object_info`
and associations are recorded from the machine-controller handler, which
already loads rack/SKU/DPU/instance data next to the existing per-object
health call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added link, i find it is cleaner to look at source, it have more context than just explaining it in the RFC

yoks and others added 2 commits July 3, 2026 10:06
Co-authored-by: Alex Ball <awball@polarweasel.org>
Signed-off-by: Ivan Anisimov <inyokwetrust@gmail.com>
Signed-off-by: ianisimov <ianisimov@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@docs/design/per-object-state-metrics.md`:
- Around line 187-193: The reprovision suppression example in the
per-object-state metrics docs is too broad and includes a no-op label rewrite.
Update the expression around the suppression logic to remove the unnecessary
label_replace on carbide_machine_dpu_info and make the state selector on
carbide_object_state_entered_timestamp_seconds explicitly filter
object_type="machine". Keep the example anchored to the existing
labels/functions (carbide_forge_dpu_agent_last_call, carbide_machine_dpu_info,
carbide_object_state_entered_timestamp_seconds, and the unless on(machine_id)
clause) so it remains safe and technically correct to copy.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2747f8d9-2813-4149-a16a-9a0b6c64fa65

📥 Commits

Reviewing files that changed from the base of the PR and between 68998b7 and d38419e.

📒 Files selected for processing (1)
  • docs/design/per-object-state-metrics.md

Comment on lines +187 to +193
```
(time() - carbide_forge_dpu_agent_last_call > 900)
and on(dpu_id) label_replace(carbide_machine_dpu_info, "dpu_id", "$1", "dpu_id", "(.*)")
unless on(machine_id) label_replace(
carbide_object_state_entered_timestamp_seconds{state="reprovisioning"},
"machine_id", "$1", "object_id", "(.*)")
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Tighten the reprovision suppression example.

label_replace(..., "dpu_id", "$1", "dpu_id", "(.*)") is a no-op, and the state selector should pin object_type="machine" so the example cannot suppress DPU alerts for an unrelated object type that happens to expose reprovisioning. As per path instructions, examples should stay technically correct and safe to copy.

Suggested fix
-(time() - carbide_forge_dpu_agent_last_call > 900)
-and on(dpu_id) label_replace(carbide_machine_dpu_info, "dpu_id", "$1", "dpu_id", "(.*)")
-unless on(machine_id) label_replace(
-  carbide_object_state_entered_timestamp_seconds{state="reprovisioning"},
-  "machine_id", "$1", "object_id", "(.*)")
+(time() - carbide_forge_dpu_agent_last_call > 900)
+and on(dpu_id) carbide_machine_dpu_info
+unless on(machine_id) label_replace(
+  carbide_object_state_entered_timestamp_seconds{object_type="machine",state="reprovisioning"},
+  "machine_id", "$1", "object_id", "(.*)")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
(time() - carbide_forge_dpu_agent_last_call > 900)
and on(dpu_id) label_replace(carbide_machine_dpu_info, "dpu_id", "$1", "dpu_id", "(.*)")
unless on(machine_id) label_replace(
carbide_object_state_entered_timestamp_seconds{state="reprovisioning"},
"machine_id", "$1", "object_id", "(.*)")
```
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 187-187: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 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 `@docs/design/per-object-state-metrics.md` around lines 187 - 193, The
reprovision suppression example in the per-object-state metrics docs is too
broad and includes a no-op label rewrite. Update the expression around the
suppression logic to remove the unnecessary label_replace on
carbide_machine_dpu_info and make the state selector on
carbide_object_state_entered_timestamp_seconds explicitly filter
object_type="machine". Keep the example anchored to the existing
labels/functions (carbide_forge_dpu_agent_last_call, carbide_machine_dpu_info,
carbide_object_state_entered_timestamp_seconds, and the unless on(machine_id)
clause) so it remains safe and technically correct to copy.

Source: Path instructions

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.

3 participants