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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/NamespaceStatsAggregator.java:
##########
@@ -44,62 +51,65 @@
 @Slf4j
 public class NamespaceStatsAggregator {
 
-    private static FastThreadLocal<AggregatedNamespaceStats> 
localNamespaceStats =
-            new FastThreadLocal<AggregatedNamespaceStats>() {
+    private static final FastThreadLocal<AggregatedNamespaceStats> 
localNamespaceStats =
+            new FastThreadLocal<>() {
                 @Override
-                protected AggregatedNamespaceStats initialValue() throws 
Exception {
+                protected AggregatedNamespaceStats initialValue() {
                     return new AggregatedNamespaceStats();
                 }
             };
 
-    private static FastThreadLocal<TopicStats> localTopicStats = new 
FastThreadLocal<TopicStats>() {
+    private static final FastThreadLocal<TopicStats> localTopicStats = new 
FastThreadLocal<>() {
         @Override
-        protected TopicStats initialValue() throws Exception {
+        protected TopicStats initialValue() {
             return new TopicStats();
         }
     };
 
     public static void generate(PulsarService pulsar, boolean 
includeTopicMetrics, boolean includeConsumerMetrics,
-           boolean includeProducerMetrics, boolean 
splitTopicAndPartitionIndexLabel, SimpleTextOutputStream stream) {
+                                boolean includeProducerMetrics, boolean 
splitTopicAndPartitionIndexLabel,
+                                SimpleTextOutputStream stream) {
         String cluster = pulsar.getConfiguration().getClusterName();
         AggregatedNamespaceStats namespaceStats = localNamespaceStats.get();
-        TopicStats.resetTypes();
         TopicStats topicStats = localTopicStats.get();
-
-        printDefaultBrokerStats(stream, cluster);
-
         Optional<CompactorMXBean> compactorMXBean = getCompactorMXBean(pulsar);
         LongAdder topicsCount = new LongAdder();
+        Map<String, ByteBuf> allMetrics = new HashMap<>();

Review Comment:
   @marksilcox Yes, you are correct. Maybe add `getByteBuf()` to 
`SimpleTextOutputStream` and then flush it and then release. Another option is 
keeping another map to ByteBuf, but I'm not sure it's so elegant.



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