Skip to content

refactor(dsx): emit queue drops, deduplications, and leak alerts#3742

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3733
Jul 21, 2026
Merged

refactor(dsx): emit queue drops, deduplications, and leak alerts#3742
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3733

Conversation

@chet

@chet chet commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

The DSX exchange consumer counted queue drops, deduplications, and leak alerts separately from the records that explained them. Leak alerts also retained the consumer's final hand-built counter.

Typed Events now own each existing counter and diagnostic together. Drop and deduplication counters remain zero-label, leak alerts preserve the BMS CamelCase LeakPointType values, and rack/point detail stays log-only. The empty metrics holder left behind is removed.

Metric/log exposition and the bounded label mappings are covered with table-driven tests.

Related issues

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

The metric series, log fields, exporter names, and canonical leak-point labels are covered by named check_values and value_scenarios! rows. Stateful deduplication and health-report persistence remain explicit tests.

Verified with:

  • cargo test -p carbide-dsx-exchange-consumer
  • cargo make format-nightly
  • cargo make clippy
  • cargo make carbide-lints
  • cargo make check-event-names
  • cargo xtask check-metric-docs

Additional Notes

LeakPointType keeps a manual LabelValue mapping because the existing metric contract uses the BMS CamelCase spellings. Deriving that mapping would silently change them to snake_case.

The generated docs/observability/core_metrics.md row stays with this implementation because it is validated as part of the Event contract and is excluded from technical-writer review.

Closes #3733

@chet
chet requested a review from a team as a code owner July 20, 2026 22:17
@chet

chet commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 20, 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: 67a88bc7-6ba6-4a7c-801b-e4972a28c07b

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad44c6 and 77a11aa.

📒 Files selected for processing (7)
  • crates/dsx-exchange-consumer/src/health_updater.rs
  • crates/dsx-exchange-consumer/src/lib.rs
  • crates/dsx-exchange-consumer/src/metrics.rs
  • crates/dsx-exchange-consumer/src/mqtt_consumer.rs
  • crates/dsx-exchange-consumer/tests/dedup_trace.rs
  • crates/dsx-exchange-consumer/tests/metric_exposition.rs
  • docs/observability/core_metrics.md

Summary by CodeRabbit

  • Observability
    • Enhanced warning/trace/info logs for queue drops, deduplication, and leak-alert detection, including message type plus point/rack/value context.
    • Added/updated Prometheus metrics for leak-alerts detected with point-type labels.
    • Refreshed metric/log instrumentation to preserve existing metric naming while improving metric exposure accuracy.
  • Documentation
    • Added carbide_dsx_exchange_consumer_alerts_detected_total to the core metrics reference.
  • Reliability
    • Continued health reporting for deduplicated and fault-cleared values, including consistent persistence-failure reporting.

Walkthrough

The DSX exchange consumer replaces manual alert metrics with structured instrumentation events. Drop, deduplication, and leak-alert events include typed context and labels, runtime wiring uses the simplified HealthUpdater constructor, and tests validate logs and Prometheus exposition.

Changes

DSX consumer observability

Layer / File(s) Summary
Structured event contracts
crates/dsx-exchange-consumer/src/metrics.rs, docs/observability/core_metrics.md
Message drop, deduplication, and leak-alert events expose structured fields and labels; the manual ConsumerMetrics API is removed and the alerts counter is documented.
Runtime event emission and wiring
crates/dsx-exchange-consumer/src/health_updater.rs, crates/dsx-exchange-consumer/src/mqtt_consumer.rs, crates/dsx-exchange-consumer/src/lib.rs
MQTT drops identify metadata versus value messages, HealthUpdater emits structured deduplication and leak-alert events, and service setup uses the reduced constructor signature.
Behavior and exposition validation
crates/dsx-exchange-consumer/src/health_updater.rs, crates/dsx-exchange-consumer/tests/*
Unit and integration tests adopt the new constructor and verify trace fields, event logs, counter deltas, alert help text, and persistence-failure logging.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MQTTConsumer
  participant HealthUpdater
  participant CarbideInstrument
  participant Prometheus
  MQTTConsumer->>CarbideInstrument: Emit typed MessageDropped event
  HealthUpdater->>CarbideInstrument: Emit MessageDeduplicated or LeakAlertDetected
  CarbideInstrument->>Prometheus: Record counters and labels
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main refactor to emit queue drops, deduplications, and leak alerts.
Description check ✅ Passed The description is clearly aligned with the refactor and test coverage changes in this pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@chet Understood — I’ll perform a full review of PR #3742, reassessing the complete change set for correctness, maintainability, metrics/logging contract preservation, and test coverage.

🐇🔍

✅ Action performed

Full review finished.

@github-actions

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.

🧹 Nitpick comments (1)
crates/dsx-exchange-consumer/src/metrics.rs (1)

173-192: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider modeling point_type as LeakPointType instead of String.

MessageDeduplicated::point_type is a bare String sourced from metadata.point_type.clone(), even though a validated LeakPointType (leak_type) is already computed and in scope at the only call site (health_updater.rs, handle_value_message). DroppedMessageType in this same file already proves #[context] fields can be non-String enums, so this isn't a macro limitation. Using the canonical enum instead of re-threading the raw metadata string avoids any risk of the logged point_type drifting from the value that was actually validated via leak_point_type().

♻️ Proposed refactor
 pub struct MessageDeduplicated {
     #[context]
     pub point_path: String,
     #[context]
-    pub point_type: String,
+    pub point_type: LeakPointType,
     #[context]
     pub value: String,
 }

And at the call site in crates/dsx-exchange-consumer/src/health_updater.rs:

                         emit(MessageDeduplicated {
                             point_path: point_path.to_string(),
-                            point_type: metadata.point_type.clone(),
+                            point_type: leak_type,
                             value: format!("{value:?}"),
                         });

As per coding guidelines, **/*.{rs,rs.in} files should "model finite sets of values with enums or structs of enums, deriving string representations through Display/FromStr; avoid passing them as bare String or &str values."

🤖 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/dsx-exchange-consumer/src/metrics.rs` around lines 173 - 192, Change
MessageDeduplicated::point_type from String to the validated LeakPointType enum,
following the existing non-String context field pattern such as
DroppedMessageType. At the handle_value_message call site, pass the in-scope
leak_type produced by leak_point_type() instead of metadata.point_type.clone(),
preserving the logged value’s alignment with validation.

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/dsx-exchange-consumer/src/metrics.rs`:
- Around line 173-192: Change MessageDeduplicated::point_type from String to the
validated LeakPointType enum, following the existing non-String context field
pattern such as DroppedMessageType. At the handle_value_message call site, pass
the in-scope leak_type produced by leak_point_type() instead of
metadata.point_type.clone(), preserving the logged value’s alignment with
validation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 51ac0f23-abb4-45b3-b50b-cd32aaa1a9d8

📥 Commits

Reviewing files that changed from the base of the PR and between 113c774 and 0415219.

📒 Files selected for processing (7)
  • crates/dsx-exchange-consumer/src/health_updater.rs
  • crates/dsx-exchange-consumer/src/lib.rs
  • crates/dsx-exchange-consumer/src/metrics.rs
  • crates/dsx-exchange-consumer/src/mqtt_consumer.rs
  • crates/dsx-exchange-consumer/tests/dedup_trace.rs
  • crates/dsx-exchange-consumer/tests/metric_exposition.rs
  • docs/observability/core_metrics.md

@chet

chet commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@chet Understood. I’ll perform a fresh full review of #3742, including correctness, metric and logging contract preservation, maintainability, and test coverage.

🐇🔍

✅ Action performed

Full review finished.

@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 `@crates/dsx-exchange-consumer/src/lib.rs`:
- Around line 103-105: Ensure the health-updater task created from
HealthUpdater::run is supervised when the metrics listener wins the
tokio::select! path: abort it and await its JoinHandle before returning, or
manage both tasks through a JoinSet. Preserve observable task panics and
shutdown completion, while retaining the intentional metrics-endpoint exception.
🪄 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: 0069364b-eada-476d-b274-5c359cba34ea

📥 Commits

Reviewing files that changed from the base of the PR and between 0415219 and 19826d7.

📒 Files selected for processing (7)
  • crates/dsx-exchange-consumer/src/health_updater.rs
  • crates/dsx-exchange-consumer/src/lib.rs
  • crates/dsx-exchange-consumer/src/metrics.rs
  • crates/dsx-exchange-consumer/src/mqtt_consumer.rs
  • crates/dsx-exchange-consumer/tests/dedup_trace.rs
  • crates/dsx-exchange-consumer/tests/metric_exposition.rs
  • docs/observability/core_metrics.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • crates/dsx-exchange-consumer/src/mqtt_consumer.rs
  • docs/observability/core_metrics.md
  • crates/dsx-exchange-consumer/tests/dedup_trace.rs
  • crates/dsx-exchange-consumer/tests/metric_exposition.rs
  • crates/dsx-exchange-consumer/src/health_updater.rs
  • crates/dsx-exchange-consumer/src/metrics.rs

Comment thread crates/dsx-exchange-consumer/src/lib.rs
@chet chet changed the title refactor(dsx): emit consumer message events refactor(dsx): count queue drops, dedupes, and leak alerts where they happen Jul 20, 2026
@chet chet changed the title refactor(dsx): count queue drops, dedupes, and leak alerts where they happen refactor(dsx): emit queue drops, deduplications, and leak alerts Jul 21, 2026

chet commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@chet Understood. I’ll perform a fresh, end-to-end review of #3742, with emphasis on correctness, metric/logging contract preservation, maintainability, and test coverage.

🐇🔍

✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 21 minutes.

The DSX exchange consumer counted queue drops, deduplications, and leak alerts separately from the records that explained them. Leak alerts also retained the consumer's final hand-built counter.

Typed `Event`s now own each existing counter and diagnostic together. Drop and deduplication counters remain zero-label, leak alerts preserve the BMS CamelCase `LeakPointType` values, and rack/point detail stays log-only. The empty metrics holder left behind is removed.

Metric/log exposition and the bounded label mappings are covered with table-driven tests.

This supports NVIDIA#3733

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet

chet commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

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!

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@chet I’ve triggered a fresh full review for #3742. This should rerun the CodeRabbit check; if it still reports a failure afterward, please share the check details so I can help isolate the cause.

🐇🔍

✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 13 minutes.

chet commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@chet Understood. I’ve triggered a fresh end-to-end review of #3742, covering correctness, maintainability, metric/logging contract preservation, and test coverage.

🐇🔍

✅ Action performed

Full review finished.

chet commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@chet Understood — I’ve triggered a fresh end-to-end review of #3742, covering correctness, maintainability, metric/logging contract preservation, and test coverage.

🐇🔍

✅ Action performed

Full review finished.

@chet
chet merged commit 34e00e3 into NVIDIA:main Jul 21, 2026
64 checks passed
@chet
chet deleted the gh-issue-3733 branch July 21, 2026 15:54
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.

Finish coherent DSX consumer message Events

2 participants