blob: 7d3d661ca43357aae18740ee5d6ad41a12be29af [file] [log] [blame]
Yao Chen44cf27c2017-09-14 22:32:50 -07001/*
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
20#include <log/logprint.h>
Yao Chencaf339d2017-10-06 16:01:10 -070021#include <utils/RefBase.h>
22#include "../matchers/matcher_util.h"
Yao Chen44cf27c2017-09-14 22:32:50 -070023
24namespace android {
25namespace os {
26namespace statsd {
27
28// A MetricProducer is responsible for compute one single metrics, creating stats log report, and
29// writing the report to dropbox.
Yao Chencaf339d2017-10-06 16:01:10 -070030class MetricProducer : public virtual RefBase {
Yao Chen44cf27c2017-09-14 22:32:50 -070031public:
32 virtual ~MetricProducer(){};
33
Yao Chencaf339d2017-10-06 16:01:10 -070034 // Consume the parsed stats log entry that already matched the "what" of the metric.
Yao Chen44cf27c2017-09-14 22:32:50 -070035 virtual void onMatchedLogEvent(const LogEventWrapper& event) = 0;
36
Yao Chencaf339d2017-10-06 16:01:10 -070037 virtual void onConditionChanged(const bool condition) = 0;
38
Yao Chen44cf27c2017-09-14 22:32:50 -070039 // This is called when the metric collecting is done, e.g., when there is a new configuration
40 // coming. MetricProducer should do the clean up, and dump existing data to dropbox.
41 virtual void finish() = 0;
42
43 virtual void onDumpReport() = 0;
44};
45
46} // namespace statsd
47} // namespace os
48} // namespace android
49#endif // METRIC_PRODUCER_H