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 658ea79af..8a9f088c4 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/MessagesCache.java @@ -82,6 +82,7 @@ public class MessagesCache extends RedisClusterPubSubAdapter imp private final Timer insertTimer = Metrics.timer(name(MessagesCache.class, "insert")); private final Timer getMessagesTimer = Metrics.timer(name(MessagesCache.class, "get")); private final Timer getQueuesToPersistTimer = Metrics.timer(name(MessagesCache.class, "getQueuesToPersist")); + private final Timer removeByGuidTimer = Metrics.timer(name(MessagesCache.class, "removeByGuid")); private final Timer clearQueueTimer = Metrics.timer(name(MessagesCache.class, "clear")); private final Counter pubSubMessageCounter = Metrics.counter(name(MessagesCache.class, "pubSubMessage")); private final Counter newMessageNotificationCounter = Metrics.counter( @@ -185,6 +186,8 @@ public CompletableFuture> remove(final UUID destina final byte destinationDevice, final List messageGuids) { + final Timer.Sample sample = Timer.start(); + return removeByGuidScript.executeBinaryAsync(List.of(getMessageQueueKey(destinationUuid, destinationDevice), getMessageQueueMetadataKey(destinationUuid, destinationDevice), getQueueIndexKey(destinationUuid, destinationDevice)), @@ -204,7 +207,8 @@ public CompletableFuture> remove(final UUID destina } return removedMessages; - }, messageDeletionExecutorService); + }, messageDeletionExecutorService) + .whenComplete((ignored, throwable) -> sample.stop(removeByGuidTimer)); } public boolean hasMessages(final UUID destinationUuid, final byte destinationDevice) {