Skip to content

feat(health): add NVLink domain UUID to switch telemetry - #4476

Open
jayzhudev wants to merge 3 commits into
NVIDIA:mainfrom
jayzhudev:health/nvl-domain-uuid
Open

feat(health): add NVLink domain UUID to switch telemetry#4476
jayzhudev wants to merge 3 commits into
NVIDIA:mainfrom
jayzhudev:health/nvl-domain-uuid

Conversation

@jayzhudev

Copy link
Copy Markdown
Contributor

Switch health metrics and logs need the NVLink domain UUID to correlate failures. This PR reads the UUID from NICo API switch inventory or static endpoint configuration and includes it in metric and log sink output.

Collectors restart when the UUID changes so telemetry does not retain stale domain metadata. Missing, invalid, and nil UUIDs are omitted.

Related issues

Supports #4397

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.)

Read switch domain UUIDs from Carbide API and propagate them to metrics,
OTLP attributes, events, and structured logs.

Restart collectors when a switch changes domains so cached metadata and
registered metric labels are replaced before collection resumes.

Signed-off-by: Jay Zhu <jayzhu@nvidia.com>
Allow static switch endpoints to provide NVLink domain UUID metadata.
Ignore invalid and nil values so telemetry never publishes unusable labels.

Preserve first-source precedence when duplicate endpoint keys are discovered,
preventing false domain changes and unnecessary collector restarts.

Signed-off-by: Jay Zhu <jayzhu@nvidia.com>
@jayzhudev jayzhudev self-assigned this Aug 1, 2026
@jayzhudev
jayzhudev requested review from a team and polarweasel as code owners August 1, 2026 18:30
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 43bef3e1-3a4f-4da9-b357-743113b1f068

📥 Commits

Reviewing files that changed from the base of the PR and between 5865518 and 9a1b40b.

📒 Files selected for processing (4)
  • crates/health/src/collectors/runtime.rs
  • crates/health/src/discovery/cleanup.rs
  • crates/health/src/sink/events.rs
  • docs/architecture/health_aggregation.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/architecture/health_aggregation.md
  • crates/health/src/sink/events.rs

Summary by CodeRabbit

  • New Features

    • Added optional NVLink domain UUID metadata for switch endpoints.
    • Included valid domain UUIDs in telemetry, logs, events, and Prometheus labels.
    • Automatically refreshes switch collectors when domain metadata changes.
  • Bug Fixes

    • Invalid or nil domain UUID values are omitted from telemetry.
    • Improved cleanup of stale switch collectors during refreshes.
  • Documentation

    • Updated configuration and telemetry documentation with switch domain metadata details.

Walkthrough

Switch endpoints now carry optional NVLink domain UUID metadata from static configuration and API responses. Discovery restarts stale switch collectors after domain changes. Event, log, Prometheus, and OTLP outputs expose valid domain UUIDs.

Changes

NVLink domain metadata

Layer / File(s) Summary
Switch metadata ingestion
crates/health/src/endpoint/model.rs, crates/health/src/config.rs, crates/health/src/endpoint/sources.rs, crates/health/src/api_client.rs, crates/health/example/config.example.toml
Static configuration and API responses parse optional NVLink domain UUIDs. Nil and invalid values are omitted. The value is stored in SwitchData.
Discovery domain-change restarts
crates/health/src/discovery/context.rs, crates/health/src/discovery/cleanup.rs, crates/health/src/discovery/iteration.rs, crates/health/src/discovery/spawn.rs, crates/health/src/collectors/runtime.rs, crates/health/src/collectors/nvue/gnmi/*
Discovery tracks domain UUIDs by switch endpoint key. Changed domains stop affected collectors before replacement collectors start. Shutdown can abort unresponsive collectors. Tests cover unchanged domains, duplicate endpoint sources, and forced cleanup.
Telemetry propagation
crates/health/src/sink/events.rs, crates/health/src/sink/log_file.rs, crates/health/src/sink/prometheus.rs, crates/health/src/otlp/convert.rs, docs/architecture/health_aggregation.md
Switch domain UUIDs are exposed through event context, JSONL logs, Prometheus labels, and OTLP resource attributes. Documentation describes the metadata fields and sink output names.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DiscoveryIteration
  participant CollectorState
  participant Cleanup
  participant SwitchCollectors
  DiscoveryIteration->>CollectorState: Observe switch domain UUID
  CollectorState-->>DiscoveryIteration: Report domain change
  DiscoveryIteration->>Cleanup: Stop stale switch collectors
  Cleanup->>SwitchCollectors: Await shutdown or abort
  DiscoveryIteration->>SwitchCollectors: Spawn collectors with updated metadata
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding NVLink domain UUID support to switch telemetry.
Description check ✅ Passed The description directly explains UUID sources, telemetry outputs, collector restarts, omissions, and testing.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
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 Aug 1, 2026

Copy link
Copy Markdown

@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: 3

🤖 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 `@crates/health/src/discovery/cleanup.rs`:
- Around line 51-106: Add a bounded shutdown helper around Collector::stop so
each stale collector is given a deadline, then its task is aborted and joined if
it does not finish; update the final join_all in stop_stale_switch_collectors to
use this behavior. Ensure shutdown does not detach old collectors before
replacements are spawned, and preserve cleanup completion for every collector.

In `@crates/health/src/sink/events.rs`:
- Line 673: Update the switch accessor fixtures at the changed
`nvlink_domain_uuid` assignments to use a fixed non-nil UUID instead of
`nvlink_domain_id()`, so they verify propagation of a valid switch UUID.
Preserve nil UUID omission coverage in a separate test case.

In `@docs/architecture/health_aggregation.md`:
- Line 284: Update the OTLP resource-attribute documentation in the
`[sinks.otlp]` section to include machine.serial, driver.version,
component.type, switch.serial_number, switch.endpoint_role, and
switch.is_primary, matching the attributes emitted by the conversion logic. Keep
the existing attribute names and type annotations accurate, and ensure the list
is presented as complete rather than omitting emitted attributes.
🪄 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: 608e4956-418f-408e-8c87-e8a7f38e0c29

📥 Commits

Reviewing files that changed from the base of the PR and between ef4fffb and 5865518.

📒 Files selected for processing (16)
  • crates/health/example/config.example.toml
  • crates/health/src/api_client.rs
  • crates/health/src/collectors/nvue/gnmi/on_change_processor.rs
  • crates/health/src/collectors/nvue/gnmi/sample_processor.rs
  • crates/health/src/config.rs
  • crates/health/src/discovery/cleanup.rs
  • crates/health/src/discovery/context.rs
  • crates/health/src/discovery/iteration.rs
  • crates/health/src/discovery/spawn.rs
  • crates/health/src/endpoint/model.rs
  • crates/health/src/endpoint/sources.rs
  • crates/health/src/otlp/convert.rs
  • crates/health/src/sink/events.rs
  • crates/health/src/sink/log_file.rs
  • crates/health/src/sink/prometheus.rs
  • docs/architecture/health_aggregation.md

Comment thread crates/health/src/discovery/cleanup.rs
Comment thread crates/health/src/sink/events.rs
Comment thread docs/architecture/health_aggregation.md Outdated
Abort and join stale collectors that exceed the shutdown grace period so
domain metadata refresh cannot block discovery indefinitely or detach old
tasks.

Use a valid non-nil UUID in sink fixtures and document the complete OTLP
resource attributes.

Signed-off-by: Jay Zhu <jayzhu@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant