From 0595acc48f13cb67c5789b653a439562d366b1c9 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Thu, 13 Mar 2025 11:47:39 -0400 Subject: [PATCH] Add a counter for messages removed from the message cache --- .../textsecuregcm/storage/MessagesCache.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java index b446fd3de..109235b0f 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java @@ -134,6 +134,7 @@ public class MessagesCache { private final Timer removeByGuidTimer = Metrics.timer(name(MessagesCache.class, "removeByGuid")); private final Timer removeRecipientViewTimer = Metrics.timer(name(MessagesCache.class, "removeRecipientView")); private final Timer clearQueueTimer = Metrics.timer(name(MessagesCache.class, "clear")); + private final Counter removeMessageCounter = Metrics.counter(name(MessagesCache.class, "remove")); private final Counter staleEphemeralMessagesCounter = Metrics.counter( name(MessagesCache.class, "staleEphemeralMessages")); private final Counter staleMrmMessagesCounter = Metrics.counter(name(MessagesCache.class, "staleMrmMessages")); @@ -273,7 +274,13 @@ public class MessagesCache { (serviceId, keysToUpdate) -> removeRecipientViewFromMrmData(keysToUpdate, serviceId, destinationDevice)); return removedMessages; - }, messageDeletionExecutorService).whenComplete((ignored, throwable) -> sample.stop(removeByGuidTimer)); + }, messageDeletionExecutorService).whenComplete((removedMessages, throwable) -> { + if (removedMessages != null) { + removeMessageCounter.increment(removedMessages.size()); + } + + sample.stop(removeByGuidTimer); + }); }