History log of /frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
1c58f04cd34291584b7bf2b45a54427e0ef650c8 18-May-2018 Yangster-mac <yanglu@google.com> Add a field in config to disable/enable the string hashing in metric report.

Statsd hashes (using its own hashing function) raw strings to reduce the
upload data size when there are duplicate strings in the report. And in cloud,
the clearcut translator would backfill the strings.

In a few droidfood users, we find the translator was unable to do that. While
debugging the root cause, we first decided to provide an option to disable
the hashing from the cloud.

Test: statsd unit test, CTS test, tested manually

BUG: b/79943763
Change-Id: If0359c8cf3f3cf83a2938db9ebf95ea7906f0b0c
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
3f57b16deb78134cf4690819a844f4d941c01710 10-May-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Skip writing metrics to disk if it's entirely composed of no_report_metric" into pi-dev
028091cb15f5e8290eed77a222582162d19a3d87 10-May-2018 yro <yro@google.com> Skip writing metrics to disk if it's entirely composed of
no_report_metric

Test: unit test, cts
Bug: 79488249
Change-Id: I3e13a6271cc36665a43d0f09d8663e5996224477
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
9e6dbbdadf8de3bcc58a6c26784219217cd35b53 08-May-2018 David Chen <dwchen@google.com> Fix statsd returning uidmap with empty reports.

We notice devices uploading a bunch of bytes for the uidmap even if
the device is running an empty config, so there are no actual metrics
to report. This hardcodes some logic to skip the inclusion of the
uidmap if there are exactly 0 metrics.

Bug: 79381210
Test: Tested unit-tests on marlin-eng
Change-Id: I96348235341a7faf15ff57d4d1eccac635a3a999
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
48944901f7e6334724efadda6c6b27d9e88fc9e2 03-May-2018 David Chen <dwchen@google.com> Fixes statsd returning too much data at once.

We observe a single ConfigMetricsReportList can be greater than the
safe size for the binder transaction buffer since we only check the
size of the current metrics in progress, but we also return the
previous reports stored on disk.

This change will attempt to send another ConfigMetricsReportList
as soon as possible if there's already a report on disk.

Also fixes a bug when trying to trigger data fetch before the client
has registered the corresponding dataFetchOperation.

Bug: 79201869
Test: Tested manually on marlin-eng
Change-Id: I2d3677162804a27e7a7a95d482d80c46bd994a67
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
9def8e3995b1034d943a0fd22b6e512bfacdab77 17-Apr-2018 Yangster-mac <yanglu@google.com> Reduce statsd log data size.

1. Hash the strings in metric dimensions.
2. Optimize the timestamp encoding in bucket.
Use bucket num for full bucket and millis for
partial bucket.
3. Encode the dimension path per metric and avoid
deduping it across dimensons.

Test: statsd test
Change-Id: I18f69654de85edb21a9c835c73edead756295e05
BUG: b/77813755
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
15f6bbc24f4d7a3d4481d90a18df33d402ddacba 08-Apr-2018 Yangster-mac <yanglu@google.com> Flush the bucket when creating the metric producer.
Use int64 for value field.
E2e test for gauge/value metric.

BUG: b/74445671

Test: statsd test.
Change-Id: I823a0bade8f89834bdfb9cf48864852a47d7b63b
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
e68f3a5811209eeab71976bc583c6075d9a5979a 04-Apr-2018 Yangster-mac <yanglu@google.com> Flush the partial bucket when startd shuts down or config updated.

Test: statsd test

BUG: b/77556036
Change-Id: Ie4a04ace55e07c4529cdff5906ba874f8815f620
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
b142cc8add29c8c97f6134d35873d23db666027c 31-Mar-2018 Yangster-mac <yanglu@google.com> Statsd config TTL

Roughly check the config every hour to see whether the ttl expired.
If so, read the config from disk and recreate the metric manager.

Test: statsd test

BUG: b/77274363

Change-Id: I16838afe5bbe966c3a0f638869751f9b59a5a259
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
faa1af535bf6ede5fcab2e0bad5f6c16908916a9 31-Mar-2018 David Chen <dwchen@google.com> Includes annotations with statsd reports.

It's tricky to determine the source of the metrics on a device
currently since we can take the union of multiple configs and send
only one giant statsd_config into statsd. We will use the int64 field
to track the sub config id's and the int32 field to track the version
for each sub config, but the fields are named more generically as
annotations.

The annotations are available in both the reports and metadata.

Test: Check that all unit-tests pass on marlin-eng
Bug: 77327261
Change-Id: Ic37c549c8b2991676f69948c515156765c9f5108
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
c04feba805c5acde92638a062cc13030fc4d3308 02-Apr-2018 Yangster-mac <yanglu@google.com> Move forward the alarm timestamp when config is added to statsd.

Test: statsd test
BUG: b/77344187

Change-Id: Ieacffaa29422829b8956f2b3fcb2c647c8c3eed9
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
684d195227bf9eaeb21698cbdcf865afb570c454 25-Mar-2018 Yangster-mac <yanglu@google.com> E2e test for periodic alarm.

Test: new test

BUG: b/76281156
Change-Id: I60cb28baaeec6996e946a7cb3358ec8e0aca80e5
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
be10ddfe46ba6371bcd02cb57a06782e6b18d371 13-Mar-2018 Yangster-mac <yanglu@google.com> Flush the past buckets in anomaly tracker when time jumps forward

E2e test for count/duration anomaly trackers.

Test: new statsd tests.

BUG: b/74446029

Change-Id: Ia9be0240ba5021d44c1e1f096d67563e9138bb59
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
a825c8ee5d3b0c2dac954f2994d70968759eb1d2 15-Mar-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Support slicing by chain." into pi-dev
e06cfd777a501eca17f8dd796b32ad61002c5875 11-Mar-2018 Yangster-mac <yanglu@google.com> Support slicing by chain.

BUG: b/73975181

Test: statsd test
Change-Id: I913ae0f68ff21ed0703bb5da9c60d3eaa3bf5981
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
3fa5d7fb236f263125bc6364ea693e5e9f122976 11-Mar-2018 Yangster-mac <yanglu@google.com> Add wall clock timestamp for ConfigMetricsReport and gauge atoms.

Fix the bug when serializing multiple atoms in gauge metric

BUG: b/74159560

Test: new test for ALL_CONDITION_CHANGES sampling method.
Change-Id: I6d33c1efbac92b6e13be2d64c323e090cb1f84aa
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
13fb7e4eeaf7aee408821afe7ee55a5167e49e59 08-Mar-2018 Yangster <yanglu@google.com> Statsd cpu optimizaton

- cache the changed dimensions in condition tracker.
- avoid query condition wizard when unnecessary.
- avoid copy dimension keys in condition key generation.

Test: statsd tests.

BUG: b/73959649
Change-Id: I17d68e2a82643de3f421309841e75f84c6fd8f43
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
06dba5d79c096b02d3ba6fb73e64451ff12e388d 26-Jan-2018 Yao Chen <yaochen@google.com> Add API to let metrics directly drop data without writing to an output.

+ Metrics will do flushIfNeeded() to correctly move the clock and informing
AnomalyTracker the past bucket info, and then clear past buckets.

+ We will still keep the current bucket data for the validity of the future metrics.

Bug: 70571383
Test: statsd_test
Change-Id: Ib13c45574974e7b4e82bd8f305091dc93bda76f5
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
932ececa1674c59a8da9f3e32d2651e781b86fc4 01-Feb-2018 Yangster-mac <yanglu@google.com> Alarm: wakes up statsd and notifies the subscribers.

Test: manually tested it.
Change-Id: Id796a68976aeb1611183023ba4e9c6a8b8c44bb8
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
8a8d16ceea1e5b7a2f8c41e17b5d993035f50f5d 08-Feb-2018 Yao Chen <yaochen@google.com> Statsd CPU optimization.

The key change is to revamp how we parse/store/match a log event, especially how we match repeated
field and attribution nodes, and how we construct dimensions and compare them.

+ We use a integer to encode the field of a log element. And also encode the FieldMatcher into an
integer and a bit mask. The log matching becomes 2 integer operations.

+ Dimension is stored as encoded field and value pair. Checking if 2 dimensions are equal is then
becoming checking if the underlying integers are equal. The integers are stored contiguously
in memory, so it's much faster than previous tree structure.

Start review from FieldValue.h

Test: statsd_test + new unit tests

Bug: 72659059

Change-Id: Iec8daeacdd3f39ab297c10ab9cd7b710a9c42e86
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
16049578001364e1fcb0f10d6f94868081e57316 02-Feb-2018 David Chen <dwchen@google.com> Modifies statsd output for start and end times.

We include the start of when the last dump occurred and the current
timestamp. These timestamps are shared across all metrics, so
there's no advantage in duplicating these numbers across all metrics.

Also, we should use elapsed realtime instead of times based on wall
clock, which can jump around and go backwards.

Test: Test that statsd can still build and
adb shell cmd stats dump-report doesn't crash.
Change-Id: I819e5643cee75dfa3e78a58f94c9d61ededa78d7
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
27785a8a4a684c831c18f7189a6fa1b98c3573e6 20-Jan-2018 David Chen <dwchen@google.com> Partial buckets on app upgrade and fix duration.

Statsd will create partial buckets in all metrics producers when an
app is upgraded so that we can separate metrics between different
versions of an app. By looking at the uid map changes, we can tell
which app versions belong to a bucket; for metrics that are not
affected by an app version, we can instead join the buckets together.

To simplify the logic, the ends of the full buckets are always
aligned to when the metric producers were created. These boundaries
are computed on the fly by using the bucket number and the metric
producers' start times.

We keep the anomaly trackers to only be given full buckets; we buffer
the partial buckets within each metric producer.

Duration metric's MAX_SPARSE is fixed to be implemented as such. In
addition, after further discussion, we find anomaly detection on
MAX_SPARSE to be unnecessary, so this functionality is removed.

Test: Unit-tests added and modified, passed on marlin-eng.
Change-Id: I5ff7a9c7f05c406e9faf400c6a39162970ded102
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
9369446f0b04945d6674550728ae81196d6fb5c2 23-Jan-2018 Yangster-mac <yanglu@google.com> Support dimension in condition in metric producers.

Test: added e2e tests for count/duration metrics sliced by fields in condition and with/without links.

Change-Id: Ie34deba68e6780abdde458be3f0ce5284e76a1a2
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
884c8c130fde0d02ada1316f7c27f0f55e7e48b9 26-Jan-2018 Yao Chen <yaochen@google.com> Add more statsd's debugging info to dumpsys.

+ Bugreport will use the non-verbose mode
+ Reuse the log_msg object in LogReader
+ Add logd errors to StatsdStats

Bug: 72383073

Test: manual + statsd_test

Change-Id: Id5a8b103074d034f5ece3c9831c740d44a5df9cd
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
87718e283a62660eaa0e39fd780c97a290da988f 12-Jan-2018 Yangster-mac <yanglu@google.com> Gauge metric e2e test

Test: new test passed
Change-Id: I6a8bceb43fbb6e7b82f47951e71b5620779f2ceb
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
b5bc74122fb95c81bedad625160fb8d144a863cd 07-Jan-2018 Yangster-mac <yanglu@google.com> E2e test: attribution matching and slicing by attribution.

Test: statsd unit tests passed.
Change-Id: I05875b80a9a1ab5f87a478d1f63543f9798254a5
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
147ce6027880d05286f051f1501100a4ce2b52e8 22-Dec-2017 Yao Chen <yaochen@google.com> use only string type in the log source whitelist.

+ predefined "AID_X" will be provided as string type to statsd, and we will translate
to integer uid using the static map.

Test: statsd_test

Change-Id: Ie47d8481e0c456457e6881ebb9cb4ce008e772b8
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
94e197cceb2ba7df13ff8de04f60bfeec64015d9 03-Jan-2018 Yangster-mac <yanglu@google.com> 1/ Change all "name" to id in statsD.
2/ Handle Subscription for alert.
3/ Support no_report_metric

Bug: 69522276
Test: all statsd unit tests passed.
Change-Id: I851b235f2d149b8602b0cad632d5bf541962f40a
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
2087716f2bdca90c7c3034d556ac12911bd8018e 23-Dec-2017 Yangster-mac <yanglu@google.com> 1/ Support nested message and repeated fields in statsd.
2/ Filter gauge fields by FieldMatcher.
3/ Wire up wakelock attribution chain.
4/ e2e test: wakelock duration metric with aggregated predicate dimensions.
5/ e2e test: count metric with multiple metric condition links for 2 predicates and 1 non-sliced predicate.

Test: statsd unit test passed.

Change-Id: I89db31cb068184a54e0a892fad710966d3127bc9
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
d10f7b1c7bdb1c66aa04148945cae9733ee4cadf 18-Dec-2017 Yao Chen <yaochen@google.com> Add log source filtering in statsd to filter out spams.

+ Add log source whitelist in StatsdConfig
+ Some changes in UidMap API. Listener needs to be wp instead of sp.
+ Update dogfood app config to have log source
+ Increase the stats service thread pool size to 10 (9+1).

TODO: add unit tests(b/70805664). This unit test takes some time to write.

Test: statsd_test & manual

Change-Id: I129b1cc13db5114db7417580962bd7cc4438519d
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
85ed8387135849f256cecb4429c75938ad91cd55 15-Dec-2017 Chenjie Yu <cjyu@google.com> align metrics to 5min bundary
We use one alarm clock for all pulled atoms.
If metrics from different configs are not aligned,
the clock will be set to repeat at higher and higher
frequency, and consume a lot of battery.
Current implementation assumes a 5min minimum bucket
size. New metric start time is set to be aligned to
the start time of statsd in the next 5min.
So it will ignore events up to 5min.

align puller alarm to minute bundary

Test: unit test
Change-Id: I77ffa3c13de363c780b1000181b9a9b780dd0846
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
288c60001330a5a924a47c0eebd6097ae3ee5d67 12-Dec-2017 Yao Chen <yaochen@google.com> Only create ProtoOutputStream when onGetData() is called.

The exception is EventMetricProducer. Each EventMetricProducer will still have a ProtoOutputStream
Because LogEvent comes as a fixed 4K, it's more memory efficient to have an 8k ProtoOutputStream for
storing the events.

Also removed finish() api in MetricProducer, which was intended to use with Dropbox.

Test: statsd_test & dogfood app
Bug: 70393808
Change-Id: I2efe4ecc76a88060a9aa5eb49d1fa6ea60bc5da8
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
d9269e2ee70b01cad3dda14c786e0e4434192248 05-Dec-2017 David Chen <dwchen@google.com> Adds rate limit to checking byte size.

Since there is a separate guardrail for memory used by uid map, we
no longer add the memory from uid map with the memory per each
config's metrics. We also prevent the byte size check from happening
too frequently. In order to mock the MetricsManager, we refactor
some of the existing methods.

Test: Added unit-tests and verified they all pass on marlin.
Change-Id: I15cf105f7d95f4016fdb0443b0a33eebe862cafb
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
b8c9aa8c9ccba4e64759c177381b742ca99a5487 03-Dec-2017 Stefan Lafon <stlafon@google.com> Rename a few things in statsd_config.proto.

This for frameworks/base/

SimpleLogEntryMatcher -> SimpleAtomMatcher.
simple_log_entry_matcher -> simple_atom_matcher
LogEntryMatcher -> AtomMatcher
log_entry_matcher -> atom_matcher

Test: Ran statsd_test.

Change-Id: I7398758e3fab86235897c162884f5ceab3002510
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
cc5adef2d0c5f96a225fd69517fd1eecb557f46d 21-Nov-2017 Bookatz <bookatz@google.com> Statsd anomaly detection - fixes

Fixes a few items in AnomalyTracker, especially to do with what happens
when an anomaly alarm fires.

Test: unit tests still pass
Change-Id: Ia89bd617442e952e587336b890c3ca67430b5e21
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
b356151e63140085cb96fa16804ee18b3862a4fc 22-Nov-2017 Yao Chen <yaochen@google.com> Add StatsdStats and guardrail.

+ StatsdStats is the global class that tracks the stats about statsd.

+ Added guardrail for classes that have a map which could potentially grow
unboundedly with the number of logs.

TODO: add unit tests & CTS for StatsdStats, and guardrail
add stats for pulled atoms.

Test: statsd_test

Change-Id: I0ea562de4dd3f6162f7923a9c193420b482c1d51
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
756cd48749eb63592b4cf8f6e16f7366debec054 22-Nov-2017 Yangster-mac <yanglu@google.com> Set the metric name for alerts in fake config and add a test to make sure the fake config is valid..

Test: unit test passed.
Change-Id: I1879fc523cca9fc6c672332ab4ac383f21dc16fc
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
e2cd6d509b17894b95d14523ae3e7c4c7a9a74e3 10-Nov-2017 Yangster-mac <yanglu@google.com> 1/ Duration anomaly tracker with alarm.
2/ Init anomaly from config based on the public language.
3/ Unit tests for anomaly detection in count/gauge producer.
4/ Revisit the duration tracker logic.

Test: unit test passed.
Change-Id: I2423c0e0f05b1e37626954de9e749303423963f2
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
1d7b0cd6b54e3b3ec8efdffd47b40cdd54c4e8d7 15-Nov-2017 David Chen <dwchen@google.com> Support StatsD sending broadcasts.

StatsD will send a broadcast when we're 90% of the way to our
allocated memory limit for the configuration. If the memory usage
goes over the limit, we just lose all the data for this config.

Also modifies the adb shell commands to facilitate debugging of the
broadcasts.

Test: Manually tested on marlin-eng with custom gmscore code.

Change-Id: I517a15bd4c959aa221802f84a51f13141a725102
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
17adac9cf3e03ad95372eb8657b26909d0414ac0 09-Nov-2017 yro <yro@google.com> Finish migrating to use ProtoOutputStream. This change will take the
outputs of each MetricProducer's and merge the results into
ConfigMetricsReport which holds ConfigKey, repeated field of
StatsLogReport, and UidMap. The data will be represented as
vector<uint8_t> which can be passed down to binder call for clients to
pick up. Also, all unnecessary dependencies to stats_log proto have been
removed.

Test: statsd, statsd_test
Change-Id: Ia69137cbc8613644a892e6be1e87b4858bd39fe3
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
93fe3a34a02c673eaee4a2d18565ba8df20685cb 02-Nov-2017 Yao Chen <yaochen@google.com> Add unit tests for CountMetricProducer, EventMetricProducer

And other miscellaneous fixes.
+ clang-format
+ 2 bug fixes, one in dump-report command, one in ResourcePowerManagerPuller

Test: statsd_test

Change-Id: Ibd164d948ad62adcc529d813df1210781e38be47
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
69007c82625dd8b19bd68d1031191e2ff83b5f49 27-Oct-2017 yro <yro@google.com> Implement a logic to rate limitted flush statsd with by checking the
size of each MetricsProducer's. The implementation of byteSize() method
is still TBD as it depends on migration to ProtoOutputStream.

Test: statsd, statsd_test
Change-Id: I966606044d7cb814dabe94192bacecad91f28177
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
d3606c79ca58e96a1919292bc139b34351dd272f 19-Oct-2017 Bookatz <bookatz@google.com> Anomaly detection for count reads from config

Count anomaly detection now reads in parameters from the config.
Also adds refractory period.

Test: Manually, using ConfigManager's fake config
Change-Id: I5618c0c6dcd6ef35e14d32315d5ea75ba58f0031
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
729093df0dd7d7038ad43b16ecdb59a1404f3b50 16-Oct-2017 Yao Chen <yaochen@google.com> 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
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
c4dfae56c10a1dd571baa78c750f2e68c919d74f 18-Oct-2017 Joe Onorato <joeo@google.com> Introduce a new wrapper for log_msg -- LogEvent

It stores all of the parsed fields in a single vector, and
provides accessor methods to get at fields by index with
their correct type.

Test: statsd_test
Change-Id: I4fa94e4ce52db3ac87f19b62f9c85398de6e8145
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
9fc9edf95a308f5884bf541cac81ce1f41aba0ba 16-Oct-2017 Joe Onorato <joeo@google.com> Clean up how we handle configurations, and other assorted cleanup

- Add a ConfigManager class that tracks the configurations
that have been passed to us. Configurations are now
tracked by tuples of (uid,tag), where the tag is an
app-defined string, in case a single uid has multiple
configurations.
- Move all of the initialization into StatsService.
- Get rid of the ability to have multiple LogListeners. Raw
events are now pushed directly into StatsService, which
can distribute them to the interested parties (and will
eventually be able to do the proper locking).
- Add Log.h, which sets our LOG_TAG correctly.
- Move some of the related files that I expect will grow some
into their own subdirectories.

Test: statsd_test
Test: adb shell cmd stats config ...
Test: adb shell dumpsys stats
Change-Id: I79487603003d8a842d5bd319741f1ecbf72063d1
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
caf339d004fad667748b68912c254df4e75cdc5a 07-Oct-2017 Yao Chen <yaochen@google.com> More complete implementation for condition and log matchers in statsd.

+ also synced proto from google3 to fix the LogEntryMatcher proto

+ MetricsManager represents StatsdConfig, it's responsible for initializing and managing all
LogEntryMatcher, Condition, and Metrics. Start review from here.

+ Added more complete StatsdConfig initialization, including building the map for:
LogEntryMatcher -> Metrics
LogEntryMatcher -> Condition
Condition -> Metrics.

All the maps use index(int). The extra amount of memory for storing mappings help us
quickly process log events.

The StatsdConfig initialization process detects malformed config
- Circle dependency
- Missing definition
etc.

And once we detect ANY error, statsd will reject the config. And the resources related to this
config will be released.

Test: Added unit tests
Change-Id: I2c4aefdbf3e2aa1701eacbb2fb5e653819ec1fbb
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h
44cf27c14880005df093f372491c593e1a9a3c58 15-Sep-2017 Yao Chen <yaochen@google.com> Add metric computation skeleton to statsd.

This cl is to let statsd understand statsd_config, and compute metrics
defined in the config.

+ StatsLogProcessor is given a StatsdConfig (hard coded right now).
We construct a MetricProducer for each of the metric, and the metrics
share Condition and LogEntryMatchers

+ Added the CountMetricProducer type for CountMetric.

We can now count times of SCREEN_ON events given a config.

TODO: 1) conditions are not implemented.
2) slicings are not implemented in CountMetric
3) move the interaction to dropbox to a separate thread
4) decide how the in memory metrics would be used by anomaly detection

Test: manual test.

$ adb shell /system/bin/statsd

$ cat config_file.dat | adb shell cmd stats config

Change-Id: I38f4059c0dc5a827c338131d4a6fa7d4cbe865db
/frameworks/base/cmds/statsd/src/metrics/MetricsManager.h