Skip to content

[ISSUE #3452]🚀Add ConsumerAttr struct and builder for metrics tracking #3453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2025

Conversation

mxsm
Copy link
Owner

@mxsm mxsm commented Jun 12, 2025

Which Issue(s) This PR Fixes(Closes)

Fixes #3452

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • New Features

    • Introduced a new metrics module for tracking consumer attributes.
    • Added a ConsumerAttr struct to represent consumer group details, including group name, language, version, and consume mode.
    • Provided builder pattern for safe and flexible creation of consumer attributes.
    • Enabled filtering and querying of consumer attributes by group, language, or consume mode.
    • Added support for serialization, formatted display, and collection operations on consumer attributes.
  • Tests

    • Included comprehensive unit tests covering creation, comparison, builder usage, filtering, and serialization of consumer attributes.

@Copilot Copilot AI review requested due to automatic review settings June 12, 2025 14:42
Copy link
Contributor

coderabbitai bot commented Jun 12, 2025

Walkthrough

A new metrics module has been added to the rocketmq-broker crate. Within this module, a consumer_attr submodule introduces the ConsumerAttr struct, a builder pattern for safe construction, error handling for missing fields, comparison and hashing implementations, filtering extensions for collections, and comprehensive unit tests.

Changes

File(s) Change Summary
rocketmq-broker/src/lib.rs Added pub(crate) mod metrics; to include the new metrics module.
rocketmq-broker/src/metrics.rs Created new module file; declares mod consumer_attr;.
rocketmq-broker/src/metrics/consumer_attr.rs Introduced ConsumerAttr struct, builder, error type, extension trait, filtering, and unit tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConsumerAttrBuilder
    participant ConsumerAttr

    User->>ConsumerAttrBuilder: set group, language, version, consume_mode
    ConsumerAttrBuilder->>ConsumerAttrBuilder: validate fields
    alt All fields present
        ConsumerAttrBuilder->>ConsumerAttr: build ConsumerAttr instance
        ConsumerAttr-->>User: return ConsumerAttr
    else Missing field(s)
        ConsumerAttrBuilder-->>User: return ConsumerAttrError
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement ConsumerAttr struct and builder for metrics tracking (#3452)

Poem

In the meadow of code where the metrics bloom,
A ConsumerAttr hops in, dispelling the gloom.
With builders and filters, so robust and neat,
Now tracking our clients is truly a treat!
🐇✨
— A rabbit with a metrics beat


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9d6826 and 8da749a.

📒 Files selected for processing (1)
  • rocketmq-broker/src/metrics/consumer_attr.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • rocketmq-broker/src/metrics/consumer_attr.rs
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build (macos-latest, nightly)
  • GitHub Check: build (windows-latest, nightly)
  • GitHub Check: build
  • GitHub Check: test
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (ubuntu-latest, nightly)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: auto-approve
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rocketmq-rust-bot
Copy link
Collaborator

🔊@mxsm 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new metrics module to support consumer metrics tracking for RocketMQ Broker by adding a ConsumerAttr struct and its associated builder.

  • Added a new file (metrics.rs) which includes the consumer_attr submodule for metrics tracking.
  • Modified the library's module exposure by including the new metrics module in lib.rs.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
rocketmq-broker/src/metrics.rs New metrics module setup with consumer_attr
rocketmq-broker/src/lib.rs Exposes the newly added metrics module
Comments suppressed due to low confidence (1)

rocketmq-broker/src/metrics.rs:17

  • Consider adding module-level documentation for 'consumer_attr' to outline its purpose and usage for metrics tracking.
mod consumer_attr;

@rocketmq-rust-robot rocketmq-rust-robot added the feature🚀 Suggest an idea for this project. label Jun 12, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (2)
rocketmq-broker/src/metrics.rs (1)

17-18: Consider tightening the module’s visibility or adding a re-export

mod consumer_attr; keeps the sub-module private to crate::metrics.
If other crates / modules are expected to use ConsumerAttr directly you either need

pub use consumer_attr::ConsumerAttr;

or to mark the sub-module pub(crate).
Decide now to avoid a follow-up public-API change.

rocketmq-broker/src/metrics/consumer_attr.rs (1)

121-142: Manual Hash impl can be replaced by #[derive(Hash)]

All four fields already implement Hash, so a custom implementation is unnecessary boilerplate and risks divergence if the struct changes.

-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, Hash)]-impl Hash for ConsumerAttr {
-    fn hash<H: Hasher>(&self, state: &mut H) {
-        self.group.hash(state);
-        self.language.hash(state);
-        self.version.hash(state);
-        self.consume_mode.hash(state);
-    }
-}
+// Custom impl no longer required
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc947f5 and f9d6826.

📒 Files selected for processing (3)
  • rocketmq-broker/src/lib.rs (1 hunks)
  • rocketmq-broker/src/metrics.rs (1 hunks)
  • rocketmq-broker/src/metrics/consumer_attr.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (macos-latest, nightly)
  • GitHub Check: auto-approve
  • GitHub Check: build (ubuntu-latest, nightly)
  • GitHub Check: build (windows-latest, nightly)
  • GitHub Check: build
  • GitHub Check: test
🔇 Additional comments (1)
rocketmq-broker/src/lib.rs (1)

42-42: Nice integration point

The new metrics module is wired into the crate root in the same style as the existing internal modules. No concerns here.

@rocketmq-rust-bot
Copy link
Collaborator

🔊@mxsm 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

Copy link

codecov bot commented Jun 12, 2025

Codecov Report

Attention: Patch coverage is 92.70073% with 20 lines in your changes missing coverage. Please review.

Project coverage is 26.09%. Comparing base (dc947f5) to head (8da749a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
rocketmq-broker/src/metrics/consumer_attr.rs 92.70% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3453      +/-   ##
==========================================
+ Coverage   25.84%   26.09%   +0.24%     
==========================================
  Files         542      543       +1     
  Lines       77055    77329     +274     
==========================================
+ Hits        19912    20176     +264     
- Misses      57143    57153      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

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

LGTM

@rocketmq-rust-bot rocketmq-rust-bot merged commit c7a05d4 into main Jun 12, 2025
18 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Jun 12, 2025
@mxsm mxsm deleted the feature-3452 branch June 14, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI review first Ai review pr first approved PR has approved auto merge feature🚀 Suggest an idea for this project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature🚀] Add ConsumerAttr struct and builder for metrics tracking
3 participants