Add support for dimension, and link with condition and added DurationMetric
Now we support following metrics:
<Duration> of [app holding a wake lock], while [*this app*] is [in background] [AND] [screen is off]
[Slice] the output by [app name, wake lock name], with bucket size [30sec]
+ Also added onDumpReport() api in MetricsManager, it can be called from client to fetch the data from
statsd
+ Also added command line tool to dump the StatsLogReport from all metrics for debugging.
+ Synced proto from google3. with a pending cl (cr/172359050)
TODO: We need to add tons of tests to test the Metrics. I will work on it after this CL so people
can be unblocked.
I locally test the duration metric with wake lock with an app that generates StatsLog events.
Test: statsd_test
and manual test, and run:
adb shell cmd stats dump-report
We have a default config, which contains a metrics to count PROCESS_START event sliced by
package name.
Change-Id: I4838cc6cf025c143b7e84f43040703a78121fd25
diff --git a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp
index 71078ea..b2c88a0 100644
--- a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp
+++ b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG true // STOPSHIP if true
+#define DEBUG false // STOPSHIP if true
#include "Log.h"
#include "SimpleLogMatchingTracker.h"
@@ -34,10 +34,12 @@
SimpleLogMatchingTracker::SimpleLogMatchingTracker(const string& name, const int index,
const SimpleLogEntryMatcher& matcher)
: LogMatchingTracker(name, index), mMatcher(matcher) {
- for (int i = 0; i < matcher.tag_size(); i++) {
- mTagIds.insert(matcher.tag(i));
+ if (!matcher.has_tag()) {
+ mInitialized = false;
+ } else {
+ mTagIds.insert(matcher.tag());
+ mInitialized = true;
}
- mInitialized = true;
}
SimpleLogMatchingTracker::~SimpleLogMatchingTracker() {
@@ -48,7 +50,7 @@
const unordered_map<string, int>& matcherMap,
vector<bool>& stack) {
// no need to do anything.
- return true;
+ return mInitialized;
}
void SimpleLogMatchingTracker::onLogEvent(const LogEvent& event,