Both native and java bindings.
TODOs:
- Finish WorkSources.
- Clean up the package names for the protos.
- Put the protos in a more suitable location.
Test: stats-log-api-gen-test
Change-Id: Idf4022225e2be05106dbcf7de8e97a3337fc63e2
PackageInfoListener already inherits from RefBase, so the
MetricsProducer doesn't need it also.
Test: Not needed.
Change-Id: I27fc4c214251ba07fefeacf76549a80c8368ffa5
When StatsCompanion informs statsd that an anomaly alarm has fired,
statsd will need to check to see whether an anomaly has indeed occurred.
This will require determining which anomaly alarms have times in the
past (since that indicates that the anomaly did indeed occur). This
capability is now added.
Test: adb shell data/nativetest64/statsd_test/statsd_test
Change-Id: I5464c94634df70832d2723d8c4718277776d58aa
The UID map is updated by StatsCompanionService, which listens to broadcast
updates indicating that an app was updated/installed or removed. Also,
the entire map is updated when statsd first connects to the companion
service. Also, there is a way for metrics producers to subscribe to
updates, so that they can know when an app was upgraded.
Test: Created new unit-test for mapping and manually tested for install
and remove. Did not manually test the app upgrade.
Change-Id: I6676ae5c93b75c72d9badabb36aa9c40006db07d
+ 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
CountMetricProducer now has a CountAnomalyTracker which stores past
bucket information. Anomalies can be determined by seeing if the
information from the past and current buckets exeeds a threshold.
Test: manual
Change-Id: I35103c01dd32dcc31cb155f5685161cbaf969d03
When statsd is told that it is time to poll data, it asks
StatsCompanionService to pull kernel wakelock data, receives the result
(as a string), and outputs it to screen.
Still to do:
1. don't use a string; use a parcel instead
2. don't output it to screen; do something useful instead
3. do more than just kernel wakelocks
4. pull data on demand, in addition to just on periodic pulling
Test: added setPollingAlarms to statsd.main and confirmed that kernel
wakelock information was written to screen
Change-Id: I35f5164420699dea1a00c9e530b938904f1d3055
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
Includes matching for both simple and compound matchers.
Change-Id: Id913d2625d205ad9a529019e98ae805f730f4d48
Test: Added new unit-tests and checked on marlin device.
Added .clang-format, because there isn't an official .clang-format file for Android framework code.
before we upload changes, do:
clang-format -style=file -i [file list]
to format the files that you touched.
Test: formatting only. NO code changes.
Change-Id: I90e87f1ee6618da8ea9bc2221c609c415a4046a8
Statsd code now lives in android::os::statsd namespace. Existing files
are largely modified to follow this convention.
Exception: parse_util, since it seems a bit different.
Test: code compiles and existing statsd_tests still pass
Change-Id: Idf92a071b9ed172d01eb3087a4fa3609d67a038c
If statsd or statsdcompanion crashes, or if one loads
before the other, the other will be able to accomodate.
When statsd loads, it will attempt to tell statscompanion that it's
alive, and then get on to its business, while assuming that
statscompanion is not alive. Only when statscompanion tells statsd
that it is alive, statsd will then start to use it.
When statscompanion loads, it will attempt to tell statsd that it's
alive and then do nothing (since it has nothing to do). When statsd
tells statscompanion that statsd is alive, statscompanion will respond,
telling statsd that it is alive and, if that binder call returns, will
get to work.
This way, if statsd loads first, it can work unobstructed until
statscompanion informs statsd that it is alive, at which point they
shake hands and work. Conversely, if statscompanion loads first, it will
do nothing until statsd contacts it, at which point they will shake
hands and work.
Test: manual
Change-Id: I969ad47fb8060e27814d05ad37433a02711cfa6a
StatsCompanionService can now inform statsd that an alarm (for anomaly
alerting and for polling) has fired, so that statsd can act accordingly.
Test: manual created an alarm from statsd.main and checked logcat that
statsd received the broadcast that it fired
Change-Id: I1d33dfbee0d3e213c91dd6973d2622ecacc890c8
must be in serialized binary format. Also fixes small issue
in build rule related to proto lib.
Test: Manually tested that ADB command works without crashing.
Change-Id: Iba2e677561ff500adb601a598f73e8a7b32540e5
Created a new class, indexed_priority_queue, which is a priority queue
that allows the removal of elements (other than just the top element).
This is required for AnomalyMonitor, which will henceforth use it.
Some tests for this new class are included.
I have only implemented the methods in indexed_priority_queue that are
currently needed. For example, pop_top() has not been written as
AnomalyMonitor does not need it.
Test: adb shell data/nativetest64/statsd_test/statsd_test
Change-Id: I82fe220ee5a879189b0cfa03b551c829cfdd05f0
Created AnomalyMonitor in statsd, which can monitor statsd's internal
anomaly alarms and register the soonest one with the
StatsCompanionService.
This cl introduces the AnomalyMonitor and allows it to register alarms.
It does not yet allow for the removal of internal alarms.
Test: manually added alarms and ensured they were correctly registered
in StatsCompanionService
Change-Id: Iff324c73751c4f43b1507dc64649b50ac388adef
+ The DropboxWriter keeps data in cache, and flush to files once the
size exceeds the maximum value.
+ Different components should create their owner DropboxWriter with
different tags, e.g., anomly detection, experiment metrics, etc.
+ Copied stats_log related protos from g3
Test: run statsd, and adb shell dumpsys dropbox
Will add unit tests.
Change-Id: If06e9a9953be32082252b340a97124d732656b40
statsd. The numbers should be replaced with protobuf enums and the
format is subject to changes. But this gets it working for now.
Test: flash with new image, statsd should print out events. toggle
screen on from off state will add a log entry
Change-Id: I733e249965689f00597232c0e3eccfd26e1a958c
It doesn't start yet by default. When you start it manually, it sets
itself up as a binder system service and starts a thread to read the
event log.
Test: Run statsd, observe output. also run stats_test
Change-Id: If435d6a80fef3c1d957aedb61699bf5e9aae7e56