Skip to content

[TEST] check tags order#21933

Open
chia7712 wants to merge 2 commits intoapache:trunkfrom
chia7712:check_order
Open

[TEST] check tags order#21933
chia7712 wants to merge 2 commits intoapache:trunkfrom
chia7712:check_order

Conversation

@chia7712
Copy link
Copy Markdown
Member

@chia7712 chia7712 commented Apr 2, 2026

Since we aren't on Java 21 yet, I'm falling back to LinkedHashMap. Let's
see how much this smells :)

@github-actions github-actions bot added core Kafka Broker small Small PRs labels Apr 2, 2026
String name, Map<String, String> tags) {
if (tags.size() > 1 && !(tags instanceof LinkedHashMap<String, String>))
throw new RuntimeException("Tags must be of type LinkedHashMap. tags: " + tags + " type: " + tags.getClass().getName());
StringBuilder nameBuilder = new StringBuilder(100);
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.

Thanks for the experiment — it’s useful for surfacing assumptions around tag map ordering.

Two suggestions if this moves toward something mergeable:

Call-site compatibility: explicitMetricName accepts a Map<String, String>, but a strict instanceof LinkedHashMap check would fail for existing multi-tag call sites that use other Map implementations. For example, some partition-scoped meters build tags with Map.of("topic", ..., "partition", ...), and other paths use HashMap-backed tags. Those callers would either need to be migrated first, or the method would need to normalize the tag order internally instead of enforcing a concrete map type.

Exception type: if we do want to reject invalid inputs here, IllegalArgumentException would be clearer than a bare RuntimeException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Kafka Broker small Small PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants