Loading cmds/statsd/src/metrics/MetricProducer.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -293,6 +293,17 @@ void MetricProducer::mapStateValue(const int32_t atomId, FieldValue* value) { } } HashableDimensionKey MetricProducer::getUnknownStateKey() { HashableDimensionKey stateKey; for (auto atom : mSlicedStateAtoms) { FieldValue fieldValue; fieldValue.mField.setTag(atom); fieldValue.mValue.setInt(StateTracker::kStateUnknown); stateKey.addValue(fieldValue); } return stateKey; } DropEvent MetricProducer::buildDropEvent(const int64_t dropTimeNs, const BucketDropReason reason) { DropEvent event; event.reason = reason; Loading cmds/statsd/src/metrics/MetricProducer.h +4 −0 Original line number Diff line number Diff line Loading @@ -386,6 +386,10 @@ protected: // If no state map exists, keep the original state value. void mapStateValue(const int32_t atomId, FieldValue* value); // Returns a HashableDimensionKey with unknown state value for each state // atom. HashableDimensionKey getUnknownStateKey(); DropEvent buildDropEvent(const int64_t dropTimeNs, const BucketDropReason reason); // Returns true if the number of drop events in the current bucket has Loading cmds/statsd/src/metrics/ValueMetricProducer.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -773,22 +773,24 @@ void ValueMetricProducer::onMatchedLogEventInternalLocked( bool shouldSkipForPulledMetric = mIsPulled && !mUseDiff && mCondition != ConditionState::kTrue; if (shouldSkipForPushMetric || shouldSkipForPulledMetric) { VLOG("ValueMetric skip event because condition is false"); VLOG("ValueMetric skip event because condition is false and we are not using diff (for " "pulled metric)"); return; } if (hitGuardRailLocked(eventKey)) { return; } vector<BaseInfo>& baseInfos = mCurrentBaseInfo[whatKey]; if (baseInfos.size() < mFieldMatchers.size()) { VLOG("Resizing number of intervals to %d", (int)mFieldMatchers.size()); baseInfos.resize(mFieldMatchers.size()); } for (auto baseInfo : baseInfos) { for (BaseInfo& baseInfo : baseInfos) { if (!baseInfo.hasCurrentState) { baseInfo.currentState = DEFAULT_DIMENSION_KEY; baseInfo.currentState = getUnknownStateKey(); baseInfo.hasCurrentState = true; } } Loading Loading @@ -1056,7 +1058,7 @@ void ValueMetricProducer::initCurrentSlicedBucket(int64_t nextBucketStartTimeNs) } else { it++; } // TODO: remove mCurrentBaseInfo entries when obsolete // TODO(b/157655103): remove mCurrentBaseInfo entries when obsolete } mCurrentBucketIsSkipped = false; Loading cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp +291 −80 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
cmds/statsd/src/metrics/MetricProducer.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -293,6 +293,17 @@ void MetricProducer::mapStateValue(const int32_t atomId, FieldValue* value) { } } HashableDimensionKey MetricProducer::getUnknownStateKey() { HashableDimensionKey stateKey; for (auto atom : mSlicedStateAtoms) { FieldValue fieldValue; fieldValue.mField.setTag(atom); fieldValue.mValue.setInt(StateTracker::kStateUnknown); stateKey.addValue(fieldValue); } return stateKey; } DropEvent MetricProducer::buildDropEvent(const int64_t dropTimeNs, const BucketDropReason reason) { DropEvent event; event.reason = reason; Loading
cmds/statsd/src/metrics/MetricProducer.h +4 −0 Original line number Diff line number Diff line Loading @@ -386,6 +386,10 @@ protected: // If no state map exists, keep the original state value. void mapStateValue(const int32_t atomId, FieldValue* value); // Returns a HashableDimensionKey with unknown state value for each state // atom. HashableDimensionKey getUnknownStateKey(); DropEvent buildDropEvent(const int64_t dropTimeNs, const BucketDropReason reason); // Returns true if the number of drop events in the current bucket has Loading
cmds/statsd/src/metrics/ValueMetricProducer.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -773,22 +773,24 @@ void ValueMetricProducer::onMatchedLogEventInternalLocked( bool shouldSkipForPulledMetric = mIsPulled && !mUseDiff && mCondition != ConditionState::kTrue; if (shouldSkipForPushMetric || shouldSkipForPulledMetric) { VLOG("ValueMetric skip event because condition is false"); VLOG("ValueMetric skip event because condition is false and we are not using diff (for " "pulled metric)"); return; } if (hitGuardRailLocked(eventKey)) { return; } vector<BaseInfo>& baseInfos = mCurrentBaseInfo[whatKey]; if (baseInfos.size() < mFieldMatchers.size()) { VLOG("Resizing number of intervals to %d", (int)mFieldMatchers.size()); baseInfos.resize(mFieldMatchers.size()); } for (auto baseInfo : baseInfos) { for (BaseInfo& baseInfo : baseInfos) { if (!baseInfo.hasCurrentState) { baseInfo.currentState = DEFAULT_DIMENSION_KEY; baseInfo.currentState = getUnknownStateKey(); baseInfo.hasCurrentState = true; } } Loading Loading @@ -1056,7 +1058,7 @@ void ValueMetricProducer::initCurrentSlicedBucket(int64_t nextBucketStartTimeNs) } else { it++; } // TODO: remove mCurrentBaseInfo entries when obsolete // TODO(b/157655103): remove mCurrentBaseInfo entries when obsolete } mCurrentBucketIsSkipped = false; Loading
cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp +291 −80 File changed.Preview size limit exceeded, changes collapsed. Show changes