Skip to content

Commit 25f57ff

Browse files
zjxxzjwangzjxxzjwang
andauthored
[improve][broker]Add the expired message count metric from this subscription within the last interval. (#24106)
Co-authored-by: zjxxzjwang <[email protected]>
1 parent ed28c21 commit 25f57ff

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ public double getMessageExpiryRate() {
173173
return msgExpired.getRate();
174174
}
175175

176+
public long getMessageExpiryCount() {
177+
return msgExpired.getCount();
178+
}
179+
176180
public long getTotalMessageExpired() {
177181
return totalMsgExpired.sum();
178182
}

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,7 @@ public CompletableFuture<SubscriptionStatsImpl> getStatsAsync(GetStatsOptions ge
13481348
}
13491349
subStats.msgBacklogNoDelayed = subStats.msgBacklog - subStats.msgDelayed;
13501350
subStats.msgRateExpired = expiryMonitor.getMessageExpiryRate();
1351+
subStats.msgExpired = expiryMonitor.getMessageExpiryCount();
13511352
subStats.totalMsgExpired = expiryMonitor.getTotalMessageExpired();
13521353
subStats.isReplicated = isReplicated();
13531354
subStats.subscriptionProperties = subscriptionProperties;

pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/SubscriptionStatsImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ public class SubscriptionStatsImpl implements SubscriptionStats {
9393
/** Total rate of messages expired on this subscription (msg/s). */
9494
public double msgRateExpired;
9595

96+
/** The count of expired messages on this subscription. */
97+
public long msgExpired;
98+
9699
/** Total messages expired on this subscription. */
97100
public long totalMsgExpired;
98101

@@ -209,6 +212,7 @@ public void reset() {
209212
unackedMessages = 0;
210213
type = null;
211214
msgRateExpired = 0;
215+
msgExpired = 0;
212216
totalMsgExpired = 0;
213217
lastExpireTimestamp = 0L;
214218
lastMarkDeleteAdvancedTimestamp = 0L;
@@ -254,6 +258,7 @@ public SubscriptionStatsImpl add(SubscriptionStatsImpl stats) {
254258
this.unackedMessages += stats.unackedMessages;
255259
this.type = stats.type;
256260
this.msgRateExpired += stats.msgRateExpired;
261+
this.msgExpired += stats.msgExpired;
257262
this.totalMsgExpired += stats.totalMsgExpired;
258263
this.isReplicated |= stats.isReplicated;
259264
this.isDurable |= stats.isDurable;

0 commit comments

Comments
 (0)