Loading cmds/statsd/src/guardrail/StatsdStats.h +6 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,12 @@ public: // Vendor pulled atom start id. static const int32_t kVendorPulledAtomStartTag = 150000; // Beginning of range for timestamp truncation. static const int32_t kTimestampTruncationStartTag = 300000; // End of range for timestamp truncation. static const int32_t kTimestampTruncationEndTag = 304999; // Max accepted atom id. static const int32_t kMaxAtomTag = 200000; Loading cmds/statsd/src/metrics/EventMetricProducer.cpp +3 −10 Original line number Diff line number Diff line Loading @@ -146,16 +146,9 @@ void EventMetricProducer::onMatchedLogEventInternalLocked( uint64_t wrapperToken = mProto->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_DATA); const bool truncateTimestamp = android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.find(event.GetTagId()) == android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.end(); if (truncateTimestamp) { mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long)truncateTimestampNsToFiveMinutes(event.GetElapsedTimestampNs())); } else { mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long)event.GetElapsedTimestampNs()); } const int64_t elapsedTimeNs = truncateTimestampIfNecessary( event.GetTagId(), event.GetElapsedTimestampNs()); mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long) elapsedTimeNs); uint64_t eventToken = mProto->start(FIELD_TYPE_MESSAGE | FIELD_ID_ATOMS); event.ToProto(*mProto); Loading cmds/statsd/src/metrics/GaugeMetricProducer.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -283,14 +283,9 @@ void GaugeMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs, writeFieldValueTreeToStream(mAtomId, *(atom.mFields), protoOutput); protoOutput->end(atomsToken); } const bool truncateTimestamp = android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.find( mAtomId) == android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.end(); for (const auto& atom : bucket.mGaugeAtoms) { const int64_t elapsedTimestampNs = truncateTimestamp ? truncateTimestampNsToFiveMinutes(atom.mElapsedTimestamps) : atom.mElapsedTimestamps; const int64_t elapsedTimestampNs = truncateTimestampIfNecessary(mAtomId, atom.mElapsedTimestamps); protoOutput->write( FIELD_TYPE_INT64 | FIELD_COUNT_REPEATED | FIELD_ID_ELAPSED_ATOM_TIMESTAMP, (long long)elapsedTimestampNs); Loading cmds/statsd/src/stats_log_util.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -545,8 +545,15 @@ int64_t getWallClockMillis() { return time(nullptr) * MS_PER_SEC; } int64_t truncateTimestampNsToFiveMinutes(int64_t timestampNs) { int64_t truncateTimestampIfNecessary(int atomId, int64_t timestampNs) { if (AtomsInfo::kTruncatingTimestampAtomBlackList.find(atomId) != AtomsInfo::kTruncatingTimestampAtomBlackList.end() || (atomId >= StatsdStats::kTimestampTruncationStartTag && atomId <= StatsdStats::kTimestampTruncationEndTag)) { return timestampNs / NS_PER_SEC / (5 * 60) * NS_PER_SEC * (5 * 60); } else { return timestampNs; } } int64_t NanoToMillis(const int64_t nano) { Loading cmds/statsd/src/stats_log_util.h +3 −2 Original line number Diff line number Diff line Loading @@ -89,8 +89,9 @@ bool parseProtoOutputStream(util::ProtoOutputStream& protoOutput, T* message) { return message->ParseFromArray(pbBytes.c_str(), pbBytes.size()); } // Returns the truncated timestamp. int64_t truncateTimestampNsToFiveMinutes(int64_t timestampNs); // Checks the blacklist of atoms as well as the blacklisted range of 300,000 - 304,999. // Returns the truncated timestamp to the nearest 5 minutes if needed. int64_t truncateTimestampIfNecessary(int atomId, int64_t timestampNs); inline bool isVendorPulledAtom(int atomId) { return atomId >= StatsdStats::kVendorPulledAtomStartTag && atomId < StatsdStats::kMaxAtomTag; Loading Loading
cmds/statsd/src/guardrail/StatsdStats.h +6 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,12 @@ public: // Vendor pulled atom start id. static const int32_t kVendorPulledAtomStartTag = 150000; // Beginning of range for timestamp truncation. static const int32_t kTimestampTruncationStartTag = 300000; // End of range for timestamp truncation. static const int32_t kTimestampTruncationEndTag = 304999; // Max accepted atom id. static const int32_t kMaxAtomTag = 200000; Loading
cmds/statsd/src/metrics/EventMetricProducer.cpp +3 −10 Original line number Diff line number Diff line Loading @@ -146,16 +146,9 @@ void EventMetricProducer::onMatchedLogEventInternalLocked( uint64_t wrapperToken = mProto->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_DATA); const bool truncateTimestamp = android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.find(event.GetTagId()) == android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.end(); if (truncateTimestamp) { mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long)truncateTimestampNsToFiveMinutes(event.GetElapsedTimestampNs())); } else { mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long)event.GetElapsedTimestampNs()); } const int64_t elapsedTimeNs = truncateTimestampIfNecessary( event.GetTagId(), event.GetElapsedTimestampNs()); mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long) elapsedTimeNs); uint64_t eventToken = mProto->start(FIELD_TYPE_MESSAGE | FIELD_ID_ATOMS); event.ToProto(*mProto); Loading
cmds/statsd/src/metrics/GaugeMetricProducer.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -283,14 +283,9 @@ void GaugeMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs, writeFieldValueTreeToStream(mAtomId, *(atom.mFields), protoOutput); protoOutput->end(atomsToken); } const bool truncateTimestamp = android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.find( mAtomId) == android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.end(); for (const auto& atom : bucket.mGaugeAtoms) { const int64_t elapsedTimestampNs = truncateTimestamp ? truncateTimestampNsToFiveMinutes(atom.mElapsedTimestamps) : atom.mElapsedTimestamps; const int64_t elapsedTimestampNs = truncateTimestampIfNecessary(mAtomId, atom.mElapsedTimestamps); protoOutput->write( FIELD_TYPE_INT64 | FIELD_COUNT_REPEATED | FIELD_ID_ELAPSED_ATOM_TIMESTAMP, (long long)elapsedTimestampNs); Loading
cmds/statsd/src/stats_log_util.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -545,8 +545,15 @@ int64_t getWallClockMillis() { return time(nullptr) * MS_PER_SEC; } int64_t truncateTimestampNsToFiveMinutes(int64_t timestampNs) { int64_t truncateTimestampIfNecessary(int atomId, int64_t timestampNs) { if (AtomsInfo::kTruncatingTimestampAtomBlackList.find(atomId) != AtomsInfo::kTruncatingTimestampAtomBlackList.end() || (atomId >= StatsdStats::kTimestampTruncationStartTag && atomId <= StatsdStats::kTimestampTruncationEndTag)) { return timestampNs / NS_PER_SEC / (5 * 60) * NS_PER_SEC * (5 * 60); } else { return timestampNs; } } int64_t NanoToMillis(const int64_t nano) { Loading
cmds/statsd/src/stats_log_util.h +3 −2 Original line number Diff line number Diff line Loading @@ -89,8 +89,9 @@ bool parseProtoOutputStream(util::ProtoOutputStream& protoOutput, T* message) { return message->ParseFromArray(pbBytes.c_str(), pbBytes.size()); } // Returns the truncated timestamp. int64_t truncateTimestampNsToFiveMinutes(int64_t timestampNs); // Checks the blacklist of atoms as well as the blacklisted range of 300,000 - 304,999. // Returns the truncated timestamp to the nearest 5 minutes if needed. int64_t truncateTimestampIfNecessary(int atomId, int64_t timestampNs); inline bool isVendorPulledAtom(int atomId) { return atomId >= StatsdStats::kVendorPulledAtomStartTag && atomId < StatsdStats::kMaxAtomTag; Loading