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 2021/09/08 14:05:00 UTC

[GitHub] [pulsar] megfigura commented on issue #10495: msgDropRate metric is not available through non-deprecated Java interface, CLI, or Pulsar Manager

megfigura commented on issue #10495:
URL: https://github.com/apache/pulsar/issues/10495#issuecomment-915269613


   Thanks @MarvinCai,
   
   The new behavior in 2.8.1 is much better. At least as far as I can tell, it still requires a type cast, but that's not so bad. This code is working:
   ```java
   String topicName = "non-persistent://public/default/my_topic";
   TopicStats topicStats = admin.topics().getStats(topicName);
   SubscriptionStats subStats = stats.getSubscriptions().get("drop_test");
   double dropRate = 0.0;
   if (subStats instanceof NonPersistentSubscriptionStats)
   {
       NonPersistentSubscriptionStats npSubStats = (NonPersistentSubscriptionStats)subStats;
       dropRate = npSubStats.getMsgDropRate();
   }
   ```
   
   This beats my previous work-around in 2.7.1 (which no longer worked in 2.8.0):
   ```java
   String topicName = "non-persistent://public/default/my_topic";
   TopicStats topicStats;
   if (topicName.startsWith("non-persistent")
   {
       topicStats = admin.nonPersistentTopics().getStats(topicName);
   }
   else
   {
       topicStats = admin.topics().getStats(topicName);
   }
   
   double dropRate = 0.0;
   if (topicStats instanceof NonPersistentTopicStats)
   {
       NonPersistentTopicStats npTopicStats = (NonPersistentTopicStats)topicStats;
       dropRate = npTopicStats.getSubscriptions().get("drop_test").getMsgDropRate();
   }
   ```


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