Skip to content

Commit

Permalink
count ItemCollectionSizeLimitExceededExceptions persisting messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jkt-signal authored Sep 27, 2023
1 parent aaba95f commit 9cd21d1
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.whispersystems.textsecuregcm.storage;

import static com.codahale.metrics.MetricRegistry.name;
import static io.micrometer.core.instrument.Metrics.counter;

import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
Expand All @@ -14,6 +15,9 @@
import com.codahale.metrics.Timer;
import com.google.common.annotations.VisibleForTesting;
import io.dropwizard.lifecycle.Managed;
import io.micrometer.core.instrument.Counter;
import software.amazon.awssdk.services.dynamodb.model.ItemCollectionSizeLimitExceededException;

import java.time.Duration;
import java.time.Instant;
import java.util.List;
Expand Down Expand Up @@ -43,6 +47,7 @@ public class MessagePersister implements Managed {
private final Timer persistQueueTimer = metricRegistry.timer(name(MessagePersister.class, "persistQueue"));
private final Meter persistQueueExceptionMeter = metricRegistry.meter(
name(MessagePersister.class, "persistQueueException"));
private final Counter oversizedQueueCounter = counter(name(MessagePersister.class, "persistQueueOversized"));
private final Histogram queueCountHistogram = metricRegistry.histogram(name(MessagePersister.class, "queueCount"));
private final Histogram queueSizeHistogram = metricRegistry.histogram(name(MessagePersister.class, "queueSize"));

Expand Down Expand Up @@ -137,6 +142,9 @@ int persistNextQueues(final Instant currentTime) {
try {
persistQueue(accountUuid, deviceId);
} catch (final Exception e) {
if (e instanceof ItemCollectionSizeLimitExceededException) {
oversizedQueueCounter.increment();
}
persistQueueExceptionMeter.mark();
logger.warn("Failed to persist queue {}::{}; will schedule for retry", accountUuid, deviceId, e);

Expand Down

0 comments on commit 9cd21d1

Please sign in to comment.