Count cases where we can find a given account, but not the given profile version
This commit is contained in:
parent
e611a70ba4
commit
22dccaeddb
|
@ -43,6 +43,8 @@ import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.Response.Status;
|
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.DecoderException;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.codec.binary.Hex;
|
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.S3Client;
|
||||||
import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
|
import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
|
||||||
|
|
||||||
|
import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name;
|
||||||
|
|
||||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||||
@Path("/v1/profile")
|
@Path("/v1/profile")
|
||||||
public class ProfileController {
|
public class ProfileController {
|
||||||
|
@ -109,6 +113,8 @@ public class ProfileController {
|
||||||
private static final String PROFILE_KEY_CREDENTIAL_TYPE = "profileKey";
|
private static final String PROFILE_KEY_CREDENTIAL_TYPE = "profileKey";
|
||||||
private static final String PNI_CREDENTIAL_TYPE = "pni";
|
private static final String PNI_CREDENTIAL_TYPE = "pni";
|
||||||
|
|
||||||
|
private static final Counter VERSION_NOT_FOUND_COUNTER = Metrics.counter(name(ProfileController.class, "versionNotFound"));
|
||||||
|
|
||||||
public ProfileController(
|
public ProfileController(
|
||||||
Clock clock,
|
Clock clock,
|
||||||
RateLimiters rateLimiters,
|
RateLimiters rateLimiters,
|
||||||
|
@ -318,6 +324,11 @@ public class ProfileController {
|
||||||
|
|
||||||
final Optional<VersionedProfile> maybeProfile = profilesManager.get(account.getUuid(), version);
|
final Optional<VersionedProfile> 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 name = maybeProfile.map(VersionedProfile::getName).orElse(null);
|
||||||
final String about = maybeProfile.map(VersionedProfile::getAbout).orElse(null);
|
final String about = maybeProfile.map(VersionedProfile::getAbout).orElse(null);
|
||||||
final String aboutEmoji = maybeProfile.map(VersionedProfile::getAboutEmoji).orElse(null);
|
final String aboutEmoji = maybeProfile.map(VersionedProfile::getAboutEmoji).orElse(null);
|
||||||
|
|
Loading…
Reference in New Issue