Yao Chen | 44cf27c | 2017-09-14 22:32:50 -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 | */ |
| 16 | |
| 17 | #ifndef METRIC_PRODUCER_H |
| 18 | #define METRIC_PRODUCER_H |
| 19 | |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 20 | #include <shared_mutex> |
| 21 | |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 22 | #include "HashableDimensionKey.h" |
Yangster-mac | e2cd6d5 | 2017-11-09 20:38:30 -0800 | [diff] [blame] | 23 | #include "anomaly/AnomalyTracker.h" |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 24 | #include "condition/ConditionWizard.h" |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 25 | #include "config/ConfigKey.h" |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 26 | #include "matchers/matcher_util.h" |
| 27 | #include "packages/PackageInfoListener.h" |
| 28 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 29 | #include <log/logprint.h> |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 30 | #include <utils/RefBase.h> |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 31 | #include <unordered_map> |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 32 | |
| 33 | namespace android { |
| 34 | namespace os { |
| 35 | namespace statsd { |
| 36 | |
| 37 | // A MetricProducer is responsible for compute one single metrics, creating stats log report, and |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 38 | // writing the report to dropbox. MetricProducers should respond to package changes as required in |
| 39 | // PackageInfoListener, but if none of the metrics are slicing by package name, then the update can |
| 40 | // be a no-op. |
David Chen | f12b5c6 | 2017-10-13 15:54:03 -0700 | [diff] [blame] | 41 | class MetricProducer : public virtual PackageInfoListener { |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 42 | public: |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 43 | MetricProducer(const int64_t& metricId, const ConfigKey& key, const int64_t startTimeNs, |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 44 | const int conditionIndex, const sp<ConditionWizard>& wizard) |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 45 | : mMetricId(metricId), |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 46 | mConfigKey(key), |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 47 | mStartTimeNs(startTimeNs), |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 48 | mCurrentBucketStartTimeNs(startTimeNs), |
Yang Lu | 3eba621 | 2017-10-25 19:54:45 -0700 | [diff] [blame] | 49 | mCurrentBucketNum(0), |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 50 | mCondition(conditionIndex >= 0 ? false : true), |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 51 | mConditionSliced(false), |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 52 | mWizard(wizard), |
Yangster | 13fb7e4 | 2018-03-07 17:30:49 -0800 | [diff] [blame] | 53 | mConditionTrackerIndex(conditionIndex), |
| 54 | mContainANYPositionInDimensionsInWhat(false), |
| 55 | mSameConditionDimensionsInTracker(false), |
| 56 | mHasLinksToAllConditionDimensionsInTracker(false) { |
| 57 | } |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 58 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 59 | virtual ~MetricProducer(){}; |
| 60 | |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 61 | /** |
| 62 | * Forces this metric to split into a partial bucket right now. If we're past a full bucket, we |
| 63 | * first call the standard flushing code to flush up to the latest full bucket. Then we call |
| 64 | * the flush again when the end timestamp is forced to be now, and then after flushing, update |
| 65 | * the start timestamp to be now. |
| 66 | */ |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 67 | void notifyAppUpgrade(const int64_t& eventTimeNs, const string& apk, const int uid, |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 68 | const int64_t version) override { |
| 69 | std::lock_guard<std::mutex> lock(mMutex); |
| 70 | |
| 71 | if (eventTimeNs > getCurrentBucketEndTimeNs()) { |
| 72 | // Flush full buckets on the normal path up to the latest bucket boundary. |
| 73 | flushIfNeededLocked(eventTimeNs); |
| 74 | } |
| 75 | // Now flush a partial bucket. |
| 76 | flushCurrentBucketLocked(eventTimeNs); |
| 77 | mCurrentBucketStartTimeNs = eventTimeNs; |
| 78 | // Don't update the current bucket number so that the anomaly tracker knows this bucket |
| 79 | // is a partial bucket and can merge it with the previous bucket. |
| 80 | }; |
| 81 | |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 82 | void notifyAppRemoved(const int64_t& eventTimeNs, const string& apk, const int uid) override{ |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 83 | // TODO: Implement me. |
| 84 | }; |
| 85 | |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 86 | void onUidMapReceived(const int64_t& eventTimeNs) override{ |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 87 | // TODO: Implement me. |
| 88 | }; |
| 89 | |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 90 | // Consume the parsed stats log entry that already matched the "what" of the metric. |
Chenjie Yu | a7259ab | 2017-12-10 08:31:05 -0800 | [diff] [blame] | 91 | void onMatchedLogEvent(const size_t matcherIndex, const LogEvent& event) { |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 92 | std::lock_guard<std::mutex> lock(mMutex); |
Chenjie Yu | a7259ab | 2017-12-10 08:31:05 -0800 | [diff] [blame] | 93 | onMatchedLogEventLocked(matcherIndex, event); |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 94 | } |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 95 | |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 96 | void onConditionChanged(const bool condition, const int64_t eventTime) { |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 97 | std::lock_guard<std::mutex> lock(mMutex); |
| 98 | onConditionChangedLocked(condition, eventTime); |
| 99 | } |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 100 | |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 101 | void onSlicedConditionMayChange(bool overallCondition, const int64_t eventTime) { |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 102 | std::lock_guard<std::mutex> lock(mMutex); |
Yao Chen | 427d372 | 2018-03-22 15:21:52 -0700 | [diff] [blame] | 103 | onSlicedConditionMayChangeLocked(overallCondition, eventTime); |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | bool isConditionSliced() const { |
| 107 | std::lock_guard<std::mutex> lock(mMutex); |
| 108 | return mConditionSliced; |
| 109 | }; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 110 | |
Yao Chen | 288c600 | 2017-12-12 13:43:18 -0800 | [diff] [blame] | 111 | // Output the metrics data to [protoOutput]. All metrics reports end with the same timestamp. |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 112 | // This method clears all the past buckets. |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 113 | void onDumpReport(const int64_t dumpTimeNs, android::util::ProtoOutputStream* protoOutput) { |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 114 | std::lock_guard<std::mutex> lock(mMutex); |
Yao Chen | 288c600 | 2017-12-12 13:43:18 -0800 | [diff] [blame] | 115 | return onDumpReportLocked(dumpTimeNs, protoOutput); |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 116 | } |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 117 | |
Yao Chen | 884c8c1 | 2018-01-26 10:36:25 -0800 | [diff] [blame] | 118 | void dumpStates(FILE* out, bool verbose) const { |
| 119 | std::lock_guard<std::mutex> lock(mMutex); |
| 120 | dumpStatesLocked(out, verbose); |
| 121 | } |
| 122 | |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 123 | // Returns the memory in bytes currently used to store this metric's data. Does not change |
| 124 | // state. |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 125 | size_t byteSize() const { |
| 126 | std::lock_guard<std::mutex> lock(mMutex); |
| 127 | return byteSizeLocked(); |
| 128 | } |
yro | 69007c8 | 2017-10-26 20:42:57 -0700 | [diff] [blame] | 129 | |
Bookatz | 1476ef2 | 2018-02-13 12:26:01 -0800 | [diff] [blame] | 130 | /* If alert is valid, adds an AnomalyTracker and returns it. If invalid, returns nullptr. */ |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 131 | virtual sp<AnomalyTracker> addAnomalyTracker(const Alert &alert, |
| 132 | const sp<AlarmMonitor>& anomalyAlarmMonitor) { |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 133 | std::lock_guard<std::mutex> lock(mMutex); |
Bookatz | 857aaa5 | 2017-12-19 15:29:06 -0800 | [diff] [blame] | 134 | sp<AnomalyTracker> anomalyTracker = new AnomalyTracker(alert, mConfigKey); |
| 135 | if (anomalyTracker != nullptr) { |
| 136 | mAnomalyTrackers.push_back(anomalyTracker); |
| 137 | } |
| 138 | return anomalyTracker; |
Yangster-mac | e2cd6d5 | 2017-11-09 20:38:30 -0800 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | int64_t getBuckeSizeInNs() const { |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 142 | std::lock_guard<std::mutex> lock(mMutex); |
Yangster-mac | e2cd6d5 | 2017-11-09 20:38:30 -0800 | [diff] [blame] | 143 | return mBucketSizeNs; |
| 144 | } |
| 145 | |
yro | 59cc24d | 2018-02-13 20:17:32 -0800 | [diff] [blame] | 146 | // Only needed for unit-testing to override guardrail. |
| 147 | void setBucketSize(int64_t bucketSize) { |
| 148 | mBucketSizeNs = bucketSize; |
| 149 | } |
| 150 | |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 151 | inline const int64_t& getMetricId() { |
| 152 | return mMetricId; |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 153 | } |
| 154 | |
Yao Chen | 06dba5d | 2018-01-26 13:38:16 -0800 | [diff] [blame] | 155 | // Let MetricProducer drop in-memory data to save memory. |
| 156 | // We still need to keep future data valid and anomaly tracking work, which means we will |
| 157 | // have to flush old data, informing anomaly trackers then safely drop old data. |
| 158 | // We still keep current bucket data for future metrics' validity. |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 159 | void dropData(const int64_t dropTimeNs) { |
Yao Chen | 06dba5d | 2018-01-26 13:38:16 -0800 | [diff] [blame] | 160 | std::lock_guard<std::mutex> lock(mMutex); |
| 161 | dropDataLocked(dropTimeNs); |
| 162 | } |
| 163 | |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 164 | protected: |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 165 | virtual void onConditionChangedLocked(const bool condition, const int64_t eventTime) = 0; |
Yao Chen | 427d372 | 2018-03-22 15:21:52 -0700 | [diff] [blame] | 166 | virtual void onSlicedConditionMayChangeLocked(bool overallCondition, |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 167 | const int64_t eventTime) = 0; |
| 168 | virtual void onDumpReportLocked(const int64_t dumpTimeNs, |
Yao Chen | 288c600 | 2017-12-12 13:43:18 -0800 | [diff] [blame] | 169 | android::util::ProtoOutputStream* protoOutput) = 0; |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 170 | virtual size_t byteSizeLocked() const = 0; |
Yao Chen | 884c8c1 | 2018-01-26 10:36:25 -0800 | [diff] [blame] | 171 | virtual void dumpStatesLocked(FILE* out, bool verbose) const = 0; |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 172 | |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 173 | /** |
| 174 | * Flushes the current bucket if the eventTime is after the current bucket's end time. |
| 175 | */ |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 176 | virtual void flushIfNeededLocked(const int64_t& eventTime){}; |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 177 | |
| 178 | /** |
| 179 | * For metrics that aggregate (ie, every metric producer except for EventMetricProducer), |
| 180 | * we need to be able to flush the current buckets on demand (ie, end the current bucket and |
| 181 | * start new bucket). If this function is called when eventTimeNs is greater than the current |
| 182 | * bucket's end timestamp, than we flush up to the end of the latest full bucket; otherwise, |
| 183 | * we assume that we want to flush a partial bucket. The bucket start timestamp and bucket |
| 184 | * number are not changed by this function. This method should only be called by |
| 185 | * flushIfNeededLocked or the app upgrade handler; the caller MUST update the bucket timestamp |
| 186 | * and bucket number as needed. |
| 187 | */ |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 188 | virtual void flushCurrentBucketLocked(const int64_t& eventTimeNs){}; |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 189 | |
| 190 | // Convenience to compute the current bucket's end time, which is always aligned with the |
| 191 | // start time of the metric. |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 192 | int64_t getCurrentBucketEndTimeNs() const { |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 193 | return mStartTimeNs + (mCurrentBucketNum + 1) * mBucketSizeNs; |
| 194 | } |
| 195 | |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 196 | virtual void dropDataLocked(const int64_t dropTimeNs) = 0; |
Yao Chen | 06dba5d | 2018-01-26 13:38:16 -0800 | [diff] [blame] | 197 | |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 198 | const int64_t mMetricId; |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 199 | |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 200 | const ConfigKey mConfigKey; |
| 201 | |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 202 | // The time when this metric producer was first created. The end time for the current bucket |
| 203 | // can be computed from this based on mCurrentBucketNum. |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 204 | int64_t mStartTimeNs; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 205 | |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 206 | // Start time may not be aligned with the start of statsd if there is an app upgrade in the |
| 207 | // middle of a bucket. |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 208 | int64_t mCurrentBucketStartTimeNs; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 209 | |
David Chen | 27785a8 | 2018-01-19 17:06:45 -0800 | [diff] [blame] | 210 | // Used by anomaly detector to track which bucket we are in. This is not sent with the produced |
| 211 | // report. |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame^] | 212 | int64_t mCurrentBucketNum; |
Yang Lu | 3eba621 | 2017-10-25 19:54:45 -0700 | [diff] [blame] | 213 | |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 214 | int64_t mBucketSizeNs; |
| 215 | |
| 216 | bool mCondition; |
| 217 | |
| 218 | bool mConditionSliced; |
| 219 | |
| 220 | sp<ConditionWizard> mWizard; |
| 221 | |
| 222 | int mConditionTrackerIndex; |
| 223 | |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 224 | vector<Matcher> mDimensionsInWhat; // The dimensions_in_what defined in statsd_config |
| 225 | vector<Matcher> mDimensionsInCondition; // The dimensions_in_condition defined in statsd_config |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 226 | |
Yangster | 13fb7e4 | 2018-03-07 17:30:49 -0800 | [diff] [blame] | 227 | bool mContainANYPositionInDimensionsInWhat; |
| 228 | |
| 229 | // True iff the condition dimensions equal to the sliced dimensions in the simple condition |
| 230 | // tracker. This field is always false for combinational condition trackers. |
| 231 | bool mSameConditionDimensionsInTracker; |
| 232 | |
| 233 | // True iff the metric to condition links cover all dimension fields in the condition tracker. |
| 234 | // This field is always false for combinational condition trackers. |
| 235 | bool mHasLinksToAllConditionDimensionsInTracker; |
| 236 | |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 237 | std::vector<Metric2Condition> mMetric2ConditionLinks; |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 238 | |
Yangster-mac | e2cd6d5 | 2017-11-09 20:38:30 -0800 | [diff] [blame] | 239 | std::vector<sp<AnomalyTracker>> mAnomalyTrackers; |
| 240 | |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 241 | /* |
| 242 | * Individual metrics can implement their own business logic here. All pre-processing is done. |
| 243 | * |
| 244 | * [matcherIndex]: the index of the matcher which matched this event. This is interesting to |
| 245 | * DurationMetric, because it has start/stop/stop_all 3 matchers. |
| 246 | * [eventKey]: the extracted dimension key for the final output. if the metric doesn't have |
| 247 | * dimensions, it will be DEFAULT_DIMENSION_KEY |
| 248 | * [conditionKey]: the keys of conditions which should be used to query the condition for this |
Stefan Lafon | a5b5191 | 2017-12-05 21:43:52 -0800 | [diff] [blame] | 249 | * target event (from MetricConditionLink). This is passed to individual metrics |
Yao Chen | b704177 | 2017-10-20 16:59:25 -0700 | [diff] [blame] | 250 | * because DurationMetric needs it to be cached. |
| 251 | * [condition]: whether condition is met. If condition is sliced, this is the result coming from |
| 252 | * query with ConditionWizard; If condition is not sliced, this is the |
| 253 | * nonSlicedCondition. |
| 254 | * [event]: the log event, just in case the metric needs its data, e.g., EventMetric. |
| 255 | */ |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 256 | virtual void onMatchedLogEventInternalLocked( |
Yangster-mac | 9369446 | 2018-01-22 20:49:31 -0800 | [diff] [blame] | 257 | const size_t matcherIndex, const MetricDimensionKey& eventKey, |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 258 | const ConditionKey& conditionKey, bool condition, |
Chenjie Yu | a7259ab | 2017-12-10 08:31:05 -0800 | [diff] [blame] | 259 | const LogEvent& event) = 0; |
yro | 2b0f886 | 2017-11-06 14:27:31 -0800 | [diff] [blame] | 260 | |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 261 | // Consume the parsed stats log entry that already matched the "what" of the metric. |
Yangster-mac | 5392888 | 2018-02-25 23:02:56 -0800 | [diff] [blame] | 262 | virtual void onMatchedLogEventLocked(const size_t matcherIndex, const LogEvent& event); |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 263 | |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 264 | mutable std::mutex mMutex; |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 265 | }; |
| 266 | |
| 267 | } // namespace statsd |
| 268 | } // namespace os |
| 269 | } // namespace android |
| 270 | #endif // METRIC_PRODUCER_H |