Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0253dc14 authored by Tej Singh's avatar Tej Singh Committed by android-build-merger
Browse files

Merge "Blacklist truncated atoms instead of whitelistnig" into qt-dev am: 85a3a468

am: e4677ac1

Change-Id: Ie01c1ae20c07b2d5bcbbd7f875886f1291a449ca
parents 26ac8316 e4677ac1
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -170,6 +170,12 @@ public:
    // Vendor pulled atom start id.
    // Vendor pulled atom start id.
    static const int32_t kVendorPulledAtomStartTag = 150000;
    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.
    // Max accepted atom id.
    static const int32_t kMaxAtomTag = 200000;
    static const int32_t kMaxAtomTag = 200000;


+3 −10
Original line number Original line Diff line number Diff line
@@ -146,16 +146,9 @@ void EventMetricProducer::onMatchedLogEventInternalLocked(


    uint64_t wrapperToken =
    uint64_t wrapperToken =
            mProto->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_DATA);
            mProto->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_DATA);
    const bool truncateTimestamp =
    const int64_t elapsedTimeNs = truncateTimestampIfNecessary(
            android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.find(event.GetTagId()) ==
            event.GetTagId(), event.GetElapsedTimestampNs());
            android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.end();
    mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long) elapsedTimeNs);
    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());
    }


    uint64_t eventToken = mProto->start(FIELD_TYPE_MESSAGE | FIELD_ID_ATOMS);
    uint64_t eventToken = mProto->start(FIELD_TYPE_MESSAGE | FIELD_ID_ATOMS);
    event.ToProto(*mProto);
    event.ToProto(*mProto);
+2 −7
Original line number Original line Diff line number Diff line
@@ -283,14 +283,9 @@ void GaugeMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
                    writeFieldValueTreeToStream(mAtomId, *(atom.mFields), protoOutput);
                    writeFieldValueTreeToStream(mAtomId, *(atom.mFields), protoOutput);
                    protoOutput->end(atomsToken);
                    protoOutput->end(atomsToken);
                }
                }
                const bool truncateTimestamp =
                        android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.find(
                                mAtomId) ==
                        android::util::AtomsInfo::kNotTruncatingTimestampAtomWhiteList.end();
                for (const auto& atom : bucket.mGaugeAtoms) {
                for (const auto& atom : bucket.mGaugeAtoms) {
                    const int64_t elapsedTimestampNs =  truncateTimestamp ?
                    const int64_t elapsedTimestampNs =
                        truncateTimestampNsToFiveMinutes(atom.mElapsedTimestamps) :
                            truncateTimestampIfNecessary(mAtomId, atom.mElapsedTimestamps);
                            atom.mElapsedTimestamps;
                    protoOutput->write(
                    protoOutput->write(
                        FIELD_TYPE_INT64 | FIELD_COUNT_REPEATED | FIELD_ID_ELAPSED_ATOM_TIMESTAMP,
                        FIELD_TYPE_INT64 | FIELD_COUNT_REPEATED | FIELD_ID_ELAPSED_ATOM_TIMESTAMP,
                        (long long)elapsedTimestampNs);
                        (long long)elapsedTimestampNs);
+9 −2
Original line number Original line Diff line number Diff line
@@ -545,8 +545,15 @@ int64_t getWallClockMillis() {
    return time(nullptr) * MS_PER_SEC;
    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);
        return timestampNs / NS_PER_SEC / (5 * 60) * NS_PER_SEC * (5 * 60);
    } else {
        return timestampNs;
    }
}
}


int64_t NanoToMillis(const int64_t nano) {
int64_t NanoToMillis(const int64_t nano) {
+3 −2
Original line number Original line Diff line number Diff line
@@ -89,8 +89,9 @@ bool parseProtoOutputStream(util::ProtoOutputStream& protoOutput, T* message) {
    return message->ParseFromArray(pbBytes.c_str(), pbBytes.size());
    return message->ParseFromArray(pbBytes.c_str(), pbBytes.size());
}
}


// Returns the truncated timestamp.
// Checks the blacklist of atoms as well as the blacklisted range of 300,000 - 304,999.
int64_t truncateTimestampNsToFiveMinutes(int64_t timestampNs);
// Returns the truncated timestamp to the nearest 5 minutes if needed.
int64_t truncateTimestampIfNecessary(int atomId, int64_t timestampNs);


inline bool isVendorPulledAtom(int atomId) {
inline bool isVendorPulledAtom(int atomId) {
    return atomId >= StatsdStats::kVendorPulledAtomStartTag && atomId < StatsdStats::kMaxAtomTag;
    return atomId >= StatsdStats::kVendorPulledAtomStartTag && atomId < StatsdStats::kMaxAtomTag;
Loading