Add metrics to check presence of PNI-associated registration IDs

This commit is contained in:
Jon Chambers 2023-11-28 12:09:18 -05:00 committed by Jon Chambers
parent 5f6fe4d670
commit 1da3f96d10
3 changed files with 19 additions and 1 deletions

View File

@ -60,6 +60,7 @@ import org.whispersystems.textsecuregcm.identity.AciServiceIdentifier;
import org.whispersystems.textsecuregcm.identity.ServiceIdentifier;
import org.whispersystems.textsecuregcm.limits.RateLimitedByIp;
import org.whispersystems.textsecuregcm.limits.RateLimiters;
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil;
import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.AccountsManager;
@ -87,6 +88,8 @@ public class AccountController {
private final RegistrationRecoveryPasswordsManager registrationRecoveryPasswordsManager;
private final UsernameHashZkProofVerifier usernameHashZkProofVerifier;
private static final String SET_ATTRIBUTES_COUNTER_NAME = MetricsUtil.name(AccountController.class, "setAttributes");
public AccountController(
AccountsManager accounts,
RateLimiters rateLimiters,
@ -249,6 +252,10 @@ public class AccountController {
// if registration recovery password was sent to us, store it (or refresh its expiration)
attributes.recoveryPassword().ifPresent(registrationRecoveryPassword ->
registrationRecoveryPasswordsManager.storeForCurrentNumber(updatedAccount.getNumber(), registrationRecoveryPassword));
Metrics.counter(SET_ATTRIBUTES_COUNTER_NAME,
"pniRegistrationIdPresent", String.valueOf(attributes.getPhoneNumberIdentityRegistrationId().isPresent()))
.increment();
}
@GET

View File

@ -8,6 +8,8 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.net.HttpHeaders;
import io.dropwizard.auth.Auth;
import io.lettuce.core.SetArgs;
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.Tags;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.headers.Header;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
@ -59,6 +61,7 @@ import org.whispersystems.textsecuregcm.entities.LinkDeviceRequest;
import org.whispersystems.textsecuregcm.entities.PreKeySignatureValidator;
import org.whispersystems.textsecuregcm.identity.IdentityType;
import org.whispersystems.textsecuregcm.limits.RateLimiters;
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.AccountsManager;
@ -86,6 +89,8 @@ public class DeviceController {
private final Clock clock;
private static final String LINK_DEVICE_COUNTER_NAME = MetricsUtil.name(DeviceController.class, "linkDevice");
private static final String VERIFICATION_TOKEN_ALGORITHM = "HmacSHA256";
@VisibleForTesting
@ -444,6 +449,10 @@ public class DeviceController {
connection.sync().set(getUsedTokenKey(verificationCode), "", new SetArgs().ex(TOKEN_EXPIRATION_DURATION)));
}
Metrics.counter(LINK_DEVICE_COUNTER_NAME,
"pniRegistrationIdPresent", String.valueOf(accountAttributes.getPhoneNumberIdentityRegistrationId().isPresent()))
.increment();
return new Pair<>(updatedAccount, device);
}

View File

@ -279,7 +279,7 @@ public class AccountsManager {
clientPresenceManager.disconnectAllPresencesForUuid(actualUuid);
}
final Tags tags;
Tags tags;
if (freshUser) {
tags = Tags.of("type", maybeRecentlyDeletedAccountIdentifier.isPresent() ? "recently-deleted" : "new");
@ -287,6 +287,8 @@ public class AccountsManager {
tags = Tags.of("type", "re-registration");
}
tags = tags.and("pniRegistrationIdPresent", String.valueOf(accountAttributes.getPhoneNumberIdentityRegistrationId().isPresent()));
Metrics.counter(CREATE_COUNTER_NAME, tags).increment();
accountAttributes.recoveryPassword().ifPresent(registrationRecoveryPassword ->