sijie commented on a change in pull request #5605: fix prometheusMetrics export 
contains " bug
URL: https://github.com/apache/pulsar/pull/5605#discussion_r344602492
 
 

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGenerator.java
 ##########
 @@ -95,10 +95,17 @@ 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.startsWith("\"") ||
 
 Review comment:
   I don't think we need to check `startsWith` and `endsWith`.
   
   We can just simplify the logic as follows:
   
   ```
   if (labelValue != null) {
       labelValue = labelValue.replace("\"", "\\\"");
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

Reply via email to