merlimat closed pull request #1209: Fixed missing '"' sign in system metrics for Prometheus URL: https://github.com/apache/incubator-pulsar/pull/1209
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGenerator.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGenerator.java index 26118c81a..e7bcda1b0 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGenerator.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGenerator.java @@ -85,14 +85,13 @@ private static void generateSystemMetrics(SimpleTextOutputStream stream, String for (int i = 0; i < metricFamily.samples.size(); i++) { Sample sample = metricFamily.samples.get(i); stream.write(sample.name); - stream.write("{cluster=\"").write(cluster).write("\","); + stream.write("{cluster=\"").write(cluster).write('"'); for (int j = 0; j < sample.labelNames.size(); j++) { + stream.write(", "); stream.write(sample.labelNames.get(j)); stream.write("=\""); stream.write(sample.labelValues.get(j)); - if (j != sample.labelNames.size() - 1) { - stream.write("\","); - } + stream.write('"'); } stream.write("} "); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java index be19b571d..8aa6fdc2c 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java @@ -90,6 +90,11 @@ public void testPerTopicStats() throws Exception { assertEquals(cm.get(1).tags.get("topic"), "persistent://my-property/use/my-ns/my-topic1"); assertEquals(cm.get(1).tags.get("namespace"), "my-property/use/my-ns"); + cm = (List<Metric>) metrics.get("topic_load_times_count"); + assertEquals(cm.size(), 1); + assertEquals(cm.get(0).value, 2.0); + assertEquals(cm.get(0).tags.get("cluster"), "test"); + p1.close(); p2.close(); } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services