Skip to content

Commit

Permalink
Add timer to removeByGuid script
Browse files Browse the repository at this point in the history
  • Loading branch information
eager-signal authored and jon-signal committed Sep 3, 2024
1 parent 0b75240 commit d78c837
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class MessagesCache extends RedisClusterPubSubAdapter<String, String> 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(
Expand Down Expand Up @@ -185,6 +186,8 @@ public CompletableFuture<List<MessageProtos.Envelope>> remove(final UUID destina
final byte destinationDevice,
final List<UUID> messageGuids) {

final Timer.Sample sample = Timer.start();

return removeByGuidScript.executeBinaryAsync(List.of(getMessageQueueKey(destinationUuid, destinationDevice),
getMessageQueueMetadataKey(destinationUuid, destinationDevice),
getQueueIndexKey(destinationUuid, destinationDevice)),
Expand All @@ -204,7 +207,8 @@ public CompletableFuture<List<MessageProtos.Envelope>> remove(final UUID destina
}

return removedMessages;
}, messageDeletionExecutorService);
}, messageDeletionExecutorService)
.whenComplete((ignored, throwable) -> sample.stop(removeByGuidTimer));
}

public boolean hasMessages(final UUID destinationUuid, final byte destinationDevice) {
Expand Down

0 comments on commit d78c837

Please sign in to comment.