Skip to content

feat(nvue-client): measure the switch-config REST calls#3537

Open
chet wants to merge 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3173-nvue
Open

feat(nvue-client): measure the switch-config REST calls#3537
chet wants to merge 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3173-nvue

Conversation

@chet

@chet chet commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

The nvue REST client -- the switch-configuration path -- logged and measured nothing, so a failed NVUE request was invisible. Every public method funnels through one execute, so metering that once covers the client.

  • execute takes an operation name and wraps its request in red::instrumented("nvue", operation, ...), recording carbide_external_call_duration_milliseconds{backend = "nvue", operation, outcome} and a WARN on failure. A non-success HTTP status counts as an error, not only a transport failure.
  • Each public method passes its own operation (get_applied_config, apply_config_revision, the DELETE and PATCH halves of a config replace, and so on); the composite helpers inherit the measurement from the primitives they call.

It reuses the outbound-RED family, so there are no new catalogue rows.

This supports #3173

The nvue REST client -- the switch-configuration path -- logged and measured nothing, so a failed NVUE request was invisible. Every public method funnels through one `execute`, so metering that once covers the client.

- `execute` takes an `operation` name and wraps its request in `red::instrumented("nvue", operation, ...)`, recording `carbide_external_call_duration_milliseconds{backend = "nvue", operation, outcome}` and a WARN on failure. A non-success HTTP status counts as an error, not only a transport failure.
- Each public method passes its own operation (`get_applied_config`, `apply_config_revision`, the DELETE and PATCH halves of a config replace, and so on); the composite helpers inherit the measurement from the primitives they call.

It reuses the outbound-RED family, so there are no new catalogue rows.

This supports NVIDIA#3173

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet chet requested a review from a team as a code owner July 15, 2026 06:09
@chet

chet commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@chet, sounds good — I'll redo the full review of all changes in this PR now.

ヽ(•‿•)ノ

✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features
    • Added request instrumentation to NVUE client HTTP operations for improved activity visibility and diagnostics.
    • Requests are now labeled with specific operation names, making it easier to distinguish actions across configuration operations, system information retrieval, and bridge MAC table lookups.

Walkthrough

NVUE client HTTP operations now pass explicit operation identifiers to an instrumented execution helper. The helper wraps reqwest execution and preserves existing request error mapping. The crate adds a local carbide-instrument dependency.

Changes

NVUE request instrumentation

Layer / File(s) Summary
Instrumented request execution
crates/nvue-client/Cargo.toml, crates/nvue-client/src/client.rs
Adds the instrumentation dependency, updates execute to accept an operation identifier, and instruments request execution and error handling.
Operation label wiring
crates/nvue-client/src/client.rs
Passes explicit operation names through all NVUE HTTP methods, including distinct delete and patch labels for configuration replacement.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant NvueClient
  participant red_instrumented
  participant reqwest
  NvueClient->>red_instrumented: instrumented("nvue", operation, request)
  red_instrumented->>reqwest: execute HTTP request
  reqwest-->>red_instrumented: response or error
  red_instrumented-->>NvueClient: response or RequestFailed
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: instrumenting NVUE client switch-configuration REST calls.
Description check ✅ Passed The description aligns with the code changes and objectives, describing NVUE request instrumentation and error handling.
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.

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

🧹 Nitpick comments (2)
crates/nvue-client/src/client.rs (2)

79-105: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for the instrumented boundary.

Add table-driven tests covering successful responses, transport failures, HTTP failures, preserved RequestFailed metadata, and the operation labels—including both replace_config.delete and replace_config.patch.

As per coding guidelines, tests for observable input/output and error mappings should use table-driven cases.

🤖 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 `@crates/nvue-client/src/client.rs` around lines 79 - 105, Add table-driven
regression tests for the execute method, covering successful responses,
transport errors, HTTP status errors, RequestFailed metadata preservation, and
operation labels. Include both replace_config.delete and replace_config.patch
labels, and assert the observable response and error mappings at the
instrumented boundary.

Source: Coding guidelines


79-82: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Represent operation names as a typed finite set.

The operation values are a closed set, but they are currently raw string literals. Introduce a private NvueOperation enum with a canonical string representation, then convert to the required static label only at the red::instrumented boundary. This prevents typos from silently creating new metric series.

As per coding guidelines and path instructions, known finite Rust values should be modeled explicitly rather than passed as bare strings.

Also applies to: 110-110, 118-118, 127-127, 149-154, 164-164, 189-189, 227-227

🤖 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 `@crates/nvue-client/src/client.rs` around lines 79 - 82, Introduce a private
NvueOperation enum covering every operation currently passed to execute, with a
canonical string representation. Update execute and all its call sites to use
this enum, and convert the enum to the required &'static str only at the
red::instrumented boundary, preserving the existing operation labels.

Sources: Coding guidelines, Path instructions

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

Nitpick comments:
In `@crates/nvue-client/src/client.rs`:
- Around line 79-105: Add table-driven regression tests for the execute method,
covering successful responses, transport errors, HTTP status errors,
RequestFailed metadata preservation, and operation labels. Include both
replace_config.delete and replace_config.patch labels, and assert the observable
response and error mappings at the instrumented boundary.
- Around line 79-82: Introduce a private NvueOperation enum covering every
operation currently passed to execute, with a canonical string representation.
Update execute and all its call sites to use this enum, and convert the enum to
the required &'static str only at the red::instrumented boundary, preserving the
existing operation labels.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1f4aa237-f4f4-4e62-be02-e6c1013938ec

📥 Commits

Reviewing files that changed from the base of the PR and between eb4ea22 and 61fa7ff.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/nvue-client/Cargo.toml
  • crates/nvue-client/src/client.rs

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

🧹 Nitpick comments (2)
crates/nvue-client/src/client.rs (2)

79-105: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add table-driven coverage for the instrumented execution boundary.

Please cover successful responses, HTTP error responses handled by error_for_status(), transport failures, and preservation of RequestFailed details. Also verify the distinct delete/patch operation labels if the existing instrumentation test harness supports it.

As per coding guidelines, Rust tests for input-to-output, error, or observable-result mappings should be table-driven.

🤖 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 `@crates/nvue-client/src/client.rs` around lines 79 - 105, Add table-driven
tests around Client::execute covering successful responses, HTTP status
failures, transport errors, and preservation of RequestFailed method, URL, body,
and source details. Reuse the existing instrumentation test harness to assert
the delete and patch operation labels when supported, while keeping each case
focused on the observable result and recorded operation.

Source: Coding guidelines


79-105: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Represent operation labels with a Rust enum.

operation and all call sites currently use raw &'static str values, even though this is a finite metric-label set. Introduce a NvueOperation enum with Display and convert to the instrumentation string only at the red::instrumented boundary. This prevents typo-driven metric fragmentation and makes future call sites harder to misuse.

Suggested shape
-        operation: &'static str,
+        operation: NvueOperation,

-        self.execute("get_api", request).await
+        self.execute(NvueOperation::GetApi, request).await

As per coding guidelines, known finite Rust values must use enums rather than bare strings, with a derived string representation.

Also applies to: 107-118, 127-127, 149-154, 164-164, 189-189, 227-227

🤖 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 `@crates/nvue-client/src/client.rs` around lines 79 - 105, Introduce a finite
NvueOperation enum covering every operation label used by execute and its call
sites, derive or implement Display for its instrumentation value, and change
execute plus all callers to use the enum instead of &'static str. Convert the
enum to a string only at the red::instrumented boundary, preserving the existing
metric labels exactly.

Source: Coding guidelines

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

Nitpick comments:
In `@crates/nvue-client/src/client.rs`:
- Around line 79-105: Add table-driven tests around Client::execute covering
successful responses, HTTP status failures, transport errors, and preservation
of RequestFailed method, URL, body, and source details. Reuse the existing
instrumentation test harness to assert the delete and patch operation labels
when supported, while keeping each case focused on the observable result and
recorded operation.
- Around line 79-105: Introduce a finite NvueOperation enum covering every
operation label used by execute and its call sites, derive or implement Display
for its instrumentation value, and change execute plus all callers to use the
enum instead of &'static str. Convert the enum to a string only at the
red::instrumented boundary, preserving the existing metric labels exactly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fccc4ab7-7e69-4f20-a295-2c336f618374

📥 Commits

Reviewing files that changed from the base of the PR and between eb4ea22 and 61fa7ff.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/nvue-client/Cargo.toml
  • crates/nvue-client/src/client.rs

@github-actions

Copy link
Copy Markdown

🔍 Container Scan Summary

Service Total Critical High Medium Low Other
boot-artifacts-aarch64 3 0 0 3 0 0
boot-artifacts-x86_64 3 0 0 3 0 0
forge-admin-cli-x86_64 259 13 30 78 7 131
machine-validation-runner 807 40 234 288 36 209
machine_validation 807 40 234 288 36 209
machine_validation-aarch64 807 40 234 288 36 209
nvmetal-carbide 807 40 234 288 36 209
TOTAL 3493 173 966 1236 151 967

Per-CVE detail lives in the per-service grype-* artifacts (JSON + SARIF). Severity counts only — no CVE IDs published here.

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