diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticator.java b/service/src/main/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticator.java index d8f15f6aa..b59f4c927 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticator.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticator.java @@ -16,6 +16,8 @@ */ package org.whispersystems.textsecuregcm.auth; +import io.micrometer.core.instrument.Metrics; +import org.apache.http.auth.AUTH; import org.whispersystems.textsecuregcm.storage.Account; import org.whispersystems.textsecuregcm.storage.AccountsManager; @@ -24,15 +26,25 @@ import java.util.Optional; import io.dropwizard.auth.Authenticator; import io.dropwizard.auth.basic.BasicCredentials; +import static com.codahale.metrics.MetricRegistry.name; + public class AccountAuthenticator extends BaseAccountAuthenticator implements Authenticator { + private static final String AUTHENTICATION_COUNTER_NAME = name(AccountAuthenticator.class, "authenticate"); + private static final String GV2_CAPABLE_TAG_NAME = "gv2"; + public AccountAuthenticator(AccountsManager accountsManager) { super(accountsManager); } @Override public Optional authenticate(BasicCredentials basicCredentials) { - return super.authenticate(basicCredentials, true); + final Optional maybeAccount = super.authenticate(basicCredentials, true); + + // TODO Remove this temporary counter after the GV2 rollout is underway + maybeAccount.ifPresent(account -> Metrics.counter(AUTHENTICATION_COUNTER_NAME, GV2_CAPABLE_TAG_NAME, String.valueOf(account.isGroupsV2Supported())).increment()); + + return maybeAccount; } }