Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-5987

Kafka metrics templates used in document generation should maintain order of tags

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 1.0.0
    • 1.0.1, 1.1.0, 2.0.0
    • clients
    • None

    Description

      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:

      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, if the MBeans maintained the order of the tags then 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 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.

      Attachments

        Activity

          People

            rhauch Randall Hauch
            rhauch Randall Hauch
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: