Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 16 | |
Yangster-mac | 754e29e | 2018-05-02 12:23:17 -0700 | [diff] [blame] | 17 | #define DEBUG false // STOPSHIP if true |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 18 | #include "Log.h" |
tsaichristine | 69000e6 | 2019-10-18 17:34:52 -0700 | [diff] [blame] | 19 | |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 20 | #include "MetricProducer.h" |
Yangster-mac | 9369446 | 2018-01-22 20:49:31 -0800 | [diff] [blame] | 21 | |
tsaichristine | b87ca15 | 2019-12-09 15:19:41 -0800 | [diff] [blame] | 22 | #include "../guardrail/StatsdStats.h" |
tsaichristine | 69000e6 | 2019-10-18 17:34:52 -0700 | [diff] [blame] | 23 | #include "state/StateTracker.h" |
| 24 | |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 25 | using android::util::FIELD_COUNT_REPEATED; |
Tej Singh | f53d445 | 2019-05-09 18:17:59 -0700 | [diff] [blame] | 26 | using android::util::FIELD_TYPE_ENUM; |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 27 | using android::util::FIELD_TYPE_INT32; |
| 28 | using android::util::FIELD_TYPE_INT64; |
| 29 | using android::util::FIELD_TYPE_MESSAGE; |
| 30 | using android::util::ProtoOutputStream; |
| 31 | |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 32 | namespace android { |
| 33 | namespace os { |
| 34 | namespace statsd { |
| 35 | |
| 36 | using std::map; |
| 37 | |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 38 | // for ActiveMetric |
| 39 | const int FIELD_ID_ACTIVE_METRIC_ID = 1; |
| 40 | const int FIELD_ID_ACTIVE_METRIC_ACTIVATION = 2; |
| 41 | |
| 42 | // for ActiveEventActivation |
| 43 | const int FIELD_ID_ACTIVE_EVENT_ACTIVATION_ATOM_MATCHER_INDEX = 1; |
| 44 | const int FIELD_ID_ACTIVE_EVENT_ACTIVATION_REMAINING_TTL_NANOS = 2; |
Tej Singh | f53d445 | 2019-05-09 18:17:59 -0700 | [diff] [blame] | 45 | const int FIELD_ID_ACTIVE_EVENT_ACTIVATION_STATE = 3; |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 46 | |
Ruchir Rastogi | 21a287b | 2019-10-02 12:04:33 -0700 | [diff] [blame] | 47 | MetricProducer::MetricProducer( |
| 48 | const int64_t& metricId, const ConfigKey& key, const int64_t timeBaseNs, |
| 49 | const int conditionIndex, const sp<ConditionWizard>& wizard, |
| 50 | const std::unordered_map<int, std::shared_ptr<Activation>>& eventActivationMap, |
| 51 | const std::unordered_map<int, std::vector<std::shared_ptr<Activation>>>& |
tsaichristine | d21aacf | 2019-10-07 14:47:38 -0700 | [diff] [blame] | 52 | eventDeactivationMap, |
| 53 | const vector<int>& slicedStateAtoms, |
| 54 | const unordered_map<int, unordered_map<int, int64_t>>& stateGroupMap) |
| 55 | : mMetricId(metricId), |
| 56 | mConfigKey(key), |
| 57 | mTimeBaseNs(timeBaseNs), |
| 58 | mCurrentBucketStartTimeNs(timeBaseNs), |
| 59 | mCurrentBucketNum(0), |
| 60 | mCondition(initialCondition(conditionIndex)), |
| 61 | mConditionTrackerIndex(conditionIndex), |
| 62 | mConditionSliced(false), |
| 63 | mWizard(wizard), |
| 64 | mContainANYPositionInDimensionsInWhat(false), |
| 65 | mSliceByPositionALL(false), |
| 66 | mHasLinksToAllConditionDimensionsInTracker(false), |
| 67 | mEventActivationMap(eventActivationMap), |
| 68 | mEventDeactivationMap(eventDeactivationMap), |
| 69 | mIsActive(mEventActivationMap.empty()), |
| 70 | mSlicedStateAtoms(slicedStateAtoms), |
| 71 | mStateGroupMap(stateGroupMap) { |
| 72 | } |
Ruchir Rastogi | 21a287b | 2019-10-02 12:04:33 -0700 | [diff] [blame] | 73 | |
Chenjie Yu | a7259ab | 2017-12-10 08:31:05 -0800 | [diff] [blame] | 74 | void MetricProducer::onMatchedLogEventLocked(const size_t matcherIndex, const LogEvent& event) { |
Tej Singh | 597c716 | 2019-04-17 16:41:45 -0700 | [diff] [blame] | 75 | if (!mIsActive) { |
| 76 | return; |
| 77 | } |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 78 | int64_t eventTimeNs = event.GetElapsedTimestampNs(); |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 79 | // this is old event, maybe statsd restarted? |
Yangster-mac | 15f6bbc | 2018-04-08 11:52:26 -0700 | [diff] [blame] | 80 | if (eventTimeNs < mTimeBaseNs) { |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 81 | return; |
| 82 | } |
| 83 | |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 84 | bool condition; |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 85 | ConditionKey conditionKey; |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 86 | if (mConditionSliced) { |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 87 | for (const auto& link : mMetric2ConditionLinks) { |
Yangster-mac | 5392888 | 2018-02-25 23:02:56 -0800 | [diff] [blame] | 88 | getDimensionForCondition(event.getValues(), link, &conditionKey[link.conditionId]); |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 89 | } |
Yangster-mac | 9369446 | 2018-01-22 20:49:31 -0800 | [diff] [blame] | 90 | auto conditionState = |
tsaichristine | 7685337 | 2019-08-06 17:17:03 -0700 | [diff] [blame] | 91 | mWizard->query(mConditionTrackerIndex, conditionKey, |
| 92 | !mHasLinksToAllConditionDimensionsInTracker); |
Yangster-mac | 9369446 | 2018-01-22 20:49:31 -0800 | [diff] [blame] | 93 | condition = (conditionState == ConditionState::kTrue); |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 94 | } else { |
Olivier Gaillard | e63d9e0 | 2019-02-12 14:43:59 +0000 | [diff] [blame] | 95 | // TODO: The unknown condition state is not handled here, we should fix it. |
| 96 | condition = mCondition == ConditionState::kTrue; |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 97 | } |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 98 | |
tsaichristine | 69000e6 | 2019-10-18 17:34:52 -0700 | [diff] [blame] | 99 | // Stores atom id to primary key pairs for each state atom that the metric is |
| 100 | // sliced by. |
| 101 | std::map<int, HashableDimensionKey> statePrimaryKeys; |
| 102 | |
| 103 | // For states with primary fields, use MetricStateLinks to get the primary |
| 104 | // field values from the log event. These values will form a primary key |
| 105 | // that will be used to query StateTracker for the correct state value. |
| 106 | for (const auto& stateLink : mMetric2StateLinks) { |
| 107 | getDimensionForState(event.getValues(), stateLink, |
| 108 | &statePrimaryKeys[stateLink.stateAtomId]); |
| 109 | } |
| 110 | |
| 111 | // For each sliced state, query StateTracker for the state value using |
| 112 | // either the primary key from the previous step or the DEFAULT_DIMENSION_KEY. |
| 113 | // |
| 114 | // Expected functionality: for any case where the MetricStateLinks are |
| 115 | // initialized incorrectly (ex. # of state links != # of primary fields, no |
| 116 | // links are provided for a state with primary fields, links are provided |
| 117 | // in the wrong order, etc.), StateTracker will simply return kStateUnknown |
| 118 | // when queried using an incorrect key. |
| 119 | HashableDimensionKey stateValuesKey; |
| 120 | for (auto atomId : mSlicedStateAtoms) { |
| 121 | FieldValue value; |
| 122 | if (statePrimaryKeys.find(atomId) != statePrimaryKeys.end()) { |
| 123 | // found a primary key for this state, query using the key |
| 124 | getMappedStateValue(atomId, statePrimaryKeys[atomId], &value); |
| 125 | } else { |
| 126 | // if no MetricStateLinks exist for this state atom, |
| 127 | // query using the default dimension key (empty HashableDimensionKey) |
| 128 | getMappedStateValue(atomId, DEFAULT_DIMENSION_KEY, &value); |
| 129 | } |
| 130 | stateValuesKey.addValue(value); |
| 131 | } |
| 132 | |
Yangster-mac | e06cfd7 | 2018-03-10 23:22:59 -0800 | [diff] [blame] | 133 | HashableDimensionKey dimensionInWhat; |
| 134 | filterValues(mDimensionsInWhat, event.getValues(), &dimensionInWhat); |
tsaichristine | 69000e6 | 2019-10-18 17:34:52 -0700 | [diff] [blame] | 135 | MetricDimensionKey metricKey(dimensionInWhat, stateValuesKey); |
tsaichristine | 7685337 | 2019-08-06 17:17:03 -0700 | [diff] [blame] | 136 | onMatchedLogEventInternalLocked( |
| 137 | matcherIndex, metricKey, conditionKey, condition, event); |
Yangster-mac | 849dfdc2 | 2018-10-12 15:41:45 -0700 | [diff] [blame] | 138 | } |
Yangster | 13fb7e4 | 2018-03-07 17:30:49 -0800 | [diff] [blame] | 139 | |
Yangster-mac | 849dfdc2 | 2018-10-12 15:41:45 -0700 | [diff] [blame] | 140 | bool MetricProducer::evaluateActiveStateLocked(int64_t elapsedTimestampNs) { |
| 141 | bool isActive = mEventActivationMap.empty(); |
| 142 | for (auto& it : mEventActivationMap) { |
Muhammad Qureshi | 3a5ebf5 | 2019-03-28 12:38:21 -0700 | [diff] [blame] | 143 | if (it.second->state == ActivationState::kActive && |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 144 | elapsedTimestampNs > it.second->ttl_ns + it.second->start_ns) { |
Muhammad Qureshi | 3a5ebf5 | 2019-03-28 12:38:21 -0700 | [diff] [blame] | 145 | it.second->state = ActivationState::kNotActive; |
Yangster-mac | 849dfdc2 | 2018-10-12 15:41:45 -0700 | [diff] [blame] | 146 | } |
Muhammad Qureshi | 3a5ebf5 | 2019-03-28 12:38:21 -0700 | [diff] [blame] | 147 | if (it.second->state == ActivationState::kActive) { |
Yangster-mac | 849dfdc2 | 2018-10-12 15:41:45 -0700 | [diff] [blame] | 148 | isActive = true; |
| 149 | } |
| 150 | } |
| 151 | return isActive; |
| 152 | } |
| 153 | |
| 154 | void MetricProducer::flushIfExpire(int64_t elapsedTimestampNs) { |
| 155 | std::lock_guard<std::mutex> lock(mMutex); |
| 156 | if (!mIsActive) { |
| 157 | return; |
| 158 | } |
| 159 | mIsActive = evaluateActiveStateLocked(elapsedTimestampNs); |
| 160 | if (!mIsActive) { |
Muhammad Qureshi | 18e4692 | 2019-05-24 16:38:49 -0700 | [diff] [blame] | 161 | onActiveStateChangedLocked(elapsedTimestampNs); |
Yangster-mac | 849dfdc2 | 2018-10-12 15:41:45 -0700 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | |
Yangster-mac | 849dfdc2 | 2018-10-12 15:41:45 -0700 | [diff] [blame] | 165 | void MetricProducer::activateLocked(int activationTrackerIndex, int64_t elapsedTimestampNs) { |
| 166 | auto it = mEventActivationMap.find(activationTrackerIndex); |
| 167 | if (it == mEventActivationMap.end()) { |
| 168 | return; |
| 169 | } |
Muhammad Qureshi | 15f8da9 | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 170 | auto& activation = it->second; |
| 171 | if (ACTIVATE_ON_BOOT == activation->activationType) { |
| 172 | if (ActivationState::kNotActive == activation->state) { |
| 173 | activation->state = ActivationState::kActiveOnBoot; |
| 174 | } |
| 175 | // If the Activation is already active or set to kActiveOnBoot, do nothing. |
Chenjie Yu | a9a310e | 2019-02-06 13:40:10 -0800 | [diff] [blame] | 176 | return; |
| 177 | } |
Muhammad Qureshi | 15f8da9 | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 178 | activation->start_ns = elapsedTimestampNs; |
| 179 | activation->state = ActivationState::kActive; |
Muhammad Qureshi | 18e4692 | 2019-05-24 16:38:49 -0700 | [diff] [blame] | 180 | bool oldActiveState = mIsActive; |
Yangster-mac | 849dfdc2 | 2018-10-12 15:41:45 -0700 | [diff] [blame] | 181 | mIsActive = true; |
Muhammad Qureshi | 18e4692 | 2019-05-24 16:38:49 -0700 | [diff] [blame] | 182 | if (!oldActiveState) { // Metric went from not active to active. |
| 183 | onActiveStateChangedLocked(elapsedTimestampNs); |
| 184 | } |
Yangster-mac | 849dfdc2 | 2018-10-12 15:41:45 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Muhammad Qureshi | 3a5ebf5 | 2019-03-28 12:38:21 -0700 | [diff] [blame] | 187 | void MetricProducer::cancelEventActivationLocked(int deactivationTrackerIndex) { |
| 188 | auto it = mEventDeactivationMap.find(deactivationTrackerIndex); |
| 189 | if (it == mEventDeactivationMap.end()) { |
| 190 | return; |
| 191 | } |
Tej Singh | ee4495e | 2019-06-03 18:37:35 -0700 | [diff] [blame] | 192 | for (auto activationToCancelIt : it->second) { |
| 193 | activationToCancelIt->state = ActivationState::kNotActive; |
| 194 | } |
Muhammad Qureshi | 3a5ebf5 | 2019-03-28 12:38:21 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 197 | void MetricProducer::loadActiveMetricLocked(const ActiveMetric& activeMetric, |
| 198 | int64_t currentTimeNs) { |
Chenjie Yu | c7939cb | 2019-02-04 17:25:45 -0800 | [diff] [blame] | 199 | if (mEventActivationMap.size() == 0) { |
| 200 | return; |
| 201 | } |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 202 | for (int i = 0; i < activeMetric.activation_size(); i++) { |
| 203 | const auto& activeEventActivation = activeMetric.activation(i); |
| 204 | auto it = mEventActivationMap.find(activeEventActivation.atom_matcher_index()); |
| 205 | if (it == mEventActivationMap.end()) { |
| 206 | ALOGE("Saved event activation not found"); |
| 207 | continue; |
Chenjie Yu | a9a310e | 2019-02-06 13:40:10 -0800 | [diff] [blame] | 208 | } |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 209 | auto& activation = it->second; |
Tej Singh | cbf2c64 | 2019-06-07 17:23:30 -0700 | [diff] [blame] | 210 | // If the event activation does not have a state, assume it is active. |
| 211 | if (!activeEventActivation.has_state() || |
| 212 | activeEventActivation.state() == ActiveEventActivation::ACTIVE) { |
Tej Singh | f53d445 | 2019-05-09 18:17:59 -0700 | [diff] [blame] | 213 | // We don't want to change the ttl for future activations, so we set the start_ns |
| 214 | // such that start_ns + ttl_ns == currentTimeNs + remaining_ttl_nanos |
| 215 | activation->start_ns = |
| 216 | currentTimeNs + activeEventActivation.remaining_ttl_nanos() - activation->ttl_ns; |
| 217 | activation->state = ActivationState::kActive; |
| 218 | mIsActive = true; |
| 219 | } else if (activeEventActivation.state() == ActiveEventActivation::ACTIVATE_ON_BOOT) { |
| 220 | activation->state = ActivationState::kActiveOnBoot; |
| 221 | } |
Chenjie Yu | a9a310e | 2019-02-06 13:40:10 -0800 | [diff] [blame] | 222 | } |
Chenjie Yu | c7939cb | 2019-02-04 17:25:45 -0800 | [diff] [blame] | 223 | } |
| 224 | |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 225 | void MetricProducer::writeActiveMetricToProtoOutputStream( |
Tej Singh | f53d445 | 2019-05-09 18:17:59 -0700 | [diff] [blame] | 226 | int64_t currentTimeNs, const DumpReportReason reason, ProtoOutputStream* proto) { |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 227 | proto->write(FIELD_TYPE_INT64 | FIELD_ID_ACTIVE_METRIC_ID, (long long)mMetricId); |
| 228 | for (auto& it : mEventActivationMap) { |
| 229 | const int atom_matcher_index = it.first; |
| 230 | const std::shared_ptr<Activation>& activation = it.second; |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 231 | |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 232 | if (ActivationState::kNotActive == activation->state || |
| 233 | (ActivationState::kActive == activation->state && |
| 234 | activation->start_ns + activation->ttl_ns < currentTimeNs)) { |
| 235 | continue; |
Chenjie Yu | a9a310e | 2019-02-06 13:40:10 -0800 | [diff] [blame] | 236 | } |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 237 | |
| 238 | const uint64_t activationToken = proto->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | |
| 239 | FIELD_ID_ACTIVE_METRIC_ACTIVATION); |
| 240 | proto->write(FIELD_TYPE_INT32 | FIELD_ID_ACTIVE_EVENT_ACTIVATION_ATOM_MATCHER_INDEX, |
| 241 | atom_matcher_index); |
| 242 | if (ActivationState::kActive == activation->state) { |
| 243 | const int64_t remainingTtlNs = |
| 244 | activation->start_ns + activation->ttl_ns - currentTimeNs; |
| 245 | proto->write(FIELD_TYPE_INT64 | FIELD_ID_ACTIVE_EVENT_ACTIVATION_REMAINING_TTL_NANOS, |
| 246 | (long long)remainingTtlNs); |
Tej Singh | f53d445 | 2019-05-09 18:17:59 -0700 | [diff] [blame] | 247 | proto->write(FIELD_TYPE_ENUM | FIELD_ID_ACTIVE_EVENT_ACTIVATION_STATE, |
| 248 | ActiveEventActivation::ACTIVE); |
| 249 | |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 250 | } else if (ActivationState::kActiveOnBoot == activation->state) { |
Tej Singh | f53d445 | 2019-05-09 18:17:59 -0700 | [diff] [blame] | 251 | if (reason == DEVICE_SHUTDOWN || reason == TERMINATION_SIGNAL_RECEIVED) { |
| 252 | proto->write( |
| 253 | FIELD_TYPE_INT64 | FIELD_ID_ACTIVE_EVENT_ACTIVATION_REMAINING_TTL_NANOS, |
| 254 | (long long)activation->ttl_ns); |
| 255 | proto->write(FIELD_TYPE_ENUM | FIELD_ID_ACTIVE_EVENT_ACTIVATION_STATE, |
| 256 | ActiveEventActivation::ACTIVE); |
| 257 | } else if (reason == STATSCOMPANION_DIED) { |
| 258 | // We are saving because of system server death, not due to a device shutdown. |
| 259 | // Next time we load, we do not want to activate metrics that activate on boot. |
| 260 | proto->write(FIELD_TYPE_ENUM | FIELD_ID_ACTIVE_EVENT_ACTIVATION_STATE, |
| 261 | ActiveEventActivation::ACTIVATE_ON_BOOT); |
| 262 | } |
Muhammad Qureshi | 844694b | 2019-04-05 10:10:40 -0700 | [diff] [blame] | 263 | } |
| 264 | proto->end(activationToken); |
Chenjie Yu | a9a310e | 2019-02-06 13:40:10 -0800 | [diff] [blame] | 265 | } |
| 266 | } |
| 267 | |
tsaichristine | 69000e6 | 2019-10-18 17:34:52 -0700 | [diff] [blame] | 268 | void MetricProducer::getMappedStateValue(const int32_t atomId, const HashableDimensionKey& queryKey, |
| 269 | FieldValue* value) { |
| 270 | if (!StateManager::getInstance().getStateValue(atomId, queryKey, value)) { |
| 271 | value->mValue = Value(StateTracker::kStateUnknown); |
| 272 | ALOGW("StateTracker not found for state atom %d", atomId); |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | // check if there is a state map for this atom |
| 277 | auto atomIt = mStateGroupMap.find(atomId); |
| 278 | if (atomIt == mStateGroupMap.end()) { |
| 279 | return; |
| 280 | } |
| 281 | auto valueIt = atomIt->second.find(value->mValue.int_value); |
| 282 | if (valueIt == atomIt->second.end()) { |
| 283 | // state map exists, but value was not put in a state group |
| 284 | // so set mValue to kStateUnknown |
| 285 | // TODO(tsaichristine): handle incomplete state maps |
| 286 | value->mValue.setInt(StateTracker::kStateUnknown); |
| 287 | } else { |
| 288 | // set mValue to group_id |
| 289 | value->mValue.setLong(valueIt->second); |
| 290 | } |
| 291 | } |
| 292 | |
tsaichristine | b87ca15 | 2019-12-09 15:19:41 -0800 | [diff] [blame] | 293 | DropEvent MetricProducer::buildDropEvent(const int64_t dropTimeNs, const BucketDropReason reason) { |
| 294 | DropEvent event; |
| 295 | event.reason = reason; |
| 296 | event.dropTimeNs = dropTimeNs; |
| 297 | return event; |
| 298 | } |
| 299 | |
| 300 | bool MetricProducer::maxDropEventsReached() { |
| 301 | return mCurrentSkippedBucket.dropEvents.size() >= StatsdStats::kMaxLoggedBucketDropEvents; |
| 302 | } |
| 303 | |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 304 | } // namespace statsd |
| 305 | } // namespace os |
yro | 2b0f886 | 2017-11-06 14:27:31 -0800 | [diff] [blame] | 306 | } // namespace android |