frankxieke commented on a change in pull request #11555:
URL: https://github.com/apache/pulsar/pull/11555#discussion_r687423917



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGenerator.java
##########
@@ -125,6 +135,24 @@ public static void generate(PulsarService pulsar, boolean 
includeTopicMetrics, b
         }
     }
 
+    private static void generateLedgerOffloaderMetrics(PulsarService pulsar, 
SimpleTextOutputStream stream) {
+        pulsar.getBrokerService().getTopics().keys().stream()
+                .filter(topic -> 
topic.startsWith(TopicDomain.persistent.value())).forEach(topic -> {
+            try {
+                ManagedLedgerConfig managedLedgerConfig = 
pulsar.getBrokerService()
+                        .getManagedLedgerConfig(TopicName.get(topic)).get();
+                LedgerOffloader ledgerOffloader = 
managedLedgerConfig.getLedgerOffloader();
+                if (ledgerOffloader != NullLedgerOffloader.INSTANCE && 
ledgerOffloader.getStats() != null) {
+                    String clusterName = 
pulsar.getConfiguration().getClusterName();
+                    List<Metrics> metrics = new LedgerOffloaderMetrics(pulsar, 
ledgerOffloader).generate();
+                    parseMetricsToPrometheusMetrics(metrics, clusterName, 
Collector.Type.GAUGE, stream);
+                }
+            } catch (Exception ex) {
+                log.error("generate ledger offloader metrics error", ex);
+            }
+        });
+    }

Review comment:
       Yes, i found other method to calculate if a topic is  persistent topic. 
Please  have to look.




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