Loading cmds/statsd/Android.mk +0 −3 Original line number Diff line number Diff line Loading @@ -51,8 +51,6 @@ statsd_common_src := \ src/metrics/MetricsManager.cpp \ src/metrics/metrics_manager_util.cpp \ src/packages/UidMap.cpp \ src/storage/DropboxReader.cpp \ src/storage/DropboxWriter.cpp \ src/storage/StorageManager.cpp \ src/StatsLogProcessor.cpp \ src/StatsService.cpp \ Loading @@ -76,7 +74,6 @@ statsd_common_shared_libraries := \ libselinux \ libutils \ libservices \ libandroidfw \ libprotoutil \ libstatslog \ libhardware \ Loading cmds/statsd/src/StatsService.cpp +0 −15 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include "config/ConfigManager.h" #include "guardrail/MemoryLeakTrackUtil.h" #include "guardrail/StatsdStats.h" #include "storage/DropboxReader.h" #include "storage/StorageManager.h" #include <android-base/file.h> Loading Loading @@ -201,11 +200,6 @@ status_t StatsService::command(FILE* in, FILE* out, FILE* err, Vector<String8>& return cmd_config(in, out, err, args); } // adb shell cmd stats print-stats-log if (!args[0].compare(String8("print-stats-log")) && args.size() > 1) { return cmd_print_stats_log(out, args); } if (!args[0].compare(String8("print-uid-map"))) { return cmd_print_uid_map(out); } Loading Loading @@ -503,15 +497,6 @@ status_t StatsService::cmd_print_stats(FILE* out, const Vector<String8>& args) { return NO_ERROR; } status_t StatsService::cmd_print_stats_log(FILE* out, const Vector<String8>& args) { long msec = 0; if (args.size() > 2) { msec = strtol(args[2].string(), NULL, 10); } return DropboxReader::readStatsLogs(out, args[1].string(), msec); } status_t StatsService::cmd_print_uid_map(FILE* out) { mUidMap->printUidMap(out); return NO_ERROR; Loading cmds/statsd/src/metrics/ValueMetricProducer.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,10 @@ void ValueMetricProducer::onDumpReportLocked(const uint64_t dumpTimeNs, void ValueMetricProducer::onConditionChangedLocked(const bool condition, const uint64_t eventTime) { mCondition = condition; if (eventTime < mCurrentBucketStartTimeNs) { return; } if (mPullTagId != -1) { if (mCondition == true) { mStatsPullerManager->RegisterReceiver(mPullTagId, this, Loading cmds/statsd/src/stats_util.cpp +0 −108 Original line number Diff line number Diff line Loading @@ -15,119 +15,11 @@ */ #include "stats_util.h" #include <log/log_event_list.h> namespace android { namespace os { namespace statsd { static inline uint32_t get4LE(const char* src) { return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24); } int getTagId(log_msg msg) { return get4LE(msg.msg()); } EventMetricData parse(log_msg msg) { // dump all statsd logs to dropbox for now. // TODO: Add filtering, aggregation, etc. EventMetricData eventMetricData; // set tag. int tag = getTagId(msg); // TODO: Replace the following line when we can serialize on the fly. // eventMetricData.set_tag(tag); // set timestamp of the event. eventMetricData.set_timestamp_nanos(msg.entry_v1.sec * NS_PER_SEC + msg.entry_v1.nsec); // start iterating k,v pairs. android_log_context context = create_android_log_parser(const_cast<log_msg*>(&msg)->msg() + sizeof(uint32_t), const_cast<log_msg*>(&msg)->len() - sizeof(uint32_t)); android_log_list_element elem; if (context) { memset(&elem, 0, sizeof(elem)); size_t index = 0; int32_t key = -1; do { elem = android_log_read_next(context); switch ((int)elem.type) { case EVENT_TYPE_INT: if (index % 2 == 0) { key = elem.data.int32; } else { // TODO: Fix the following lines when we can serialize on the fly. /* int32_t val = elem.data.int32; KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair(); keyValuePair->set_key(key); keyValuePair->set_value_int(val); */ } index++; break; case EVENT_TYPE_FLOAT: if (index % 2 == 1) { // TODO: Fix the following lines when we can serialize on the fly. /* float val = elem.data.float32; KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair(); keyValuePair->set_key(key); keyValuePair->set_value_float(val); */ } index++; break; case EVENT_TYPE_STRING: if (index % 2 == 1) { // TODO: Fix the following lines when we can serialize on the fly. /* char* val = elem.data.string; KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair(); keyValuePair->set_key(key); keyValuePair->set_value_str(val); */ } index++; break; case EVENT_TYPE_LONG: if (index % 2 == 1) { // TODO: Fix the following lines when we can serialize on the fly. /* int64_t val = elem.data.int64; KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair(); keyValuePair->set_key(key); keyValuePair->set_value_int(val); */ } index++; break; case EVENT_TYPE_LIST: break; case EVENT_TYPE_LIST_STOP: break; case EVENT_TYPE_UNKNOWN: break; default: elem.complete = true; break; } if (elem.complete) { break; } } while ((elem.type != EVENT_TYPE_UNKNOWN) && !elem.complete); android_log_destroy(&context); } return eventMetricData; } // There is no existing hash function for the dimension key ("repeated KeyValuePair"). // Temporarily use a string concatenation as the hashable key. // TODO: Find a better hash function for std::vector<KeyValuePair>. Loading cmds/statsd/src/stats_util.h +1 −10 Original line number Diff line number Diff line Loading @@ -16,11 +16,7 @@ #pragma once #include "logd/LogReader.h" #include "storage/DropboxWriter.h" #include <log/logprint.h> #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" #include "frameworks/base/cmds/statsd/src/stats_log.pb.h" #include <unordered_map> Loading @@ -29,7 +25,6 @@ namespace os { namespace statsd { #define DEFAULT_DIMENSION_KEY "" #define MATCHER_NOT_FOUND -2 typedef std::string HashableDimensionKey; Loading @@ -37,10 +32,6 @@ typedef std::map<std::string, HashableDimensionKey> ConditionKey; typedef std::unordered_map<HashableDimensionKey, int64_t> DimToValMap; EventMetricData parse(log_msg msg); int getTagId(log_msg msg); std::string getHashableKey(std::vector<KeyValuePair> key); } // namespace statsd Loading Loading
cmds/statsd/Android.mk +0 −3 Original line number Diff line number Diff line Loading @@ -51,8 +51,6 @@ statsd_common_src := \ src/metrics/MetricsManager.cpp \ src/metrics/metrics_manager_util.cpp \ src/packages/UidMap.cpp \ src/storage/DropboxReader.cpp \ src/storage/DropboxWriter.cpp \ src/storage/StorageManager.cpp \ src/StatsLogProcessor.cpp \ src/StatsService.cpp \ Loading @@ -76,7 +74,6 @@ statsd_common_shared_libraries := \ libselinux \ libutils \ libservices \ libandroidfw \ libprotoutil \ libstatslog \ libhardware \ Loading
cmds/statsd/src/StatsService.cpp +0 −15 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include "config/ConfigManager.h" #include "guardrail/MemoryLeakTrackUtil.h" #include "guardrail/StatsdStats.h" #include "storage/DropboxReader.h" #include "storage/StorageManager.h" #include <android-base/file.h> Loading Loading @@ -201,11 +200,6 @@ status_t StatsService::command(FILE* in, FILE* out, FILE* err, Vector<String8>& return cmd_config(in, out, err, args); } // adb shell cmd stats print-stats-log if (!args[0].compare(String8("print-stats-log")) && args.size() > 1) { return cmd_print_stats_log(out, args); } if (!args[0].compare(String8("print-uid-map"))) { return cmd_print_uid_map(out); } Loading Loading @@ -503,15 +497,6 @@ status_t StatsService::cmd_print_stats(FILE* out, const Vector<String8>& args) { return NO_ERROR; } status_t StatsService::cmd_print_stats_log(FILE* out, const Vector<String8>& args) { long msec = 0; if (args.size() > 2) { msec = strtol(args[2].string(), NULL, 10); } return DropboxReader::readStatsLogs(out, args[1].string(), msec); } status_t StatsService::cmd_print_uid_map(FILE* out) { mUidMap->printUidMap(out); return NO_ERROR; Loading
cmds/statsd/src/metrics/ValueMetricProducer.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,10 @@ void ValueMetricProducer::onDumpReportLocked(const uint64_t dumpTimeNs, void ValueMetricProducer::onConditionChangedLocked(const bool condition, const uint64_t eventTime) { mCondition = condition; if (eventTime < mCurrentBucketStartTimeNs) { return; } if (mPullTagId != -1) { if (mCondition == true) { mStatsPullerManager->RegisterReceiver(mPullTagId, this, Loading
cmds/statsd/src/stats_util.cpp +0 −108 Original line number Diff line number Diff line Loading @@ -15,119 +15,11 @@ */ #include "stats_util.h" #include <log/log_event_list.h> namespace android { namespace os { namespace statsd { static inline uint32_t get4LE(const char* src) { return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24); } int getTagId(log_msg msg) { return get4LE(msg.msg()); } EventMetricData parse(log_msg msg) { // dump all statsd logs to dropbox for now. // TODO: Add filtering, aggregation, etc. EventMetricData eventMetricData; // set tag. int tag = getTagId(msg); // TODO: Replace the following line when we can serialize on the fly. // eventMetricData.set_tag(tag); // set timestamp of the event. eventMetricData.set_timestamp_nanos(msg.entry_v1.sec * NS_PER_SEC + msg.entry_v1.nsec); // start iterating k,v pairs. android_log_context context = create_android_log_parser(const_cast<log_msg*>(&msg)->msg() + sizeof(uint32_t), const_cast<log_msg*>(&msg)->len() - sizeof(uint32_t)); android_log_list_element elem; if (context) { memset(&elem, 0, sizeof(elem)); size_t index = 0; int32_t key = -1; do { elem = android_log_read_next(context); switch ((int)elem.type) { case EVENT_TYPE_INT: if (index % 2 == 0) { key = elem.data.int32; } else { // TODO: Fix the following lines when we can serialize on the fly. /* int32_t val = elem.data.int32; KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair(); keyValuePair->set_key(key); keyValuePair->set_value_int(val); */ } index++; break; case EVENT_TYPE_FLOAT: if (index % 2 == 1) { // TODO: Fix the following lines when we can serialize on the fly. /* float val = elem.data.float32; KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair(); keyValuePair->set_key(key); keyValuePair->set_value_float(val); */ } index++; break; case EVENT_TYPE_STRING: if (index % 2 == 1) { // TODO: Fix the following lines when we can serialize on the fly. /* char* val = elem.data.string; KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair(); keyValuePair->set_key(key); keyValuePair->set_value_str(val); */ } index++; break; case EVENT_TYPE_LONG: if (index % 2 == 1) { // TODO: Fix the following lines when we can serialize on the fly. /* int64_t val = elem.data.int64; KeyValuePair* keyValuePair = eventMetricData.add_key_value_pair(); keyValuePair->set_key(key); keyValuePair->set_value_int(val); */ } index++; break; case EVENT_TYPE_LIST: break; case EVENT_TYPE_LIST_STOP: break; case EVENT_TYPE_UNKNOWN: break; default: elem.complete = true; break; } if (elem.complete) { break; } } while ((elem.type != EVENT_TYPE_UNKNOWN) && !elem.complete); android_log_destroy(&context); } return eventMetricData; } // There is no existing hash function for the dimension key ("repeated KeyValuePair"). // Temporarily use a string concatenation as the hashable key. // TODO: Find a better hash function for std::vector<KeyValuePair>. Loading
cmds/statsd/src/stats_util.h +1 −10 Original line number Diff line number Diff line Loading @@ -16,11 +16,7 @@ #pragma once #include "logd/LogReader.h" #include "storage/DropboxWriter.h" #include <log/logprint.h> #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" #include "frameworks/base/cmds/statsd/src/stats_log.pb.h" #include <unordered_map> Loading @@ -29,7 +25,6 @@ namespace os { namespace statsd { #define DEFAULT_DIMENSION_KEY "" #define MATCHER_NOT_FOUND -2 typedef std::string HashableDimensionKey; Loading @@ -37,10 +32,6 @@ typedef std::map<std::string, HashableDimensionKey> ConditionKey; typedef std::unordered_map<HashableDimensionKey, int64_t> DimToValMap; EventMetricData parse(log_msg msg); int getTagId(log_msg msg); std::string getHashableKey(std::vector<KeyValuePair> key); } // namespace statsd Loading