Skip to content

Commit

Permalink
fix prometheusMetrics export contains " bug (apache#5605)
Browse files Browse the repository at this point in the history
when i use Oracle JDK 10.0.2,the broker metrics `jvm_info` will export as follow: 
```
# TYPE jvm_info gauge
jvm_info{cluster="pulsar-cluster-zk",version="10.0.2+13",vendor=""Oracle Corporation"",runtime="Java(TM) SE Runtime Environment"} 1.0
```
and then prometheus will failed when parsing `""Oracle Corporation""`
![image](https://user-images.githubusercontent.com/5436568/68560255-41398a80-047b-11ea-9fcb-b79d748a353d.png)


The Reason is when using `io.prometheus:simpleclient:0.5.0` to collect jvm info, it returns jvm vendor with `"Oracle Corporation"`, and in the Pulsar source code, it adds `"` in both sides, so it comming with `vendor=""Oracle Corporation""`, and prometheus parse failed.
  • Loading branch information
hangc0276 authored and sijie committed Nov 13, 2019
1 parent 1ab1ffd commit aeca8fe
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ private static void generateSystemMetrics(SimpleTextOutputStream stream, String
stream.write(sample.name);
stream.write("{cluster=\"").write(cluster).write('"');
for (int j = 0; j < sample.labelNames.size(); j++) {
String labelValue = sample.labelValues.get(j);
if (labelValue != null) {
labelValue = labelValue.replace("\"", "\\\"");
}

stream.write(",");
stream.write(sample.labelNames.get(j));
stream.write("=\"");
stream.write(sample.labelValues.get(j));
stream.write(labelValue);
stream.write('"');
}

Expand Down

0 comments on commit aeca8fe

Please sign in to comment.