Increment a counter for timeouts rather than logging the full exception

This commit is contained in:
Jon Chambers authored and Jon Chambers committed 2026-07-09 09:49:32 -04:00
1 parent fdaba751bd
commit 75532b307c
1 file changed
+11 -4
@@ -61,6 +61,9 @@ public class MessagesManager {
private static final String PRESENCE_MATCH_COUNTER_NAME =
MetricsUtil.name(MessagesManager.class, "presenceMatch");
private static final Counter INSERT_TIMEOUT_COUNTER =
Metrics.counter(name(MessagesManager.class, "insertTimeout"));
@VisibleForTesting
static final String MIRROR_INSERTS_EXPERIMENT_NAME = "foundationDbMirrorInserts";
@@ -132,10 +135,14 @@ public class MessagesManager {
foundationDbMessageStore.insert(new AciServiceIdentifier(accountIdentifier), minimizedMessagesByDeviceId)
.orTimeout(FOUNDATIONDB_INSERT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)
.exceptionally(e -> {
logger.warn("Failed to insert {} message(s) for {} into FoundationDB",
minimizedMessagesByDeviceId.size(),
accountIdentifier,
e);
if (e instanceof TimeoutException) {
INSERT_TIMEOUT_COUNTER.increment();
} else {
logger.warn("Failed to insert {} message(s) for {} into FoundationDB",
minimizedMessagesByDeviceId.size(),
accountIdentifier,
e);
}
return Collections.emptyMap();
});