Record the number of authentications for users with/without GV2 support.
This commit is contained in:
parent
83f9eacac4
commit
b134a69a28
|
@ -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<BasicCredentials, Account> {
|
||||
|
||||
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<Account> authenticate(BasicCredentials basicCredentials) {
|
||||
return super.authenticate(basicCredentials, true);
|
||||
final Optional<Account> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue