Merge "add dump report reason to reports" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a194a6bee3
@@ -64,6 +64,7 @@ const int FIELD_ID_LAST_REPORT_ELAPSED_NANOS = 3;
|
||||
const int FIELD_ID_CURRENT_REPORT_ELAPSED_NANOS = 4;
|
||||
const int FIELD_ID_LAST_REPORT_WALL_CLOCK_NANOS = 5;
|
||||
const int FIELD_ID_CURRENT_REPORT_WALL_CLOCK_NANOS = 6;
|
||||
const int FIELD_ID_DUMP_REPORT_REASON = 8;
|
||||
|
||||
#define NS_PER_HOUR 3600 * NS_PER_SEC
|
||||
|
||||
@@ -183,7 +184,7 @@ void StatsLogProcessor::OnLogEvent(LogEvent* event, bool reconnected) {
|
||||
mInReconnection = false;
|
||||
StatsdStats::getInstance().noteLogLost(currentTimestampNs);
|
||||
// Persist the data before we reset. Do we want this?
|
||||
WriteDataToDiskLocked();
|
||||
WriteDataToDiskLocked(CONFIG_RESET);
|
||||
// We see fresher event before we see the checkpoint. We might have lost data.
|
||||
// The best we can do is to reset.
|
||||
std::vector<ConfigKey> configKeys;
|
||||
@@ -251,7 +252,7 @@ void StatsLogProcessor::OnConfigUpdatedLocked(
|
||||
mAnomalyAlarmMonitor, mPeriodicAlarmMonitor);
|
||||
auto it = mMetricsManagers.find(key);
|
||||
if (it != mMetricsManagers.end()) {
|
||||
WriteDataToDiskLocked(it->first);
|
||||
WriteDataToDiskLocked(it->first, CONFIG_UPDATED);
|
||||
}
|
||||
if (newMetricsManager->isConfigValid()) {
|
||||
mUidMap->OnConfigUpdated(key);
|
||||
@@ -292,6 +293,7 @@ void StatsLogProcessor::dumpStates(FILE* out, bool verbose) {
|
||||
*/
|
||||
void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTimeStampNs,
|
||||
const bool include_current_partial_bucket,
|
||||
const DumpReportReason dumpReportReason,
|
||||
vector<uint8_t>* outData) {
|
||||
std::lock_guard<std::mutex> lock(mMetricsMutex);
|
||||
|
||||
@@ -317,7 +319,8 @@ void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTim
|
||||
// Start of ConfigMetricsReport (reports).
|
||||
uint64_t reportsToken =
|
||||
proto.start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_REPORTS);
|
||||
onConfigMetricsReportLocked(key, dumpTimeStampNs, include_current_partial_bucket, &proto);
|
||||
onConfigMetricsReportLocked(key, dumpTimeStampNs, include_current_partial_bucket,
|
||||
dumpReportReason, &proto);
|
||||
proto.end(reportsToken);
|
||||
// End of ConfigMetricsReport (reports).
|
||||
} else {
|
||||
@@ -346,6 +349,7 @@ void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTim
|
||||
void StatsLogProcessor::onConfigMetricsReportLocked(const ConfigKey& key,
|
||||
const int64_t dumpTimeStampNs,
|
||||
const bool include_current_partial_bucket,
|
||||
const DumpReportReason dumpReportReason,
|
||||
ProtoOutputStream* proto) {
|
||||
// We already checked whether key exists in mMetricsManagers in
|
||||
// WriteDataToDisk.
|
||||
@@ -374,6 +378,8 @@ void StatsLogProcessor::onConfigMetricsReportLocked(const ConfigKey& key,
|
||||
(long long)lastReportWallClockNs);
|
||||
proto->write(FIELD_TYPE_INT64 | FIELD_ID_CURRENT_REPORT_WALL_CLOCK_NANOS,
|
||||
(long long)getWallClockNs());
|
||||
// Dump report reason
|
||||
proto->write(FIELD_TYPE_INT32 | FIELD_ID_DUMP_REPORT_REASON, dumpReportReason);
|
||||
}
|
||||
|
||||
void StatsLogProcessor::resetConfigsLocked(const int64_t timestampNs,
|
||||
@@ -409,7 +415,7 @@ void StatsLogProcessor::OnConfigRemoved(const ConfigKey& key) {
|
||||
std::lock_guard<std::mutex> lock(mMetricsMutex);
|
||||
auto it = mMetricsManagers.find(key);
|
||||
if (it != mMetricsManagers.end()) {
|
||||
WriteDataToDiskLocked(key);
|
||||
WriteDataToDiskLocked(key, CONFIG_REMOVED);
|
||||
mMetricsManagers.erase(it);
|
||||
mUidMap->OnConfigRemoved(key);
|
||||
}
|
||||
@@ -455,10 +461,11 @@ void StatsLogProcessor::flushIfNecessaryLocked(
|
||||
}
|
||||
}
|
||||
|
||||
void StatsLogProcessor::WriteDataToDiskLocked(const ConfigKey& key) {
|
||||
void StatsLogProcessor::WriteDataToDiskLocked(const ConfigKey& key,
|
||||
const DumpReportReason dumpReportReason) {
|
||||
ProtoOutputStream proto;
|
||||
onConfigMetricsReportLocked(key, getElapsedRealtimeNs(),
|
||||
true /* include_current_partial_bucket*/, &proto);
|
||||
true /* include_current_partial_bucket*/, dumpReportReason, &proto);
|
||||
string file_name = StringPrintf("%s/%ld_%d_%lld", STATS_DATA_DIR,
|
||||
(long)getWallClockSec(), key.GetUid(), (long long)key.GetId());
|
||||
android::base::unique_fd fd(open(file_name.c_str(),
|
||||
@@ -470,15 +477,15 @@ void StatsLogProcessor::WriteDataToDiskLocked(const ConfigKey& key) {
|
||||
proto.flush(fd.get());
|
||||
}
|
||||
|
||||
void StatsLogProcessor::WriteDataToDiskLocked() {
|
||||
void StatsLogProcessor::WriteDataToDiskLocked(const DumpReportReason dumpReportReason) {
|
||||
for (auto& pair : mMetricsManagers) {
|
||||
WriteDataToDiskLocked(pair.first);
|
||||
WriteDataToDiskLocked(pair.first, dumpReportReason);
|
||||
}
|
||||
}
|
||||
|
||||
void StatsLogProcessor::WriteDataToDisk() {
|
||||
void StatsLogProcessor::WriteDataToDisk(bool isShutdown) {
|
||||
std::lock_guard<std::mutex> lock(mMetricsMutex);
|
||||
WriteDataToDiskLocked();
|
||||
WriteDataToDiskLocked(DEVICE_SHUTDOWN);
|
||||
}
|
||||
|
||||
void StatsLogProcessor::informPullAlarmFired(const int64_t timestampNs) {
|
||||
|
||||
@@ -32,6 +32,17 @@ namespace android {
|
||||
namespace os {
|
||||
namespace statsd {
|
||||
|
||||
// Keep this in sync with DumpReportReason enum in stats_log.proto
|
||||
enum DumpReportReason {
|
||||
DEVICE_SHUTDOWN = 1,
|
||||
CONFIG_UPDATED = 2,
|
||||
CONFIG_REMOVED = 3,
|
||||
GET_DATA_CALLED = 4,
|
||||
ADB_DUMP = 5,
|
||||
CONFIG_RESET = 6,
|
||||
STATSCOMPANION_DIED = 7
|
||||
};
|
||||
|
||||
class StatsLogProcessor : public ConfigListener {
|
||||
public:
|
||||
StatsLogProcessor(const sp<UidMap>& uidMap, const sp<AlarmMonitor>& anomalyAlarmMonitor,
|
||||
@@ -52,7 +63,8 @@ public:
|
||||
size_t GetMetricsSize(const ConfigKey& key) const;
|
||||
|
||||
void onDumpReport(const ConfigKey& key, const int64_t dumpTimeNs,
|
||||
const bool include_current_partial_bucket, vector<uint8_t>* outData);
|
||||
const bool include_current_partial_bucket,
|
||||
const DumpReportReason dumpReportReason, vector<uint8_t>* outData);
|
||||
|
||||
/* Tells MetricsManager that the alarms in alarmSet have fired. Modifies anomaly alarmSet. */
|
||||
void onAnomalyAlarmFired(
|
||||
@@ -65,7 +77,7 @@ public:
|
||||
unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>> alarmSet);
|
||||
|
||||
/* Flushes data to disk. Data on memory will be gone after written to disk. */
|
||||
void WriteDataToDisk();
|
||||
void WriteDataToDisk(bool shutdown);
|
||||
|
||||
inline sp<UidMap> getUidMap() {
|
||||
return mUidMap;
|
||||
@@ -109,11 +121,12 @@ private:
|
||||
void OnConfigUpdatedLocked(
|
||||
const int64_t currentTimestampNs, const ConfigKey& key, const StatsdConfig& config);
|
||||
|
||||
void WriteDataToDiskLocked();
|
||||
void WriteDataToDiskLocked(const ConfigKey& key);
|
||||
void WriteDataToDiskLocked(DumpReportReason dumpReportReason);
|
||||
void WriteDataToDiskLocked(const ConfigKey& key, DumpReportReason dumpReportReason);
|
||||
|
||||
void onConfigMetricsReportLocked(const ConfigKey& key, const int64_t dumpTimeStampNs,
|
||||
const bool include_current_partial_bucket,
|
||||
const DumpReportReason dumpReportReason,
|
||||
util::ProtoOutputStream* proto);
|
||||
|
||||
/* Check if we should send a broadcast if approaching memory limits and if we're over, we
|
||||
|
||||
@@ -592,7 +592,7 @@ status_t StatsService::cmd_dump_report(FILE* out, FILE* err, const Vector<String
|
||||
if (good) {
|
||||
vector<uint8_t> data;
|
||||
mProcessor->onDumpReport(ConfigKey(uid, StrToInt64(name)), getElapsedRealtimeNs(),
|
||||
false /* include_current_bucket*/, &data);
|
||||
false /* include_current_bucket*/, ADB_DUMP, &data);
|
||||
// TODO: print the returned StatsLogReport to file instead of printing to logcat.
|
||||
if (proto) {
|
||||
for (size_t i = 0; i < data.size(); i ++) {
|
||||
@@ -658,7 +658,7 @@ status_t StatsService::cmd_print_uid_map(FILE* out, const Vector<String8>& args)
|
||||
|
||||
status_t StatsService::cmd_write_data_to_disk(FILE* out) {
|
||||
fprintf(out, "Writing data to disk\n");
|
||||
mProcessor->WriteDataToDisk();
|
||||
mProcessor->WriteDataToDisk(false);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -815,11 +815,10 @@ Status StatsService::systemRunning() {
|
||||
return Status::ok();
|
||||
}
|
||||
|
||||
Status StatsService::writeDataToDisk() {
|
||||
Status StatsService::informDeviceShutdown(bool isShutdown) {
|
||||
ENFORCE_UID(AID_SYSTEM);
|
||||
|
||||
VLOG("StatsService::writeDataToDisk");
|
||||
mProcessor->WriteDataToDisk();
|
||||
VLOG("StatsService::informDeviceShutdown");
|
||||
mProcessor->WriteDataToDisk(isShutdown);
|
||||
return Status::ok();
|
||||
}
|
||||
|
||||
@@ -866,8 +865,8 @@ Status StatsService::getData(int64_t key, const String16& packageName, vector<ui
|
||||
IPCThreadState* ipc = IPCThreadState::self();
|
||||
VLOG("StatsService::getData with Pid %i, Uid %i", ipc->getCallingPid(), ipc->getCallingUid());
|
||||
ConfigKey configKey(ipc->getCallingUid(), key);
|
||||
mProcessor->onDumpReport(configKey, getElapsedRealtimeNs(),
|
||||
false /* include_current_bucket*/, output);
|
||||
mProcessor->onDumpReport(configKey, getElapsedRealtimeNs(), false /* include_current_bucket*/,
|
||||
GET_DATA_CALLED, output);
|
||||
return Status::ok();
|
||||
}
|
||||
|
||||
@@ -966,7 +965,7 @@ Status StatsService::unsetBroadcastSubscriber(int64_t configId,
|
||||
|
||||
void StatsService::binderDied(const wp <IBinder>& who) {
|
||||
ALOGW("statscompanion service died");
|
||||
mProcessor->WriteDataToDisk();
|
||||
mProcessor->WriteDataToDisk(STATSCOMPANION_DIED);
|
||||
mAnomalyAlarmMonitor->setStatsCompanionService(nullptr);
|
||||
mPeriodicAlarmMonitor->setStatsCompanionService(nullptr);
|
||||
SubscriberReporter::getInstance().setStatsCompanionService(nullptr);
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
const vector<String16>& app);
|
||||
virtual Status informOnePackage(const String16& app, int32_t uid, int64_t version);
|
||||
virtual Status informOnePackageRemoved(const String16& app, int32_t uid);
|
||||
virtual Status writeDataToDisk();
|
||||
virtual Status informDeviceShutdown(bool isShutdown);
|
||||
|
||||
/**
|
||||
* Called right before we start processing events.
|
||||
|
||||
@@ -221,7 +221,7 @@ void UidMap::removeApp(const int64_t& timestamp, const String16& app_16, const i
|
||||
{
|
||||
lock_guard<mutex> lock(mMutex);
|
||||
|
||||
int32_t prevVersion = 0;
|
||||
int64_t prevVersion = 0;
|
||||
auto key = std::make_pair(uid, app);
|
||||
auto it = mMap.find(key);
|
||||
if (it != mMap.end() && !it->second.deleted) {
|
||||
@@ -324,8 +324,9 @@ void UidMap::appendUidMap(const int64_t& timestamp, const ConfigKey& key,
|
||||
(long long)record.timestampNs);
|
||||
proto->write(FIELD_TYPE_STRING | FIELD_ID_CHANGE_PACKAGE, record.package);
|
||||
proto->write(FIELD_TYPE_INT32 | FIELD_ID_CHANGE_UID, (int)record.uid);
|
||||
proto->write(FIELD_TYPE_INT32 | FIELD_ID_CHANGE_NEW_VERSION, (int)record.version);
|
||||
proto->write(FIELD_TYPE_INT32 | FIELD_ID_CHANGE_PREV_VERSION, (int)record.prevVersion);
|
||||
proto->write(FIELD_TYPE_INT64 | FIELD_ID_CHANGE_NEW_VERSION, (long long)record.version);
|
||||
proto->write(FIELD_TYPE_INT64 | FIELD_ID_CHANGE_PREV_VERSION,
|
||||
(long long)record.prevVersion);
|
||||
proto->end(changesToken);
|
||||
}
|
||||
}
|
||||
@@ -338,8 +339,8 @@ void UidMap::appendUidMap(const int64_t& timestamp, const ConfigKey& key,
|
||||
uint64_t token = proto->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED |
|
||||
FIELD_ID_SNAPSHOT_PACKAGE_INFO);
|
||||
proto->write(FIELD_TYPE_STRING | FIELD_ID_SNAPSHOT_PACKAGE_NAME, kv.first.second);
|
||||
proto->write(FIELD_TYPE_INT32 | FIELD_ID_SNAPSHOT_PACKAGE_VERSION,
|
||||
(int)kv.second.versionCode);
|
||||
proto->write(FIELD_TYPE_INT64 | FIELD_ID_SNAPSHOT_PACKAGE_VERSION,
|
||||
(long long)kv.second.versionCode);
|
||||
proto->write(FIELD_TYPE_INT32 | FIELD_ID_SNAPSHOT_PACKAGE_UID, kv.first.first);
|
||||
proto->write(FIELD_TYPE_BOOL | FIELD_ID_SNAPSHOT_PACKAGE_DELETED, kv.second.deleted);
|
||||
proto->end(token);
|
||||
|
||||
@@ -59,11 +59,11 @@ struct ChangeRecord {
|
||||
const int64_t timestampNs;
|
||||
const string package;
|
||||
const int32_t uid;
|
||||
const int32_t version;
|
||||
const int32_t prevVersion;
|
||||
const int64_t version;
|
||||
const int64_t prevVersion;
|
||||
|
||||
ChangeRecord(const bool isDeletion, const int64_t timestampNs, const string& package,
|
||||
const int32_t uid, const int32_t version, const int32_t prevVersion)
|
||||
const int32_t uid, const int64_t version, const int64_t prevVersion)
|
||||
: deletion(isDeletion),
|
||||
timestampNs(timestampNs),
|
||||
package(package),
|
||||
|
||||
@@ -197,6 +197,17 @@ message ConfigMetricsReport {
|
||||
|
||||
optional int64 current_report_wall_clock_nanos = 6;
|
||||
|
||||
enum DumpReportReason {
|
||||
DEVICE_SHUTDOWN = 1;
|
||||
CONFIG_UPDATED = 2;
|
||||
CONFIG_REMOVED = 3;
|
||||
GET_DATA_CALLED = 4;
|
||||
ADB_DUMP = 5;
|
||||
CONFIG_RESET = 6;
|
||||
STATSCOMPANION_DIED = 7;
|
||||
}
|
||||
optional DumpReportReason dump_report_reason = 8;
|
||||
|
||||
message Annotation {
|
||||
optional int64 field_int64 = 1;
|
||||
optional int32 field_int32 = 2;
|
||||
@@ -212,6 +223,8 @@ message ConfigMetricsReportList {
|
||||
optional ConfigKey config_key = 1;
|
||||
|
||||
repeated ConfigMetricsReport reports = 2;
|
||||
|
||||
reserved 10;
|
||||
}
|
||||
|
||||
message StatsdStatsReport {
|
||||
|
||||
@@ -139,7 +139,7 @@ TEST(StatsLogProcessorTest, TestUidMapHasSnapshot) {
|
||||
|
||||
// Expect to get no metrics, but snapshot specified above in uidmap.
|
||||
vector<uint8_t> bytes;
|
||||
p.onDumpReport(key, 1, false, &bytes);
|
||||
p.onDumpReport(key, 1, false, ADB_DUMP, &bytes);
|
||||
|
||||
ConfigMetricsReportList output;
|
||||
output.ParseFromArray(bytes.data(), bytes.size());
|
||||
@@ -167,7 +167,7 @@ TEST(StatsLogProcessorTest, TestReportIncludesSubConfig) {
|
||||
|
||||
// Expect to get no metrics, but snapshot specified above in uidmap.
|
||||
vector<uint8_t> bytes;
|
||||
p.onDumpReport(key, 1, false, &bytes);
|
||||
p.onDumpReport(key, 1, false, ADB_DUMP, &bytes);
|
||||
|
||||
ConfigMetricsReportList output;
|
||||
output.ParseFromArray(bytes.data(), bytes.size());
|
||||
|
||||
@@ -144,7 +144,8 @@ TEST(AttributionE2eTest, TestAttributionMatchAndSliceByFirstUid) {
|
||||
}
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 4 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 4 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(reports.reports_size(), 1);
|
||||
@@ -286,7 +287,8 @@ TEST(AttributionE2eTest, TestAttributionMatchAndSliceByChain) {
|
||||
}
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 4 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 4 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(reports.reports_size(), 1);
|
||||
|
||||
@@ -172,8 +172,8 @@ TEST(DimensionInConditionE2eTest, TestDurationMetric_NoLink_AND_CombinationCondi
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1,
|
||||
false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false,
|
||||
ADB_DUMP, &buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
@@ -490,7 +490,7 @@ TEST(DimensionInConditionE2eTest, TestDurationMetric_Link_AND_CombinationConditi
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false,
|
||||
&buffer);
|
||||
ADB_DUMP, &buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
@@ -733,7 +733,8 @@ TEST(DimensionInConditionE2eTest, TestDurationMetric_PartialLink_AND_Combination
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
|
||||
@@ -130,7 +130,8 @@ TEST(DimensionInConditionE2eTest, TestCreateCountMetric_NoLink_OR_CombinationCon
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
@@ -342,7 +343,8 @@ TEST(DimensionInConditionE2eTest, TestCreateCountMetric_Link_OR_CombinationCondi
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
@@ -522,7 +524,8 @@ TEST(DimensionInConditionE2eTest, TestDurationMetric_NoLink_OR_CombinationCondit
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
@@ -720,7 +723,8 @@ TEST(DimensionInConditionE2eTest, TestDurationMetric_Link_OR_CombinationConditio
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ TEST(DimensionInConditionE2eTest, TestDurationMetric_NoLink_SimpleCondition) {
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false,
|
||||
&buffer);
|
||||
ADB_DUMP, &buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
@@ -435,7 +435,7 @@ TEST(DimensionInConditionE2eTest, TestDurationMetric_Link_SimpleCondition) {
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false,
|
||||
&buffer);
|
||||
ADB_DUMP, &buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
@@ -652,7 +652,8 @@ TEST(DimensionInConditionE2eTest, TestDurationMetric_PartialLink_SimpleCondition
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
|
||||
@@ -122,7 +122,8 @@ TEST(GaugeMetricE2eTest, TestRandomSamplePulledEvents) {
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 7 * bucketSizeNs + 10, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 7 * bucketSizeNs + 10, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(1, reports.reports_size());
|
||||
@@ -240,7 +241,8 @@ TEST(GaugeMetricE2eTest, TestAllConditionChangesSamplePulledEvents) {
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 8 * bucketSizeNs + 10, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 8 * bucketSizeNs + 10, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(1, reports.reports_size());
|
||||
@@ -340,7 +342,8 @@ TEST(GaugeMetricE2eTest, TestRandomSamplePulledEvent_LateAlarm) {
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 7 * bucketSizeNs + 10, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 7 * bucketSizeNs + 10, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(1, reports.reports_size());
|
||||
|
||||
@@ -149,7 +149,8 @@ TEST(GaugeMetricE2eTest, TestMultipleFieldsForPushedEvent) {
|
||||
}
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 3 * bucketSizeNs, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 3 * bucketSizeNs, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(1, reports.reports_size());
|
||||
|
||||
@@ -200,7 +200,8 @@ TEST(MetricConditionLinkE2eTest, TestMultiplePredicatesAndLinks1) {
|
||||
}
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs - 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs - 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(reports.reports_size(), 1);
|
||||
@@ -315,7 +316,8 @@ TEST(MetricConditionLinkE2eTest, TestMultiplePredicatesAndLinks2) {
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(reports.reports_size(), 1);
|
||||
|
||||
@@ -46,7 +46,7 @@ ConfigMetricsReport GetReports(sp<StatsLogProcessor> processor, int64_t timestam
|
||||
IPCThreadState* ipc = IPCThreadState::self();
|
||||
ConfigKey configKey(ipc->getCallingUid(), kConfigKey);
|
||||
processor->onDumpReport(configKey, timestamp, include_current /* include_current_bucket*/,
|
||||
&output);
|
||||
ADB_DUMP, &output);
|
||||
ConfigMetricsReportList reports;
|
||||
reports.ParseFromArray(output.data(), output.size());
|
||||
EXPECT_EQ(1, reports.reports_size());
|
||||
|
||||
@@ -117,7 +117,8 @@ TEST(ValueMetricE2eTest, TestPulledEvents) {
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 7 * bucketSizeNs + 10, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 7 * bucketSizeNs + 10, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(1, reports.reports_size());
|
||||
@@ -220,7 +221,8 @@ TEST(ValueMetricE2eTest, TestPulledEvents_LateAlarm) {
|
||||
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 9 * bucketSizeNs + 10, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, configAddedTimeNs + 9 * bucketSizeNs + 10, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(1, reports.reports_size());
|
||||
|
||||
@@ -127,7 +127,8 @@ TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForSumDuration1)
|
||||
FeedEvents(config, processor);
|
||||
vector<uint8_t> buffer;
|
||||
ConfigMetricsReportList reports;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs - 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs - 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
|
||||
@@ -161,7 +162,8 @@ TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForSumDuration2)
|
||||
vector<uint8_t> buffer;
|
||||
ConfigMetricsReportList reports;
|
||||
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(reports.reports_size(), 1);
|
||||
@@ -208,7 +210,8 @@ TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForSumDuration3)
|
||||
processor->OnLogEvent(event.get());
|
||||
}
|
||||
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 6 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 6 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(reports.reports_size(), 1);
|
||||
@@ -237,7 +240,8 @@ TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForMaxDuration1)
|
||||
FeedEvents(config, processor);
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs - 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs - 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
@@ -262,7 +266,8 @@ TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForMaxDuration2)
|
||||
FeedEvents(config, processor);
|
||||
ConfigMetricsReportList reports;
|
||||
vector<uint8_t> buffer;
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 2 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(reports.reports_size(), 1);
|
||||
@@ -304,7 +309,8 @@ TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForMaxDuration3)
|
||||
processor->OnLogEvent(event.get());
|
||||
}
|
||||
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 6 * bucketSizeNs + 1, false, &buffer);
|
||||
processor->onDumpReport(cfgKey, bucketStartTimeNs + 6 * bucketSizeNs + 1, false, ADB_DUMP,
|
||||
&buffer);
|
||||
EXPECT_TRUE(buffer.size() > 0);
|
||||
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(reports.reports_size(), 1);
|
||||
|
||||
@@ -54,9 +54,9 @@ interface IStatsManager {
|
||||
void informAlarmForSubscriberTriggeringFired();
|
||||
|
||||
/**
|
||||
* Tells statsd to store data to disk.
|
||||
* Tells statsd that the device is about to shutdown.
|
||||
*/
|
||||
void writeDataToDisk();
|
||||
void informDeviceShutdown(boolean isShutdown);
|
||||
|
||||
/**
|
||||
* Inform statsd what the version and package are for each uid. Note that each array should
|
||||
|
||||
@@ -426,7 +426,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
sStatsd.writeDataToDisk();
|
||||
sStatsd.informDeviceShutdown(true);
|
||||
} catch (Exception e) {
|
||||
Slog.w(TAG, "Failed to inform statsd of a shutdown event.", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user