Loading cmds/statsd/src/metrics/EventMetricProducer.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ const int FIELD_ID_DATA = 1; // for EventMetricData const int FIELD_ID_ELAPSED_TIMESTAMP_NANOS = 1; const int FIELD_ID_ATOMS = 2; const int FIELD_ID_WALL_CLOCK_TIMESTAMP_NANOS = 3; EventMetricProducer::EventMetricProducer(const ConfigKey& key, const EventMetric& metric, const int conditionIndex, Loading Loading @@ -146,13 +145,9 @@ void EventMetricProducer::onMatchedLogEventInternalLocked( if (truncateTimestamp) { mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long)truncateTimestampNsToFiveMinutes(event.GetElapsedTimestampNs())); mProto->write(FIELD_TYPE_INT64 | FIELD_ID_WALL_CLOCK_TIMESTAMP_NANOS, (long long)truncateTimestampNsToFiveMinutes(getWallClockNs())); } else { mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long)event.GetElapsedTimestampNs()); mProto->write(FIELD_TYPE_INT64 | FIELD_ID_WALL_CLOCK_TIMESTAMP_NANOS, (long long)getWallClockNs()); } uint64_t eventToken = mProto->start(FIELD_TYPE_MESSAGE | FIELD_ID_ATOMS); Loading cmds/statsd/src/metrics/GaugeMetricProducer.cpp +1 −9 Original line number Diff line number Diff line Loading @@ -63,7 +63,6 @@ const int FIELD_ID_DIMENSION_LEAF_IN_CONDITION = 5; // for GaugeBucketInfo const int FIELD_ID_ATOM = 3; const int FIELD_ID_ELAPSED_ATOM_TIMESTAMP = 4; const int FIELD_ID_WALL_CLOCK_ATOM_TIMESTAMP = 5; const int FIELD_ID_BUCKET_NUM = 6; const int FIELD_ID_START_BUCKET_ELAPSED_MILLIS = 7; const int FIELD_ID_END_BUCKET_ELAPSED_MILLIS = 8; Loading Loading @@ -286,16 +285,9 @@ void GaugeMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs, const int64_t elapsedTimestampNs = truncateTimestamp ? truncateTimestampNsToFiveMinutes(atom.mElapsedTimestamps) : atom.mElapsedTimestamps; const int64_t wallClockNs = truncateTimestamp ? truncateTimestampNsToFiveMinutes(atom.mWallClockTimestampNs) : atom.mWallClockTimestampNs; 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_WALL_CLOCK_ATOM_TIMESTAMP, (long long)wallClockNs); } } protoOutput->end(bucketInfoToken); Loading Loading @@ -450,7 +442,7 @@ void GaugeMetricProducer::onMatchedLogEventInternalLocked( if ((*mCurrentSlicedBucket)[eventKey].size() >= mGaugeAtomsPerDimensionLimit) { return; } GaugeAtom gaugeAtom(getGaugeFields(event), eventTimeNs, getWallClockNs()); GaugeAtom gaugeAtom(getGaugeFields(event), eventTimeNs); (*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 −3 Original line number Diff line number Diff line Loading @@ -33,12 +33,11 @@ namespace os { namespace statsd { struct GaugeAtom { GaugeAtom(std::shared_ptr<vector<FieldValue>> fields, int64_t elapsedTimeNs, int64_t wallClockNs) : mFields(fields), mElapsedTimestamps(elapsedTimeNs), mWallClockTimestampNs(wallClockNs) { GaugeAtom(std::shared_ptr<vector<FieldValue>> fields, int64_t elapsedTimeNs) : mFields(fields), mElapsedTimestamps(elapsedTimeNs) { } std::shared_ptr<vector<FieldValue>> mFields; int64_t mElapsedTimestamps; int64_t mWallClockTimestampNs; }; struct GaugeBucket { Loading cmds/statsd/src/stats_log.proto +2 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ message EventMetricData { optional Atom atom = 2; optional int64 wall_clock_timestamp_nanos = 3; optional int64 wall_clock_timestamp_nanos = 3 [deprecated = true]; } message CountBucketInfo { Loading Loading @@ -142,7 +142,7 @@ message GaugeBucketInfo { repeated int64 elapsed_timestamp_nanos = 4; repeated int64 wall_clock_timestamp_nanos = 5; repeated int64 wall_clock_timestamp_nanos = 5 [deprecated = true]; optional int64 bucket_num = 6; Loading cmds/statsd/tests/e2e/GaugeMetric_e2e_pull_test.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ TEST(GaugeMetricE2eTest, TestRandomSamplePulledEvents) { EXPECT_EQ(1, data.bucket_info(0).atom_size()); EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size()); EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0)); EXPECT_EQ(1, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos()); EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos()); EXPECT_TRUE(data.bucket_info(0).atom(0).temperature().sensor_name().empty()); Loading Loading @@ -271,7 +271,7 @@ TEST(GaugeMetricE2eTest, TestAllConditionChangesSamplePulledEvents) { EXPECT_EQ(1, data.bucket_info(0).atom_size()); EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size()); EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0)); EXPECT_EQ(1, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos()); EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos()); EXPECT_TRUE(data.bucket_info(0).atom(0).temperature().sensor_name().empty()); Loading Loading @@ -375,7 +375,6 @@ TEST(GaugeMetricE2eTest, TestRandomSamplePulledEvent_LateAlarm) { EXPECT_EQ(1, data.bucket_info(0).atom_size()); EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size()); EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0)); EXPECT_EQ(1, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos()); EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos()); EXPECT_TRUE(data.bucket_info(0).atom(0).temperature().sensor_name().empty()); Loading Loading
cmds/statsd/src/metrics/EventMetricProducer.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ const int FIELD_ID_DATA = 1; // for EventMetricData const int FIELD_ID_ELAPSED_TIMESTAMP_NANOS = 1; const int FIELD_ID_ATOMS = 2; const int FIELD_ID_WALL_CLOCK_TIMESTAMP_NANOS = 3; EventMetricProducer::EventMetricProducer(const ConfigKey& key, const EventMetric& metric, const int conditionIndex, Loading Loading @@ -146,13 +145,9 @@ void EventMetricProducer::onMatchedLogEventInternalLocked( if (truncateTimestamp) { mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long)truncateTimestampNsToFiveMinutes(event.GetElapsedTimestampNs())); mProto->write(FIELD_TYPE_INT64 | FIELD_ID_WALL_CLOCK_TIMESTAMP_NANOS, (long long)truncateTimestampNsToFiveMinutes(getWallClockNs())); } else { mProto->write(FIELD_TYPE_INT64 | FIELD_ID_ELAPSED_TIMESTAMP_NANOS, (long long)event.GetElapsedTimestampNs()); mProto->write(FIELD_TYPE_INT64 | FIELD_ID_WALL_CLOCK_TIMESTAMP_NANOS, (long long)getWallClockNs()); } uint64_t eventToken = mProto->start(FIELD_TYPE_MESSAGE | FIELD_ID_ATOMS); Loading
cmds/statsd/src/metrics/GaugeMetricProducer.cpp +1 −9 Original line number Diff line number Diff line Loading @@ -63,7 +63,6 @@ const int FIELD_ID_DIMENSION_LEAF_IN_CONDITION = 5; // for GaugeBucketInfo const int FIELD_ID_ATOM = 3; const int FIELD_ID_ELAPSED_ATOM_TIMESTAMP = 4; const int FIELD_ID_WALL_CLOCK_ATOM_TIMESTAMP = 5; const int FIELD_ID_BUCKET_NUM = 6; const int FIELD_ID_START_BUCKET_ELAPSED_MILLIS = 7; const int FIELD_ID_END_BUCKET_ELAPSED_MILLIS = 8; Loading Loading @@ -286,16 +285,9 @@ void GaugeMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs, const int64_t elapsedTimestampNs = truncateTimestamp ? truncateTimestampNsToFiveMinutes(atom.mElapsedTimestamps) : atom.mElapsedTimestamps; const int64_t wallClockNs = truncateTimestamp ? truncateTimestampNsToFiveMinutes(atom.mWallClockTimestampNs) : atom.mWallClockTimestampNs; 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_WALL_CLOCK_ATOM_TIMESTAMP, (long long)wallClockNs); } } protoOutput->end(bucketInfoToken); Loading Loading @@ -450,7 +442,7 @@ void GaugeMetricProducer::onMatchedLogEventInternalLocked( if ((*mCurrentSlicedBucket)[eventKey].size() >= mGaugeAtomsPerDimensionLimit) { return; } GaugeAtom gaugeAtom(getGaugeFields(event), eventTimeNs, getWallClockNs()); GaugeAtom gaugeAtom(getGaugeFields(event), eventTimeNs); (*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 −3 Original line number Diff line number Diff line Loading @@ -33,12 +33,11 @@ namespace os { namespace statsd { struct GaugeAtom { GaugeAtom(std::shared_ptr<vector<FieldValue>> fields, int64_t elapsedTimeNs, int64_t wallClockNs) : mFields(fields), mElapsedTimestamps(elapsedTimeNs), mWallClockTimestampNs(wallClockNs) { GaugeAtom(std::shared_ptr<vector<FieldValue>> fields, int64_t elapsedTimeNs) : mFields(fields), mElapsedTimestamps(elapsedTimeNs) { } std::shared_ptr<vector<FieldValue>> mFields; int64_t mElapsedTimestamps; int64_t mWallClockTimestampNs; }; struct GaugeBucket { Loading
cmds/statsd/src/stats_log.proto +2 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ message EventMetricData { optional Atom atom = 2; optional int64 wall_clock_timestamp_nanos = 3; optional int64 wall_clock_timestamp_nanos = 3 [deprecated = true]; } message CountBucketInfo { Loading Loading @@ -142,7 +142,7 @@ message GaugeBucketInfo { repeated int64 elapsed_timestamp_nanos = 4; repeated int64 wall_clock_timestamp_nanos = 5; repeated int64 wall_clock_timestamp_nanos = 5 [deprecated = true]; optional int64 bucket_num = 6; Loading
cmds/statsd/tests/e2e/GaugeMetric_e2e_pull_test.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ TEST(GaugeMetricE2eTest, TestRandomSamplePulledEvents) { EXPECT_EQ(1, data.bucket_info(0).atom_size()); EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size()); EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0)); EXPECT_EQ(1, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos()); EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos()); EXPECT_TRUE(data.bucket_info(0).atom(0).temperature().sensor_name().empty()); Loading Loading @@ -271,7 +271,7 @@ TEST(GaugeMetricE2eTest, TestAllConditionChangesSamplePulledEvents) { EXPECT_EQ(1, data.bucket_info(0).atom_size()); EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size()); EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0)); EXPECT_EQ(1, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos()); EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos()); EXPECT_TRUE(data.bucket_info(0).atom(0).temperature().sensor_name().empty()); Loading Loading @@ -375,7 +375,6 @@ TEST(GaugeMetricE2eTest, TestRandomSamplePulledEvent_LateAlarm) { EXPECT_EQ(1, data.bucket_info(0).atom_size()); EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size()); EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0)); EXPECT_EQ(1, data.bucket_info(0).wall_clock_timestamp_nanos_size()); EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos()); EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos()); EXPECT_TRUE(data.bucket_info(0).atom(0).temperature().sensor_name().empty()); Loading