Add temporary metrics to monitor the ratio of enabled/disabled accounts.
This commit is contained in:
parent
1ab52cfce3
commit
9339823e84
|
@ -20,6 +20,8 @@ package org.whispersystems.textsecuregcm.storage;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import io.micrometer.core.instrument.Counter;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import org.whispersystems.textsecuregcm.auth.AmbiguousIdentifier;
|
||||
import org.whispersystems.textsecuregcm.auth.StoredRegistrationLock;
|
||||
|
||||
|
@ -32,8 +34,14 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.codahale.metrics.MetricRegistry.name;
|
||||
|
||||
public class Account implements Principal {
|
||||
|
||||
// TODO Remove these temporary metrics
|
||||
private static final Counter ENABLED_ACCOUNT_COUNTER = Metrics.counter(name(Account.class, "isEnabled"), "enabled", "true");
|
||||
private static final Counter DISABLED_ACCOUNT_COUNTER = Metrics.counter(name(Account.class, "isEnabled"), "enabled", "false");
|
||||
|
||||
@JsonIgnore
|
||||
private UUID uuid;
|
||||
|
||||
|
@ -152,10 +160,18 @@ public class Account implements Principal {
|
|||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return
|
||||
final boolean enabled =
|
||||
getMasterDevice().isPresent() &&
|
||||
getMasterDevice().get().isEnabled() &&
|
||||
getLastSeen() > (System.currentTimeMillis() - TimeUnit.DAYS.toMillis(365));
|
||||
|
||||
if (enabled) {
|
||||
ENABLED_ACCOUNT_COUNTER.increment();
|
||||
} else {
|
||||
DISABLED_ACCOUNT_COUNTER.increment();
|
||||
}
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public long getNextDeviceId() {
|
||||
|
|
Loading…
Reference in New Issue