pgier commented on code in PR #18451:
URL: https://github.com/apache/pulsar/pull/18451#discussion_r1025357099


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricStreams.java:
##########
@@ -65,11 +65,19 @@ void releaseAll() {
         metricStreamMap.clear();
     }
 
-    private SimpleTextOutputStream initGaugeType(String metricName) {
+    private SimpleTextOutputStream initMetricType(String metricName) {
+        String metricTypeDef = String.format("# TYPE %s %s\n", metricName, 
metricType(metricName));
         return metricStreamMap.computeIfAbsent(metricName, s -> {
             SimpleTextOutputStream stream = new 
SimpleTextOutputStream(PulsarByteBufAllocator.DEFAULT.directBuffer());
-            stream.write("# TYPE ").write(metricName).write(" gauge\n");
+            stream.write(metricTypeDef);
             return stream;
         });
     }
+
+    private String metricType(String metricName) {
+        if (metricName.endsWith("_total")) {
+            return "counter";
+        }
+        return "gauge";
+    }

Review Comment:
   Yeah, good points, I'll split this out from the metric fix.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to