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

Commit fd400b2f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Remove kTruncatingTimestampAtomBlackList" into rvc-dev am: cbd9f03e am: 230e4c83

Change-Id: I6fd36c64ce2eb5d3239d21b695fff43ac9952fe4
parents b2219a7f 230e4c83
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ public:
    }

    // Default value = false
    inline bool shouldTruncateTimestamp() {
    inline bool shouldTruncateTimestamp() const {
        return mTruncateTimestamp;
    }

+1 −2
Original line number Diff line number Diff line
@@ -151,8 +151,7 @@ void EventMetricProducer::onMatchedLogEventInternalLocked(

    uint64_t wrapperToken =
            mProto->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_DATA);
    const int64_t elapsedTimeNs = truncateTimestampIfNecessary(
            event.GetTagId(), event.GetElapsedTimestampNs());
    const int64_t elapsedTimeNs = truncateTimestampIfNecessary(event);
    mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long) elapsedTimeNs);

    uint64_t eventToken = mProto->start(FIELD_TYPE_MESSAGE | FIELD_ID_ATOMS);
+6 −6
Original line number Diff line number Diff line
@@ -270,11 +270,9 @@ void GaugeMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
                    protoOutput->end(atomsToken);
                }
                for (const auto& atom : bucket.mGaugeAtoms) {
                    const int64_t elapsedTimestampNs =
                            truncateTimestampIfNecessary(mAtomId, atom.mElapsedTimestamps);
                    protoOutput->write(
                        FIELD_TYPE_INT64 | FIELD_COUNT_REPEATED | FIELD_ID_ELAPSED_ATOM_TIMESTAMP,
                        (long long)elapsedTimestampNs);
                    protoOutput->write(FIELD_TYPE_INT64 | FIELD_COUNT_REPEATED |
                                               FIELD_ID_ELAPSED_ATOM_TIMESTAMP,
                                       (long long)atom.mElapsedTimestampNs);
                }
            }
            protoOutput->end(bucketInfoToken);
@@ -477,7 +475,9 @@ void GaugeMetricProducer::onMatchedLogEventInternalLocked(
    if ((*mCurrentSlicedBucket)[eventKey].size() >= mGaugeAtomsPerDimensionLimit) {
        return;
    }
    GaugeAtom gaugeAtom(getGaugeFields(event), eventTimeNs);

    const int64_t truncatedElapsedTimestampNs = truncateTimestampIfNecessary(event);
    GaugeAtom gaugeAtom(getGaugeFields(event), truncatedElapsedTimestampNs);
    (*mCurrentSlicedBucket)[eventKey].push_back(gaugeAtom);
    // Anomaly detection on gauge metric only works when there is one numeric
    // field specified.
+2 −2
Original line number Diff line number Diff line
@@ -35,10 +35,10 @@ namespace statsd {

struct GaugeAtom {
    GaugeAtom(std::shared_ptr<vector<FieldValue>> fields, int64_t elapsedTimeNs)
        : mFields(fields), mElapsedTimestamps(elapsedTimeNs) {
        : mFields(fields), mElapsedTimestampNs(elapsedTimeNs) {
    }
    std::shared_ptr<vector<FieldValue>> mFields;
    int64_t mElapsedTimestamps;
    int64_t mElapsedTimestampNs;
};

struct GaugeBucket {
+6 −7
Original line number Diff line number Diff line
@@ -549,14 +549,13 @@ int64_t getWallClockMillis() {
    return time(nullptr) * MS_PER_SEC;
}

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);
int64_t truncateTimestampIfNecessary(const LogEvent& event) {
    if (event.shouldTruncateTimestamp() ||
        (event.GetTagId() >= StatsdStats::kTimestampTruncationStartTag &&
         event.GetTagId() <= StatsdStats::kTimestampTruncationEndTag)) {
        return event.GetElapsedTimestampNs() / NS_PER_SEC / (5 * 60) * NS_PER_SEC * (5 * 60);
    } else {
        return timestampNs;
        return event.GetElapsedTimestampNs();
    }
}

Loading