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/11/04 01:42:00 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #12523: add a metric to get earliest time in the backlog

codelipenghui commented on a change in pull request #12523:
URL: https://github.com/apache/pulsar/pull/12523#discussion_r742460181



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java
##########
@@ -1065,6 +1066,12 @@ public SubscriptionStatsImpl getStats(Boolean getPreciseBacklog, boolean subscri
             subStats.backlogSize = ((ManagedLedgerImpl) topic.getManagedLedger())
                     .getEstimatedBacklogSize((PositionImpl) cursor.getMarkDeletedPosition());
         }
+        if (getEarliestTimeInBacklog && subStats.msgBacklog > 0) {
+            ManagedLedgerImpl managedLedger = ((ManagedLedgerImpl) cursor.getManagedLedger());
+            PositionImpl markDeletedPosition = (PositionImpl) cursor.getMarkDeletedPosition();
+            long result = managedLedger.getEarliestMessagePublishTimeOfPos(markDeletedPosition);
+            subStats.timeBacklogInMills = result == 0 ? 0 : System.currentTimeMillis() - result;

Review comment:
       @hangc0276 yes, it looks like a time-based lag.

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java
##########
@@ -1065,6 +1066,12 @@ public SubscriptionStatsImpl getStats(Boolean getPreciseBacklog, boolean subscri
             subStats.backlogSize = ((ManagedLedgerImpl) topic.getManagedLedger())
                     .getEstimatedBacklogSize((PositionImpl) cursor.getMarkDeletedPosition());
         }
+        if (getEarliestTimeInBacklog && subStats.msgBacklog > 0) {
+            ManagedLedgerImpl managedLedger = ((ManagedLedgerImpl) cursor.getManagedLedger());
+            PositionImpl markDeletedPosition = (PositionImpl) cursor.getMarkDeletedPosition();
+            long result = managedLedger.getEarliestMessagePublishTimeOfPos(markDeletedPosition);
+            subStats.timeBacklogInMills = result == 0 ? 0 : System.currentTimeMillis() - result;

Review comment:
       @hangc0276 yes, it looks like a time-based lag.




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