Repository: jenkinsci/prometheus-plugin (java)

Issue:
metric TYPE is defined after samples still in 2.0.11
The same issue is reported in #245 #250 #314

The above closed issues seems to all show the same error. I can confirm that this is still the case in the latest available plugin `Version: 2.0.11`.

I have just installed the plugin and configured telegraf and confirm the issues are exactly as described in the above mentioned issues.

Pull request:
Possible fix for #375
Fixes #375 

### Changes proposed
Seems like the is a blank required after the comma. Unsure if that fixes the issue completely but on the first deploy on our system it worked.

### Checklist

- [ ] Includes tests covering the new functionality?
- [ ] Ready for review
- [ ] Follows CONTRIBUTING rules

### Notify

@markyjackson-taulia


Patch:
diff --git a/src/main/java/org/jenkinsci/plugins/prometheus/util/MetricsFormatter.java b/src/main/java/org/jenkinsci/plugins/prometheus/util/MetricsFormatter.java
index 36d4069..5ed0f12 100644
--- a/src/main/java/org/jenkinsci/plugins/prometheus/util/MetricsFormatter.java
+++ b/src/main/java/org/jenkinsci/plugins/prometheus/util/MetricsFormatter.java
@@ -8,8 +8,8 @@ public class MetricsFormatter {
         formatString = formatString.replaceAll("jenkins_node_(.*)_builds_count (.*)", "jenkins_node_builds_count{node=\"$1\"} $2");
 
         //node specific histograms
-        formatString = formatString.replaceAll("jenkins_node_builds\\{(.*)} (.*)", "jenkins_node_builds{node=\"master\",$1} $2");
-        formatString = formatString.replaceAll("jenkins_node_(.*)_builds\\{(.*)} (.*)", "jenkins_node_builds{node=\"$1\",$2} $3");
+        formatString = formatString.replaceAll("jenkins_node_builds\\{(.*)} (.*)", "jenkins_node_builds{node=\"master\", $1} $2");
+        formatString = formatString.replaceAll("jenkins_node_(.*)_builds\\{(.*)} (.*)", "jenkins_node_builds{node=\"$1\", $2} $3");
 
         return formatString;
     }


Test patch:
diff --git a/src/test/java/org/jenkinsci/plugins/prometheus/util/MetricsFormatterTest.java b/src/test/java/org/jenkinsci/plugins/prometheus/util/MetricsFormatterTest.java
index 62f8639..86f3d9a 100644
--- a/src/test/java/org/jenkinsci/plugins/prometheus/util/MetricsFormatterTest.java
+++ b/src/test/java/org/jenkinsci/plugins/prometheus/util/MetricsFormatterTest.java
@@ -29,7 +29,7 @@ public class MetricsFormatterTest {
         String formatString = MetricsFormatter.formatMetrics(inString);
         //master node histogram
         Assert.assertFalse(formatString.contains("jenkins_node_builds{quantile=\"0.999\",} 0.091670452\n"));
-        Assert.assertTrue(formatString.contains("jenkins_node_builds{node=\"master\",quantile=\"0.999\",} 0.091670452\n"));
+        Assert.assertTrue(formatString.contains("jenkins_node_builds{node=\"master\", quantile=\"0.999\",} 0.091670452\n"));
     }
 
     @Test
@@ -45,6 +45,6 @@ public class MetricsFormatterTest {
         String formatString = MetricsFormatter.formatMetrics(inString);
         //named node histogram
         Assert.assertFalse(formatString.contains("jenkins_node_my_node_4_builds{quantile=\"0.999\",} 0.091670452\n"));
-        Assert.assertTrue(formatString.contains("jenkins_node_builds{node=\"my_node_4\",quantile=\"0.999\",} 0.091670452\n"));
+        Assert.assertTrue(formatString.contains("jenkins_node_builds{node=\"my_node_4\", quantile=\"0.999\",} 0.091670452\n"));
     }
 }