static List<RawMetric> constructMetricsList(ObjectName jmxMetric,
                                              MBeanAttributeInfo[] attributes,
                                              Object[] attrValues) {
    String domain = fixIllegalChars(jmxMetric.getDomain());
    LinkedHashMap<String, String> labels = getLabelsMap(jmxMetric);
    String firstLabel = labels.keySet().iterator().next();
    String firstLabelValue = fixIllegalChars(labels.get(firstLabel));
    labels.remove(firstLabel); //removing first label since it's value will be in name

    List<RawMetric> result = new ArrayList<>(attributes.length);
    for (int i = 0; i < attributes.length; i++) {
      String attrName = fixIllegalChars(attributes[i].getName());
      convertNumericValue(attrValues[i]).ifPresent(convertedValue -> {
        String name = String.format("%s_%s_%s", domain, firstLabelValue, attrName);
        var metric = RawMetric.create(name, labels, convertedValue);
        result.add(metric);
      });
    }
    return result;
  }
@Test
  void convertsJmxMetricsAccordingToJmxExporterFormat() throws Exception {
    List<RawMetric> metrics = JmxMetricsFormatter.constructMetricsList(
        new ObjectName(
            "kafka.server:type=Some.BrokerTopic-Metrics,name=BytesOutPer-Sec,topic=test,some-lbl=123"),
        new MBeanAttributeInfo[] {
            createMbeanInfo("FifteenMinuteRate"),
            createMbeanInfo("Mean"),
            createMbeanInfo("Calls-count"),
            createMbeanInfo("SkipValue"),
        },
        new Object[] {
            123.0,
            100.0,
            10L,
            "string values not supported"
        }
    );

    Assertions.assertThat(metrics).hasSize(3);

    assertMetricsEqual(
        RawMetric.create(
            "kafka_server_Some_BrokerTopic_Metrics_FifteenMinuteRate",
            Map.of("name", "BytesOutPer-Sec", "topic", "test",  "some_lbl", "123"),
            BigDecimal.valueOf(123.0)
        ),
        metrics.get(0)
    );

    assertMetricsEqual(
        RawMetric.create(
            "kafka_server_Some_BrokerTopic_Metrics_Mean",
            Map.of("name", "BytesOutPer-Sec", "topic", "test", "some_lbl", "123"),
            BigDecimal.valueOf(100.0)
        ),
        metrics.get(1)
    );

    assertMetricsEqual(
        RawMetric.create(
            "kafka_server_Some_BrokerTopic_Metrics_Calls_count",
            Map.of("name", "BytesOutPer-Sec", "topic", "test", "some_lbl", "123"),
            BigDecimal.valueOf(10)
        ),
        metrics.get(2)
    );
  }