You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/11/11 08:34:31 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #5605: fix prometheusMetrics export contains " bug

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:
users@infra.apache.org


With regards,
Apache Git Services