From 22dccaeddb8c66ee513bad2203a3c0e78f88016c Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Wed, 8 Dec 2021 12:14:57 -0500 Subject: [PATCH] Count cases where we can find a given account, but not the given profile version --- .../textsecuregcm/controllers/ProfileController.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java index bbae991d4..9ab389666 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java @@ -43,6 +43,8 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import io.micrometer.core.instrument.Counter; +import io.micrometer.core.instrument.Metrics; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Hex; @@ -85,6 +87,8 @@ import org.whispersystems.textsecuregcm.util.Pair; import software.amazon.awssdk.services.s3.S3Client; import software.amazon.awssdk.services.s3.model.DeleteObjectRequest; +import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name; + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @Path("/v1/profile") public class ProfileController { @@ -109,6 +113,8 @@ public class ProfileController { private static final String PROFILE_KEY_CREDENTIAL_TYPE = "profileKey"; private static final String PNI_CREDENTIAL_TYPE = "pni"; + private static final Counter VERSION_NOT_FOUND_COUNTER = Metrics.counter(name(ProfileController.class, "versionNotFound")); + public ProfileController( Clock clock, RateLimiters rateLimiters, @@ -318,6 +324,11 @@ public class ProfileController { final Optional maybeProfile = profilesManager.get(account.getUuid(), version); + if (maybeProfile.isEmpty()) { + // Hypothesis: this should basically never happen since clients can't delete versions + VERSION_NOT_FOUND_COUNTER.increment(); + } + final String name = maybeProfile.map(VersionedProfile::getName).orElse(null); final String about = maybeProfile.map(VersionedProfile::getAbout).orElse(null); final String aboutEmoji = maybeProfile.map(VersionedProfile::getAboutEmoji).orElse(null);