refactor(scout): pair action and reconnect records with their counters#3739
Conversation
|
@coderabbitai full_review, thanks! |
Summary by CodeRabbit
WalkthroughScout telemetry now emits structured logs with action outcomes, action names, errors, reconnect endpoints, and machine identities while preserving metric counters. Service and stream paths populate the expanded events, with tests covering log contents and metric increments. ChangesScout telemetry enrichment
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🐇✨ ✅ Action performedFull review finished. |
|
@coderabbitai full_review, thanks! |
|
🐇🔎 ✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 17 minutes. |
|
Hey @coderabbitai can you do a full_review when you get a chance? CICD isn't letting me continue because the CodeRabbit check "failed". Thanks! |
|
🐇🔎 ✅ Action performedFull review finished. |
Scout action outcomes and stream reconnects each described one occurrence with two calls: a counter update followed by its operator record. Typed sibling `Event`s now own both sides while preserving the existing metric names, labels, log levels, messages, and log-only context. Stream connection outcomes remain metric-only because their surrounding lifecycle records describe a broader boundary. Table-driven tests cover each paired emission and the deliberately silent connection outcome. This supports NVIDIA#3730 Signed-off-by: Chet Nichols III <chetn@nvidia.com>
|
@coderabbitai full_review, thanks! |
|
🐇🔎 ✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 21 minutes. |
|
@coderabbitai full_review, thanks! |
|
🐇🔎 ✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 5 minutes. |
|
@coderabbitai full_review, thanks! |
|
🐇🔎 ✅ Action performedFull review finished. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/scout/src/metrics.rs (1)
116-134: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winHardcoded "10s delay" text is decoupled from the actual sleep duration — extract a shared constant.
ScoutStreamReconnect's fixed message literally states"...after 10s delay", while the real delay is a separately-definedDuration::from_secs(10)in the reconnect loop. Nothing keeps these two in sync; if the delay is ever tuned, the log message will misinform operators without any compiler or test signal.
crates/scout/src/metrics.rs#L116-L134: derive the "10s" wording from a shared constant (or replace it with a generic message and add a#[context] delay_secondsfield per the coding guideline to "record dynamic operational values as structured fields rather than interpolating them into the message").crates/scout/src/stream.rs#L80-L84: define the reconnect delay as apub(crate) const/shared value and reuse it both forDuration::from_secs(...)and to populate the new context field (or the shared constant consumed by the message text).♻️ Proposed fix using a structured delay field
- message = "scout stream reconnecting after 10s delay", + message = "scout stream reconnecting after delay", describe = "Number of scout stream reconnect cycles after a stream closed or errored." )] pub struct ScoutStreamReconnect { #[context] pub api_endpoint: String, #[context] pub machine_id: MachineId, + #[context] + pub delay_seconds: u64, }+const RECONNECT_DELAY: Duration = Duration::from_secs(10); + emit(ScoutStreamReconnect { api_endpoint: options.api.clone(), machine_id, + delay_seconds: RECONNECT_DELAY.as_secs(), }); - tokio::time::sleep(Duration::from_secs(10)).await; + tokio::time::sleep(RECONNECT_DELAY).await;🤖 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/scout/src/metrics.rs` around lines 116 - 134, Replace the hardcoded reconnect delay text in ScoutStreamReconnect with a generic message and add a structured delay_seconds context field populated from a shared reconnect-delay constant. In crates/scout/src/stream.rs lines 80-84, define that constant as pub(crate), reuse it for Duration::from_secs(...) and when constructing ScoutStreamReconnect; update crates/scout/src/metrics.rs lines 116-134 accordingly.
🤖 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/scout/src/metrics.rs`:
- Around line 116-134: Replace the hardcoded reconnect delay text in
ScoutStreamReconnect with a generic message and add a structured delay_seconds
context field populated from a shared reconnect-delay constant. In
crates/scout/src/stream.rs lines 80-84, define that constant as pub(crate),
reuse it for Duration::from_secs(...) and when constructing
ScoutStreamReconnect; update crates/scout/src/metrics.rs lines 116-134
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 2c5ba94c-4871-47ba-a13e-0a4db73b72fa
📒 Files selected for processing (3)
crates/scout/src/main.rscrates/scout/src/metrics.rscrates/scout/src/stream.rs
Scout action outcomes and stream reconnects each described one occurrence with two calls: a counter update followed by its operator record.
Typed sibling
Events now own both sides while preserving the existing metric names, labels, log levels, messages, and log-only context. Stream connection outcomes remain metric-only because their surrounding lifecycle records describe a broader boundary.Table-driven tests cover each paired emission and the deliberately silent connection outcome.
Related issues
Type of Change
Breaking Changes
Testing
The action and stream-connection outcome matrices use named
check_valuesrows, while the reconnect contract remains a focused test.Verified with:
cargo test -p carbide-scoutcargo make format-nightlycargo make clippycargo make carbide-lintscargo make check-event-namesAdditional Notes
Eventlabels are also written into the log record, so action records now carryaction=firmware_upgrade(the bounded metric spelling) alongsideaction_name=FIRMWARE_UPGRADE(the historical protobuf spelling). This keeps the existing metric contract and retains the original action value.Closes #3730