[ https://issues.apache.org/jira/browse/KAFKA-5987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16184796#comment-16184796 ]
ASF GitHub Bot commented on KAFKA-5987: --------------------------------------- GitHub user rhauch opened a pull request: https://github.com/apache/kafka/pull/3985 KAFKA-5987: Maintain order of metric tags in generated documentation The `MetricNameTemplate` is changed to used a `LinkedHashSet` to maintain the same order of the tags that are passed in. This tag order is then maintained when `Metrics.toHtmlTable` generates the MBean names for each of the metrics. The `SenderMetricsRegistry` and `FetcherMetricsRegistry` both contain templates used in the producer and consumer, respectively, and these were changed to use a `LinkedHashSet` to maintain the order of the tags. Before this change, the generated HTML documentation might use MBean names like the following and order them: ``` kafka.connect:type=sink-task-metrics,connector={connector},partition={partition},task={task},topic={topic} kafka.connect:type=sink-task-metrics,connector={connector},task={task} ``` However, after this change, the documentation would use the following order: ``` kafka.connect:type=sink-task-metrics,connector={connector},task={task} kafka.connect:type=sink-task-metrics,connector={connector},task={task},topic={topic},partition={partition} ``` This is more readable as the code that is creating the templates has control over the order of the tags. Note that JMX MBean names use ObjectName that does not maintain order of the properties (tags), so this change should have no impact on the actual JMX MBean names used in the metrics. cc @wushujames You can merge this pull request into a Git repository by running: $ git pull https://github.com/rhauch/kafka kafka-5987 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/3985.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3985 ---- commit e5379c999b03b1a10d3779e21659f4a7808dc53c Author: Randall Hauch <rha...@gmail.com> Date: 2017-09-28T20:07:34Z KAFKA-5987 Maintain order of metric tags in generated documentation The `MetricNameTemplate` is changed to used a `LinkedHashSet` to maintain the same order of the tags that are passed in. This tag order is then maintained when `Metrics.toHtmlTable` generates the MBean names for each of the metrics. The `SenderMetricsRegistry` and `FetcherMetricsRegistry` both contain templates used in the producer and consumer, respectively, and these were changed to use a `LinkedHashSet` to maintain the order of the tags. ---- > Kafka metrics templates used in document generation should maintain order of > tags > --------------------------------------------------------------------------------- > > Key: KAFKA-5987 > URL: https://issues.apache.org/jira/browse/KAFKA-5987 > Project: Kafka > Issue Type: Improvement > Components: clients > Affects Versions: 1.0.0 > Reporter: Randall Hauch > Assignee: Randall Hauch > Fix For: 1.0.0 > > > KAFKA-5191 recently added a new {{MetricNameTemplate}} that is used to create > the {{MetricName}} objects in the producer and consumer, as we as in the > newly-added generation of metric documentation. The {{MetricNameTemplate}} > and the {{Metric.toHtmlTable}} do not maintain the order of the tags, which > means the resulting HTML documentation will order the table of MBean > attributes based upon the lexicographical ordering of the MBeans, each of > which uses the lexicographical ordering of its tags. This can result in the > following order: > {noformat} > kafka.connect:type=sink-task-metrics,connector={connector},partition={partition},task={task},topic={topic} > kafka.connect:type=sink-task-metrics,connector={connector},task={task} > {noformat} > However, if the MBeans maintained the order of the tags then the > documentation would use the following order: > {noformat} > kafka.connect:type=sink-task-metrics,connector={connector},task={task} > kafka.connect:type=sink-task-metrics,connector={connector},task={task},topic={topic},partition={partition} > {noformat} > This would be more readable, and the code that is creating the templates > would have control over the order of the tags. > To maintain order, {{MetricNameTemplate}} should used a {{LinkedHashSet}} for > the tags, and the {{Metrics.toHtmlTable}} method should also use a > {{LinkedHashMap}} when building up the tags used in the MBean name. > Note that JMX MBean names use {{ObjectName}} that does not maintain order, so > this change should have no impact on JMX MBean names. -- This message was sent by Atlassian JIRA (v6.4.14#64029)