diff --git a/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java b/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java index 704d845fa..d56735b3d 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java +++ b/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java @@ -77,8 +77,11 @@ public abstract class Accounts { @SqlQuery("SELECT * FROM accounts") public abstract Iterator getAll(); - @SqlQuery("SELECT COUNT(*) FROM accounts a, json_array_elements(a.data->'devices') devices WHERE devices->>'id' = '1' AND (devices->>'lastSeen')\\:\\:bigint >= :since") - public abstract int getActiveSinceCount(@Bind("since") long since); + @SqlQuery("SELECT COUNT(*) FROM accounts a, json_array_elements(a.data->'devices') devices WHERE devices->>'id' = '1' AND (devices->>'gcmId') is not null AND (devices->>'lastSeen')\\:\\:bigint >= :since") + public abstract int getAndroidActiveSinceCount(@Bind("since") long since); + + @SqlQuery("SELECT COUNT(*) FROM accounts a, json_array_elements(a.data->'devices') devices WHERE devices->>'id' = '1' AND (devices->>'apnId') is not null AND (devices->>'lastSeen')\\:\\:bigint >= :since") + public abstract int getIosActiveSinceCount(@Bind("since") long since); @SqlQuery("SELECT count(*) FROM accounts a, json_array_elements(a.data->'devices') devices WHERE devices->>'id' = '1' AND (devices->>'lastSeen')\\:\\:bigint >= :since AND (devices->>'signedPreKey') is null AND (devices->>'gcmId') is not null") public abstract int getUnsignedKeysCount(@Bind("since") long since); diff --git a/src/main/java/org/whispersystems/textsecuregcm/workers/PeriodicStatsCommand.java b/src/main/java/org/whispersystems/textsecuregcm/workers/PeriodicStatsCommand.java index 260ea7138..7340a390b 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/workers/PeriodicStatsCommand.java +++ b/src/main/java/org/whispersystems/textsecuregcm/workers/PeriodicStatsCommand.java @@ -2,17 +2,13 @@ package org.whispersystems.textsecuregcm.workers; import com.codahale.metrics.Gauge; import com.codahale.metrics.ScheduledReporter; -import com.codahale.metrics.SharedMetricRegistries; import com.fasterxml.jackson.databind.DeserializationFeature; import net.sourceforge.argparse4j.inf.Namespace; import org.skife.jdbi.v2.DBI; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.whispersystems.textsecuregcm.WhisperServerConfiguration; -import org.whispersystems.textsecuregcm.metrics.JsonMetricsReporter; -import org.whispersystems.textsecuregcm.metrics.JsonMetricsReporterFactory; import org.whispersystems.textsecuregcm.storage.Accounts; -import org.whispersystems.textsecuregcm.util.Constants; import java.util.concurrent.TimeUnit; @@ -68,9 +64,12 @@ public class PeriodicStatsCommand extends EnvironmentCommand() { @Override public Integer getValue() { - return dailyActive; + return dailyActiveAndroid + dailyActiveIos; + } + }); + + environment.metrics().register(name(PeriodicStatsCommand.class, "daily_active_android"), + new Gauge() { + @Override + public Integer getValue() { + return dailyActiveAndroid; + } + }); + + environment.metrics().register(name(PeriodicStatsCommand.class, "daily_active_ios"), + new Gauge() { + @Override + public Integer getValue() { + return dailyActiveIos; } }); @@ -89,7 +104,23 @@ public class PeriodicStatsCommand extends EnvironmentCommand() { @Override public Integer getValue() { - return monthlyActive; + return monthlyActiveAndroid + monthlyActiveIos; + } + }); + + environment.metrics().register(name(PeriodicStatsCommand.class, "monthly_active_android"), + new Gauge() { + @Override + public Integer getValue() { + return monthlyActiveAndroid; + } + }); + + environment.metrics().register(name(PeriodicStatsCommand.class, "monthly_active_ios"), + new Gauge() { + @Override + public Integer getValue() { + return monthlyActiveIos; } });