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 2022/07/07 04:40:55 UTC

[GitHub] [pulsar] michaeljmarshall commented on a diff in pull request #13785: Bump prometheus client version from 0.5.0 to 0.15.0

michaeljmarshall commented on code in PR #13785:
URL: https://github.com/apache/pulsar/pull/13785#discussion_r915450940


##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtils.java:
##########
@@ -59,7 +59,7 @@ public static void generateSystemMetrics(SimpleTextOutputStream stream, String c
             Collector.MetricFamilySamples metricFamily = metricFamilySamples.nextElement();
 
             // Write type of metric
-            stream.write("# TYPE ").write(metricFamily.name).write(' ')
+            stream.write("# TYPE ").write(metricFamily.name + getTypeNameSuffix(metricFamily.type)).write(' ')

Review Comment:
   I think we might want to use the following:
   
   ```suggestion
               stream.write("# TYPE ").write(metricFamily.name).write(getTypeNameSuffix(metricFamily.type)).write(' ')
   ```



##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtils.java:
##########
@@ -88,19 +88,27 @@ public static void generateSystemMetrics(SimpleTextOutputStream stream, String c
         }
     }
 
+    static String getTypeNameSuffix(Collector.Type type) {
+        if (type.equals(Collector.Type.INFO)) {
+            return "_info";
+        }
+        return "";

Review Comment:
   This might be a premature optimization, but the `stream.write` method accepts null values, so it might be better not to create the empty string here.
   
   ```suggestion
           return null;
   ```



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org