KAFKA-20368: Use LinkedHashMap for deterministic metric tags order in RLMExpirationTask#21931
Open
cychiu8 wants to merge 2 commits intoapache:trunkfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes RemoteLogManager’s per-partition retention metrics produce deterministic JMX MBean tag ordering by constructing the tag map via MetricsUtils.getTags (which preserves insertion order), and updates tests to match the new stable tag order and validate metric cleanup on task cancellation.
Changes:
- Switch
RLMExpirationTaskmetric tag creation toMetricsUtils.getTags(...)for deterministic tag iteration order. - Update JMX metric name expectations in
RemoteLogManagerTestto match the stabletopic,partitionorder. - Extend the task-cancellation metrics test to assert the metrics are actually deregistered from the Yammer registry.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java | Uses MetricsUtils.getTags to build ordered metricTags for retention gauges in RLMExpirationTask. |
| storage/src/test/java/org/apache/kafka/server/log/remote/storage/RemoteLogManagerTest.java | Adjusts expected JMX suffix ordering for retention metrics and adds assertions that cancellation deregisters them. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
nileshkumar3
approved these changes
Apr 2, 2026
Contributor
nileshkumar3
left a comment
There was a problem hiding this comment.
LGTM. Using deterministic tag ordering here makes sense, and the JMX metric name assertions are updated consistently with the new tag order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary: use
MetricsUtils.getTagsto handle metricTags in RLMExpirationTask.