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.

----


---

Reply via email to