Loading cmds/statsd/src/atoms.proto +21 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import "frameworks/base/core/proto/android/server/location/enums.proto"; import "frameworks/base/core/proto/android/service/procstats_enum.proto"; import "frameworks/base/core/proto/android/service/usb.proto"; import "frameworks/base/core/proto/android/stats/connectivity/network_stack.proto"; import "frameworks/base/core/proto/android/stats/connectivity/tethering.proto"; import "frameworks/base/core/proto/android/stats/dnsresolver/dns_resolver.proto"; import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy.proto"; import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy_enums.proto"; Loading Loading @@ -483,6 +484,8 @@ message Atom { BlobOpened blob_opened = 300 [(module) = "framework"]; ContactsProviderStatusReported contacts_provider_status_reported = 301; KeystoreKeyEventReported keystore_key_event_reported = 302; NetworkTetheringReported network_tethering_reported = 303 [(module) = "network_tethering"]; // StatsdStats tracks platform atoms with ids upto 500. // Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value. Loading Loading @@ -6890,6 +6893,24 @@ message AppCompacted { optional int64 after_zram_free_kilobytes = 18; } /** * Logs when a Tethering event occurs. * */ message NetworkTetheringReported { // tethering error code optional android.stats.connectivity.ErrorCode error_code = 1; // tethering downstream type optional android.stats.connectivity.DownstreamType downstream_type = 2; // transport type of upstream network optional android.stats.connectivity.UpstreamType upstream_type = 3; // The user type of Tethering optional android.stats.connectivity.UserType user_type= 4; } /** * Logs a DNS lookup operation initiated by the system resolver on behalf of an application * invoking native APIs such as getaddrinfo() or Java APIs such as Network#getAllByName(). Loading cmds/statsd/src/external/StatsPuller.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -44,7 +44,8 @@ StatsPuller::StatsPuller(const int tagId, const int64_t coolDownNs, const int64_ bool StatsPuller::Pull(const int64_t eventTimeNs, std::vector<std::shared_ptr<LogEvent>>* data) { lock_guard<std::mutex> lock(mLock); int64_t elapsedTimeNs = getElapsedRealtimeNs(); const int64_t elapsedTimeNs = getElapsedRealtimeNs(); const int64_t systemUptimeMillis = getSystemUptimeMillis(); StatsdStats::getInstance().notePull(mTagId); const bool shouldUseCache = (mLastEventTimeNs == eventTimeNs) || (elapsedTimeNs - mLastPullTimeNs < mCoolDownNs); Loading @@ -67,16 +68,18 @@ bool StatsPuller::Pull(const int64_t eventTimeNs, std::vector<std::shared_ptr<Lo if (!mHasGoodData) { return mHasGoodData; } const int64_t pullDurationNs = getElapsedRealtimeNs() - elapsedTimeNs; StatsdStats::getInstance().notePullTime(mTagId, pullDurationNs); const bool pullTimeOut = pullDurationNs > mPullTimeoutNs; const int64_t pullElapsedDurationNs = getElapsedRealtimeNs() - elapsedTimeNs; const int64_t pullSystemUptimeDurationMillis = getSystemUptimeMillis() - systemUptimeMillis; StatsdStats::getInstance().notePullTime(mTagId, pullElapsedDurationNs); const bool pullTimeOut = pullElapsedDurationNs > mPullTimeoutNs; if (pullTimeOut) { // Something went wrong. Discard the data. mCachedData.clear(); mHasGoodData = false; StatsdStats::getInstance().notePullTimeout(mTagId); StatsdStats::getInstance().notePullTimeout( mTagId, pullSystemUptimeDurationMillis, NanoToMillis(pullElapsedDurationNs)); ALOGW("Pull for atom %d exceeds timeout %lld nano seconds.", mTagId, (long long)pullDurationNs); (long long)pullElapsedDurationNs); return mHasGoodData; } Loading cmds/statsd/src/guardrail/StatsdStats.cpp +27 −2 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ using android::util::ProtoOutputStream; using std::lock_guard; using std::shared_ptr; using std::string; using std::to_string; using std::vector; const int FIELD_ID_BEGIN_TIME = 1; Loading Loading @@ -436,9 +437,18 @@ void StatsdStats::notePullDataError(int pullAtomId) { mPulledAtomStats[pullAtomId].dataError++; } void StatsdStats::notePullTimeout(int pullAtomId) { void StatsdStats::notePullTimeout(int pullAtomId, int64_t pullUptimeMillis, int64_t pullElapsedMillis) { lock_guard<std::mutex> lock(mLock); mPulledAtomStats[pullAtomId].pullTimeout++; PulledAtomStats& pulledAtomStats = mPulledAtomStats[pullAtomId]; pulledAtomStats.pullTimeout++; if (pulledAtomStats.pullTimeoutMetadata.size() == kMaxTimestampCount) { pulledAtomStats.pullTimeoutMetadata.pop_front(); } pulledAtomStats.pullTimeoutMetadata.emplace_back(pullUptimeMillis, pullElapsedMillis); } void StatsdStats::notePullExceedMaxDelay(int pullAtomId) { Loading Loading @@ -630,6 +640,7 @@ void StatsdStats::resetInternalLocked() { pullStats.second.unregisteredCount = 0; pullStats.second.atomErrorCount = 0; pullStats.second.binderCallFailCount = 0; pullStats.second.pullTimeoutMetadata.clear(); } mAtomMetricStats.clear(); mActivationBroadcastGuardrailStats.clear(); Loading Loading @@ -786,6 +797,20 @@ void StatsdStats::dumpStats(int out) const { pair.second.pullUidProviderNotFound, pair.second.pullerNotFound, pair.second.registeredCount, pair.second.unregisteredCount, pair.second.atomErrorCount); if (pair.second.pullTimeoutMetadata.size() > 0) { string uptimeMillis = "(pull timeout system uptime millis) "; string pullTimeoutMillis = "(pull timeout elapsed time millis) "; for (const auto& stats : pair.second.pullTimeoutMetadata) { uptimeMillis.append(to_string(stats.pullTimeoutUptimeMillis)).append(",");; pullTimeoutMillis.append(to_string(stats.pullTimeoutElapsedMillis)).append(","); } uptimeMillis.pop_back(); uptimeMillis.push_back('\n'); pullTimeoutMillis.pop_back(); pullTimeoutMillis.push_back('\n'); dprintf(out, "%s", uptimeMillis.c_str()); dprintf(out, "%s", pullTimeoutMillis.c_str()); } } if (mAnomalyAlarmRegisteredStats > 0) { Loading cmds/statsd/src/guardrail/StatsdStats.h +10 −1 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ public: /* * Records pull exceeds timeout for the puller. */ void notePullTimeout(int pullAtomId); void notePullTimeout(int pullAtomId, int64_t pullUptimeMillis, int64_t pullElapsedMillis); /* * Records pull exceeds max delay for a metric. Loading Loading @@ -498,6 +498,14 @@ public: */ void dumpStats(int outFd) const; typedef struct PullTimeoutMetadata { int64_t pullTimeoutUptimeMillis; int64_t pullTimeoutElapsedMillis; PullTimeoutMetadata(int64_t uptimeMillis, int64_t elapsedMillis) : pullTimeoutUptimeMillis(uptimeMillis), pullTimeoutElapsedMillis(elapsedMillis) {/* do nothing */} } PullTimeoutMetadata; typedef struct { long totalPull = 0; long totalPullFromCache = 0; Loading @@ -519,6 +527,7 @@ public: long unregisteredCount = 0; int32_t atomErrorCount = 0; long binderCallFailCount = 0; std::list<PullTimeoutMetadata> pullTimeoutMetadata; } PulledAtomStats; typedef struct { Loading cmds/statsd/src/stats_log.proto +5 −0 Original line number Diff line number Diff line Loading @@ -467,6 +467,11 @@ message StatsdStatsReport { optional int64 binder_call_failed = 19; optional int64 failed_uid_provider_not_found = 20; optional int64 puller_not_found = 21; message PullTimeoutMetadata { optional int64 pull_timeout_uptime_millis = 1; optional int64 pull_timeout_elapsed_millis = 2; } repeated PullTimeoutMetadata pull_atom_metadata = 22; } repeated PulledAtomStats pulled_atom_stats = 10; Loading Loading
cmds/statsd/src/atoms.proto +21 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import "frameworks/base/core/proto/android/server/location/enums.proto"; import "frameworks/base/core/proto/android/service/procstats_enum.proto"; import "frameworks/base/core/proto/android/service/usb.proto"; import "frameworks/base/core/proto/android/stats/connectivity/network_stack.proto"; import "frameworks/base/core/proto/android/stats/connectivity/tethering.proto"; import "frameworks/base/core/proto/android/stats/dnsresolver/dns_resolver.proto"; import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy.proto"; import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy_enums.proto"; Loading Loading @@ -483,6 +484,8 @@ message Atom { BlobOpened blob_opened = 300 [(module) = "framework"]; ContactsProviderStatusReported contacts_provider_status_reported = 301; KeystoreKeyEventReported keystore_key_event_reported = 302; NetworkTetheringReported network_tethering_reported = 303 [(module) = "network_tethering"]; // StatsdStats tracks platform atoms with ids upto 500. // Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value. Loading Loading @@ -6890,6 +6893,24 @@ message AppCompacted { optional int64 after_zram_free_kilobytes = 18; } /** * Logs when a Tethering event occurs. * */ message NetworkTetheringReported { // tethering error code optional android.stats.connectivity.ErrorCode error_code = 1; // tethering downstream type optional android.stats.connectivity.DownstreamType downstream_type = 2; // transport type of upstream network optional android.stats.connectivity.UpstreamType upstream_type = 3; // The user type of Tethering optional android.stats.connectivity.UserType user_type= 4; } /** * Logs a DNS lookup operation initiated by the system resolver on behalf of an application * invoking native APIs such as getaddrinfo() or Java APIs such as Network#getAllByName(). Loading
cmds/statsd/src/external/StatsPuller.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -44,7 +44,8 @@ StatsPuller::StatsPuller(const int tagId, const int64_t coolDownNs, const int64_ bool StatsPuller::Pull(const int64_t eventTimeNs, std::vector<std::shared_ptr<LogEvent>>* data) { lock_guard<std::mutex> lock(mLock); int64_t elapsedTimeNs = getElapsedRealtimeNs(); const int64_t elapsedTimeNs = getElapsedRealtimeNs(); const int64_t systemUptimeMillis = getSystemUptimeMillis(); StatsdStats::getInstance().notePull(mTagId); const bool shouldUseCache = (mLastEventTimeNs == eventTimeNs) || (elapsedTimeNs - mLastPullTimeNs < mCoolDownNs); Loading @@ -67,16 +68,18 @@ bool StatsPuller::Pull(const int64_t eventTimeNs, std::vector<std::shared_ptr<Lo if (!mHasGoodData) { return mHasGoodData; } const int64_t pullDurationNs = getElapsedRealtimeNs() - elapsedTimeNs; StatsdStats::getInstance().notePullTime(mTagId, pullDurationNs); const bool pullTimeOut = pullDurationNs > mPullTimeoutNs; const int64_t pullElapsedDurationNs = getElapsedRealtimeNs() - elapsedTimeNs; const int64_t pullSystemUptimeDurationMillis = getSystemUptimeMillis() - systemUptimeMillis; StatsdStats::getInstance().notePullTime(mTagId, pullElapsedDurationNs); const bool pullTimeOut = pullElapsedDurationNs > mPullTimeoutNs; if (pullTimeOut) { // Something went wrong. Discard the data. mCachedData.clear(); mHasGoodData = false; StatsdStats::getInstance().notePullTimeout(mTagId); StatsdStats::getInstance().notePullTimeout( mTagId, pullSystemUptimeDurationMillis, NanoToMillis(pullElapsedDurationNs)); ALOGW("Pull for atom %d exceeds timeout %lld nano seconds.", mTagId, (long long)pullDurationNs); (long long)pullElapsedDurationNs); return mHasGoodData; } Loading
cmds/statsd/src/guardrail/StatsdStats.cpp +27 −2 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ using android::util::ProtoOutputStream; using std::lock_guard; using std::shared_ptr; using std::string; using std::to_string; using std::vector; const int FIELD_ID_BEGIN_TIME = 1; Loading Loading @@ -436,9 +437,18 @@ void StatsdStats::notePullDataError(int pullAtomId) { mPulledAtomStats[pullAtomId].dataError++; } void StatsdStats::notePullTimeout(int pullAtomId) { void StatsdStats::notePullTimeout(int pullAtomId, int64_t pullUptimeMillis, int64_t pullElapsedMillis) { lock_guard<std::mutex> lock(mLock); mPulledAtomStats[pullAtomId].pullTimeout++; PulledAtomStats& pulledAtomStats = mPulledAtomStats[pullAtomId]; pulledAtomStats.pullTimeout++; if (pulledAtomStats.pullTimeoutMetadata.size() == kMaxTimestampCount) { pulledAtomStats.pullTimeoutMetadata.pop_front(); } pulledAtomStats.pullTimeoutMetadata.emplace_back(pullUptimeMillis, pullElapsedMillis); } void StatsdStats::notePullExceedMaxDelay(int pullAtomId) { Loading Loading @@ -630,6 +640,7 @@ void StatsdStats::resetInternalLocked() { pullStats.second.unregisteredCount = 0; pullStats.second.atomErrorCount = 0; pullStats.second.binderCallFailCount = 0; pullStats.second.pullTimeoutMetadata.clear(); } mAtomMetricStats.clear(); mActivationBroadcastGuardrailStats.clear(); Loading Loading @@ -786,6 +797,20 @@ void StatsdStats::dumpStats(int out) const { pair.second.pullUidProviderNotFound, pair.second.pullerNotFound, pair.second.registeredCount, pair.second.unregisteredCount, pair.second.atomErrorCount); if (pair.second.pullTimeoutMetadata.size() > 0) { string uptimeMillis = "(pull timeout system uptime millis) "; string pullTimeoutMillis = "(pull timeout elapsed time millis) "; for (const auto& stats : pair.second.pullTimeoutMetadata) { uptimeMillis.append(to_string(stats.pullTimeoutUptimeMillis)).append(",");; pullTimeoutMillis.append(to_string(stats.pullTimeoutElapsedMillis)).append(","); } uptimeMillis.pop_back(); uptimeMillis.push_back('\n'); pullTimeoutMillis.pop_back(); pullTimeoutMillis.push_back('\n'); dprintf(out, "%s", uptimeMillis.c_str()); dprintf(out, "%s", pullTimeoutMillis.c_str()); } } if (mAnomalyAlarmRegisteredStats > 0) { Loading
cmds/statsd/src/guardrail/StatsdStats.h +10 −1 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ public: /* * Records pull exceeds timeout for the puller. */ void notePullTimeout(int pullAtomId); void notePullTimeout(int pullAtomId, int64_t pullUptimeMillis, int64_t pullElapsedMillis); /* * Records pull exceeds max delay for a metric. Loading Loading @@ -498,6 +498,14 @@ public: */ void dumpStats(int outFd) const; typedef struct PullTimeoutMetadata { int64_t pullTimeoutUptimeMillis; int64_t pullTimeoutElapsedMillis; PullTimeoutMetadata(int64_t uptimeMillis, int64_t elapsedMillis) : pullTimeoutUptimeMillis(uptimeMillis), pullTimeoutElapsedMillis(elapsedMillis) {/* do nothing */} } PullTimeoutMetadata; typedef struct { long totalPull = 0; long totalPullFromCache = 0; Loading @@ -519,6 +527,7 @@ public: long unregisteredCount = 0; int32_t atomErrorCount = 0; long binderCallFailCount = 0; std::list<PullTimeoutMetadata> pullTimeoutMetadata; } PulledAtomStats; typedef struct { Loading
cmds/statsd/src/stats_log.proto +5 −0 Original line number Diff line number Diff line Loading @@ -467,6 +467,11 @@ message StatsdStatsReport { optional int64 binder_call_failed = 19; optional int64 failed_uid_provider_not_found = 20; optional int64 puller_not_found = 21; message PullTimeoutMetadata { optional int64 pull_timeout_uptime_millis = 1; optional int64 pull_timeout_elapsed_millis = 2; } repeated PullTimeoutMetadata pull_atom_metadata = 22; } repeated PulledAtomStats pulled_atom_stats = 10; Loading