mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 12:46:47 +00:00
Add temporary metrics to monitor the ratio of enabled/disabled accounts.
This commit is contained in:
1 parent
1ab52cfce3
commit
9339823e84
1 file changed
+17
-1
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user