Loading cmds/statsd/src/logd/LogEvent.h +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ public: } // Default value = false inline bool shouldTruncateTimestamp() { inline bool shouldTruncateTimestamp() const { return mTruncateTimestamp; } Loading cmds/statsd/src/metrics/EventMetricProducer.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -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); Loading cmds/statsd/src/metrics/GaugeMetricProducer.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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. Loading cmds/statsd/src/metrics/GaugeMetricProducer.h +2 −2 Original line number Diff line number Diff line Loading @@ -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 { Loading cmds/statsd/src/stats_log_util.cpp +6 −7 Original line number Diff line number Diff line Loading @@ -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 Loading
cmds/statsd/src/logd/LogEvent.h +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ public: } // Default value = false inline bool shouldTruncateTimestamp() { inline bool shouldTruncateTimestamp() const { return mTruncateTimestamp; } Loading
cmds/statsd/src/metrics/EventMetricProducer.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -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); Loading
cmds/statsd/src/metrics/GaugeMetricProducer.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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. Loading
cmds/statsd/src/metrics/GaugeMetricProducer.h +2 −2 Original line number Diff line number Diff line Loading @@ -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 { Loading
cmds/statsd/src/stats_log_util.cpp +6 −7 Original line number Diff line number Diff line Loading @@ -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