Commit Graph

2233 Commits

Author SHA1 Message Date
Yao Chen
729093df0d 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
2017-10-19 15:40:55 -07:00
Yi Jin
6e66a2cf34 Merge "Fixed several bugs found for incidentd" 2017-10-19 00:16:54 +00:00
Yi Jin
22769e0123 Fixed several bugs found for incidentd
1. Add logging for proto can't be parsed by incident_report
2. Close opened file descriptor of incident report request!
3. Fix invalid syntax of auto-gen section_list.cpp

Bug: 67849582
Test: manually run incident and checks /proc/<its pid>/fd
Change-Id: I38e6ac28de09aca6243ad536ed41d8059e08ba24
2017-10-18 13:17:32 -07:00
Joe Onorato
c4dfae56c1 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
2017-10-18 04:19:04 -07:00
Joe Onorato
9fc9edf95a 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
2017-10-18 04:18:58 -07:00
TreeHugger Robot
37ed703d6b Merge changes from topic "resubmit_joeo_cl"
* changes:
  Fix build error.
  Revert "Revert "Start auto-generating the stats log API.""
2017-10-17 22:27:54 +00:00
TreeHugger Robot
ca6988e65b Merge "Update documentation for pm install / pm install-create" 2017-10-17 21:29:08 +00:00
Yao Chen
70b9863761 Fix build error.
Test: builds successfully.

Change-Id: I9ffefa28f37830319864e7b98d32340f59df0a62
2017-10-17 12:52:37 -07:00
Yao Chen
d54f9dd625 Revert "Revert "Start auto-generating the stats log API.""
Test: builds successfully

This reverts commit 9319453998.

Change-Id: I22bca4a32adf86040b9d72ad5b45999aba28f586
2017-10-17 10:42:44 -07:00
Dianne Hackborn
91a711baac Update documentation for pm install / pm install-create
Test: manual
Change-Id: I1b039c72719c48ac607ff25bc8698d2524ebf2b5
2017-10-16 17:37:38 -07:00
Joe Onorato
bcc8478d2b Merge "Revert "Start auto-generating the stats log API."" 2017-10-16 22:46:21 +00:00
Joe Onorato
9319453998 Revert "Start auto-generating the stats log API."
This reverts commit b81d1a7b9a.

Change-Id: I189684d8913ffffca42d9514ac88ea5cc4a44f05
2017-10-16 22:41:28 +00:00
Joe Onorato
22910ada9a Merge changes Idf402222,I8eb7e341
* changes:
  Start auto-generating the stats log API.
  Make bit able to build native tests.
2017-10-16 21:19:16 +00:00
Chih-hung Hsieh
e1e0785c38 Merge "Use -Werror in frameworks/base" am: 16fbd3a1d8 am: 0bfb717a37 am: 9f004b1752
am: decc397b26

Change-Id: Id4abbc6cb95b2eb96f535b6c1c5295cb27c9d2b0
2017-10-16 20:39:41 +00:00
Yi Jin
7215f94401 Merge "Use ProtoOutputStream to strip Pii sensetive fields in incidentd" 2017-10-16 20:22:34 +00:00
Chih-hung Hsieh
decc397b26 Merge "Use -Werror in frameworks/base" am: 16fbd3a1d8 am: 0bfb717a37
am: 9f004b1752

Change-Id: I6517ee1689b0247caf830a6c3528bfa9bcf91f75
2017-10-16 19:50:38 +00:00
Chih-hung Hsieh
0bfb717a37 Merge "Use -Werror in frameworks/base"
am: 16fbd3a1d8

Change-Id: Iab69cf4f99cf4bedd12eb7764c773a893bfe5343
2017-10-16 19:24:53 +00:00
Joe Onorato
b81d1a7b9a Start auto-generating the stats log API.
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
2017-10-15 20:25:19 -07:00
Chih-Hung Hsieh
c7edf078f9 Use -Werror in frameworks/base
* Fix unused variable and return value warnings.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I890e65a20848d00559ba5a4f9691be1347b456af
2017-10-13 16:25:16 -07:00
David Chen
f12b5c6789 Removes redundant RefBase inheritance.
PackageInfoListener already inherits from RefBase, so the
MetricsProducer doesn't need it also.

Test: Not needed.
Change-Id: I27fc4c214251ba07fefeacf76549a80c8368ffa5
2017-10-13 15:57:48 -07:00
Yi Jin
42711a0b4f Use ProtoOutputStream to strip Pii sensetive fields in incidentd
The in-place algorithm in ProtoOutputStream will have at most 2 copies
of possible nested message values incidentd is getting which makes it
more ram-efficient, and minimize allocations.

Bug: 65641021
Test: the units pass
Change-Id: Ic3fe99b7e27895bd613a129ba0f12ccfca4af317
2017-10-13 15:44:26 -07:00
Rob Carr
53966760d7 Merge "Use new SurfaceFlinger transaction API." 2017-10-12 22:08:03 +00:00
TreeHugger Robot
a69b6f29e0 Merge "AnomalyMonitor can get alarms based on timestamp" 2017-10-11 17:58:15 +00:00
Yi Jin
956ab6ac91 Merge "Implement go/streaming-proto native libs, part 2" 2017-10-11 17:51:37 +00:00
Bookatz
ece5f705d5 AnomalyMonitor can get alarms based on timestamp
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
2017-10-11 09:26:20 -07:00
David Pursell
1de1197993 Merge "iot bootaction: provide default lib name" 2017-10-11 15:49:24 +00:00
TreeHugger Robot
6edd1686e0 Merge "Fix a bug in SimpleConditionTracker." 2017-10-11 00:32:21 +00:00
Yi Jin
974a9c2885 Implement go/streaming-proto native libs, part 2
Implement ProtoOutputStream.h to write protobuf format data.

Usage of dumping proto:
ProtoOutputStream proto(fd);

proto.write(fieldId, value1); // dump a single value

// start to dump a message:
long long token = proto.start(messageFieldId);
proto.write(nestedField1, nestedValue1);
...
proto.end(token);

fieldId will be generated by protoc-cpp plugin(TBD). It is an encoded uint64_t
value, with 0 - 32 bits as its proto number, 33 - 40 bits reserved for
field type, int32, bool, string, message, etc. and 41 - 43 bits for
single, repeated or packed type. Currently packed field is not
supported.

Bug: 65641021
Test: N/A, need to wait for protoc-cpp plugin and will test in
incident_helper
Change-Id: Ic188615b950235aae0edeee4876b78d31feb5619
2017-10-10 17:16:34 -07:00
David Pursell
be09c954cb iot bootaction: provide default lib name
We want to provide a sane default for the bootaction library name so
that the developer isn't required to mess with read-only properties to
get this working.

Also small cleanup to remove duplicate and unused libs from Android.mk.

Bug: 67644323
Test: builds (master)
Test: properly loads default lib (nyc-iot-dev)
Test: logs and exits when lib doesn't exist (nyc-iot-dev)
Change-Id: I865a45f43b3594c99419e7e27c9798ee944d0db2
2017-10-10 16:51:01 -07:00
Yao Chen
4b1468538f Fix a bug in SimpleConditionTracker.
copy-paste bug

Test: manual. Will add unit tests for it.
Change-Id: I9494271a8a407b0f3c5fc0138c1afb4925c69b79
2017-10-10 15:34:42 -07:00
David Chen
de70169109 UID mapping to provide app name and version.
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
2017-10-10 14:33:23 -07:00
Yao Chen
caf339d004 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
2017-10-10 10:03:46 -07:00
Robert Carr
e13b58e15b Use new SurfaceFlinger transaction API.
For now we reimplement global transactions in the Java side
JNI layer.

Bug: 64815723
Bug: 64816140
Bug: 64815766
Test: Existing tests pass. go/wm-smoke
Change-Id: I6c0a7b5e65b1b6cc844ac61f3269629af60a4244
2017-10-09 16:52:48 -07:00
Chenjie Yu
16e9b10aa2 Merge "refactor statspuller" 2017-10-09 21:48:51 +00:00
TreeHugger Robot
4f99ad1e7b Merge "Statsd Anomaly tracking for CountMetricProducer" 2017-10-09 20:54:32 +00:00
Chenjie Yu
1a317baeda refactor statspuller
Test: manual test on device
Change-Id: Ibdec6a821e47cd2b2e7435002219c0b2e3f4c5d2
2017-10-09 12:47:45 -07:00
Bookatz
a4bc9c4a1e Statsd Anomaly tracking for CountMetricProducer
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
2017-10-04 14:03:02 -07:00
David Pursell
6a3078672d Merge "iot: extract boot parameter logic." 2017-10-03 18:32:20 +00:00
Stefan Lafon
3e595b07c4 Check in new version of stats_events.proto. Rename a field.
Test: The code compiles, and most changes are cosmetic.

Change-Id: Iae06d7bbbe0212067de4302d4004d89d45812176
2017-10-02 20:55:52 -07:00
David Pursell
54a8fe4bbe iot: extract boot parameter logic.
Currently the boot parameters are tied pretty tightly to the bootaction
functionality, but volume and brightness need to be set on the
bootanimation regardless of whether there's a bootaction or not.

Extract boot parameters into a separate class to make it easier to apply
volume/brightness in a future CL.

Bug: 65462981
Test: Manual test, can succesfully read params on boot.
Change-Id: I32daad64cb8aab39fcd0ca17503218e0605ccd27
(cherry picked from commit f78561e7bbe580d0f0dbca7a615c575973ef6ce4)
2017-10-02 17:52:24 -07:00
TreeHugger Robot
6214ad9f5f Merge "Statsd can pull kernel wakelock data" 2017-10-02 18:22:53 +00:00
Yi Jin
667ded2fc9 Merge "Implement c++ native lib for streaming proto, part 1" 2017-09-30 00:08:44 +00:00
Bookatz
c68a9d21b4 Statsd can pull kernel wakelock data
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
2017-09-29 15:10:47 -07:00
Yao Chen
44cf27c148 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
2017-09-29 12:52:41 -07:00
TreeHugger Robot
078208d235 Merge "Check in new protos and constants. Test: Started statsd and verified it outputs data. Also ran statsd tests." 2017-09-29 04:46:12 +00:00
Yi Jin
b5e4ddd16b Merge "Enable Diskstats Section" 2017-09-29 00:52:18 +00:00
TreeHugger Robot
dbc2bfeaf4 Merge "Finish removing ASEC." 2017-09-28 22:37:40 +00:00
Stefan Lafon
cdb1a0ed95 Check in new protos and constants.
Test: Started statsd and verified it outputs data. Also ran statsd tests.

Change-Id: I2a438b2ddfcb1576e21acb6159bea607fed7caaa
2017-09-28 14:38:31 -07:00
Yi Jin
a5c5e8a99b Enable Diskstats Section
Bug: 67019205
Test: manually tested in incident_report tool
Change-Id: I291d4b0b0c01385e57c6ad83a12678c0f8d8746b
2017-09-28 14:09:02 -07:00
Jeff Sharkey
f8bb2445ff Finish removing ASEC.
Awhile back we explicitly blocked any new ASEC installs, with the
expectation that we'd eventually remove the logic entirely.  We've
had them disabled for about a week now without incident, so let's
rip out the remaining code.

Test: bit FrameworksCoreTests:android.content.pm.PackageHelperTests
Test: bit FrameworksCoreTests:android.content.pm.PackageManagerTests
Bug: 32913676
Change-Id: I1ecc35487420731f5c4bdf03bca5751548ce51b3
2017-09-28 11:32:57 -06:00