asafm commented on code in PR #18116:
URL: https://github.com/apache/pulsar/pull/18116#discussion_r1006514051


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/NamespaceStatsAggregator.java:
##########
@@ -302,22 +335,35 @@ private static void getTopicStats(Topic topic, TopicStats 
stats, boolean include
                 });
     }
 
-    private static void printDefaultBrokerStats(PrometheusMetricStreams 
stream, String cluster) {
-        // Print metrics with 0 values. This is necessary to have the 
available brokers being
+    private static void printBrokerStats(PrometheusMetricStreams stream, 
String cluster,
+                                         LongAdder brokerTopicsCount,
+                                         LongAdder brokerSubscriptionsCount,
+                                         LongAdder brokerProducersCount,
+                                         LongAdder brokerConsumersCount,
+                                         DoubleAdder brokerRateIn,
+                                         DoubleAdder brokerRateOut,
+                                         DoubleAdder brokerThroughputIn,
+                                         DoubleAdder brokerThroughputOut,
+                                         DoubleAdder brokerStorageSize,
+                                         DoubleAdder brokerStorageLogicalSize,
+                                         DoubleAdder brokerStorageWriteRate,
+                                         DoubleAdder brokerStorageReadRate,
+                                         DoubleAdder brokerMsgBacklog) {
+        // Print metrics values. This is necessary to have the available 
brokers being
         // reported in the brokers dashboard even if they don't have any topic 
or traffic
-        writeMetric(stream, "pulsar_topics_count", 0, cluster);
-        writeMetric(stream, "pulsar_subscriptions_count", 0, cluster);
-        writeMetric(stream, "pulsar_producers_count", 0, cluster);
-        writeMetric(stream, "pulsar_consumers_count", 0, cluster);
-        writeMetric(stream, "pulsar_rate_in", 0, cluster);
-        writeMetric(stream, "pulsar_rate_out", 0, cluster);
-        writeMetric(stream, "pulsar_throughput_in", 0, cluster);
-        writeMetric(stream, "pulsar_throughput_out", 0, cluster);
-        writeMetric(stream, "pulsar_storage_size", 0, cluster);
-        writeMetric(stream, "pulsar_storage_logical_size", 0, cluster);
-        writeMetric(stream, "pulsar_storage_write_rate", 0, cluster);
-        writeMetric(stream, "pulsar_storage_read_rate", 0, cluster);
-        writeMetric(stream, "pulsar_msg_backlog", 0, cluster);
+        writeMetric(stream, "pulsar_broker_topics_count", 
brokerTopicsCount.longValue(), cluster);

Review Comment:
   You're changing the original intent of the code by alerting the metric name 
at this point in the code:
   See
   ```
   // reported in the brokers dashboard even if they don't have any topic or 
traffic
   ```



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