[ https://issues.apache.org/jira/browse/KAFKA-7734?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16721658#comment-16721658 ]
John Roesler commented on KAFKA-7734: ------------------------------------- [~guozhang], I've already made this comment on the PR, but it seems more manageable to establish a contract that says that the MetricName will always contain the tags in alphanumeric order. This could be implemented more easily, simply by storing the tags in a TreeMap in MetricName, and wouldn't require any other changes to the code, or incur future maintenence costs. WDYT? > Metrics tags should use LinkedHashMap to guarantee ordering > ----------------------------------------------------------- > > Key: KAFKA-7734 > URL: https://issues.apache.org/jira/browse/KAFKA-7734 > Project: Kafka > Issue Type: Improvement > Components: metrics > Reporter: Guozhang Wang > Assignee: lambdaliu > Priority: Major > > Today we store metrics tags inside MetricName from various places, and many > of them are using `HashMap`. However, for metrics reporters like JMXReporter, > the mBeanName is constructed by looping over `metricName.tags().entrySet()` > which does not guarantee ordering. This resulted a few places where the > mBeanName string not as expected, e.g. we document the Streams cache metrics > as > {code} > kafka.streams:type=stream-record-cache-metrics,client-id=([-.\w]+),task-id=([-.\w]+),record-cache-id=([-.\w]+) > {code} > However, what I've seen from JMXReporter is, for example: > {code} > kafka.streams:type=stream-record-cache-metrics,record-cache-id=all,client-id=streams-saak-test-client-StreamThread-1,task-id=1_3 > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)