diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java index 9b349bd64..5a85c0fd2 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java @@ -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 diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java index 5cdab7484..29f366b24 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java @@ -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); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java index 624e394fa..18e0381ad 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java @@ -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 ->