816 Commits

Author SHA1 Message Date
android-build-team Robot
b096a34428 Merge "Reset statsd and correctly record the dump reason when system server restarts/crashes." into pi-dev am: ec41a069fd
am: c1d985cf8b

Change-Id: I4df0cd841757ed13a9f7bf0f5bbf4d2df8ff0fb2
2018-05-03 20:15:56 -07:00
android-build-team Robot
7b744af70f Merge "Turns DEBUG to false in statsd." into pi-dev am: 1e9761df82
am: 77e1d3fc95

Change-Id: I59e2723e423748e24a5985d7db8377ce0588aef0
2018-05-03 20:07:48 -07:00
android-build-team Robot
ec41a069fd Merge "Reset statsd and correctly record the dump reason when system server restarts/crashes." into pi-dev 2018-05-04 02:43:03 +00:00
Yangster-mac
892f3d3229 Reset statsd and correctly record the dump reason when system
server restarts/crashes.

Test: statsd test
BUG: b/79161505
Change-Id: I0646c764964f6eafde91f9ae0179a1c837af320d
2018-05-03 17:05:24 -07:00
Yangster-mac
754e29edd7 Turns DEBUG to false in statsd.
Test: statsd test
BUG: b/79161505
Change-Id: Ic6eee527d625b10aa86b2beb4b4c4fc05b051c7d
2018-05-03 21:19:39 +00:00
Yao Chen
876889cb76 Add cmd to let statsd print all logs it received for debugging.
It only works on eng build. And all code is behind a build flag, so the
code will be stripped out in production builds.

Bug: 78239479
Test: manual
Change-Id: I20ee51822d18e6c77ca324a5327712cbed09593e
2018-05-03 10:53:27 -07:00
Yang Lu
890db383f9 Merge "Lock the pulling alarm handler." into pi-dev am: 493bb2b119
am: 2eccd835de

Change-Id: I4c488e49c74021459b4a86ba9d596bed2e2007c1
2018-05-02 14:31:12 -07:00
Yang Lu
493bb2b119 Merge "Lock the pulling alarm handler." into pi-dev 2018-05-02 18:25:18 +00:00
android-build-team Robot
b5371d441f Merge "Reduce statsd log data size." into pi-dev am: b85e5616df
am: f308d98f79

Change-Id: I2ac1c09c4473eb31ed163395272b6ccfaba51917
2018-05-01 18:05:39 -07:00
android-build-team Robot
b85e5616df Merge "Reduce statsd log data size." into pi-dev 2018-05-02 00:45:51 +00:00
android-build-team Robot
c1b66305a6 Merge "Increase the bytes per config threshold to avoid too frequent uploading." into pi-dev am: e442db3e40
am: 80c93aed29

Change-Id: I9580a5cdccda24c7e5d7c586e783be90703c3de0
2018-05-01 14:39:36 -07:00
android-build-team Robot
e442db3e40 Merge "Increase the bytes per config threshold to avoid too frequent uploading." into pi-dev 2018-05-01 21:02:32 +00:00
android-build-team Robot
f370ee41fc Merge "Clear the past buckets for no-report metrics" into pi-dev am: c0775117c4
am: 6e7821ec66

Change-Id: Ief582aa48afcfb0c6fe5b683bfa5b4ffa20ac80a
2018-04-30 17:42:46 -07:00
Yangster-mac
9def8e3995 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
2018-04-26 04:30:18 -07:00
Yangster-mac
a802d73da6 Clear the past buckets for no-report metrics
Test: statsd tests.
BUG: b/78503732
Change-Id: I3de855929ad05677769cffaae4fea2db0d2f32da
2018-04-24 08:07:20 -07:00
George Burgess IV
ef8262cedf [statsd] Fix a memory leak
Reported by the static analyzer:
frameworks/base/cmds/statsd/src/main.cpp:81:16: warning: Potential leak
of memory pointed to by 'data' [clang-analyzer-cplusplus.NewDeleteLeaks]

Bug: None
Test: Built with the static analyzer; warning disappeared.
Change-Id: Icf2cfb4bc4b397d8664e91ddb6c6e346c33ec4ac
2018-04-23 10:18:34 -07:00
Yao Chen
49954cd681 Add socket listener to statsd. And remove Davey atom.
+ The socket listener is behind a flag. It's disabled until we get sepolicy changes in.
+ Data parsing code is from logd, because we use the same format.

+ Removed Davey from JankTracker because it violates our new sepolicy

Test: manually
Bug: 78239479

Change-Id: Ib17729fbc362cdb13385f780e2d636a95adf9bc3
2018-04-20 17:41:25 -07:00
Yao Chen
f7bc6ab7fa Allow StatsLog to directly write to statsd's socket.
+ Reuse the log_event_list from liblog. StatsLog's binary format remains unchanged
+ Copied socket write code from liblog, including the retry logic.
+ Added build flags to control the StatsLog channel (logd, statsd, or both for debugging)

Bug: 78239479
Test: locally tested and saw logs being written to statsd

Change-Id: I7b1f0069ead00bbf3c29e4bd5b7f363a7ce26abe
2018-04-20 14:52:01 -07:00
Yangster-mac
db185c94cc Increase the bytes per config threshold to avoid
too frequent uploading.

BUG: b/77813755
Test: statsd test
Change-Id: I2b7b9292edf2c7d607f1ae6af4d52b104cd8443a
2018-04-19 11:31:03 -07:00
TreeHugger Robot
a194a6bee3 Merge "add dump report reason to reports" into pi-dev 2018-04-18 20:35:29 +00:00
Chenjie Yu
e36018b272 add dump report reason to reports
+ also change uidmapping version numbers to int64_t

Bug: 78132855
Change-Id: Iac7ea93e4bf651bd65bd03383e7ab4971af4fc29
Fix: 78132855
Test: gts test
2018-04-18 20:19:21 +00:00
TreeHugger Robot
2abcea2b8a Merge "Fix merge isolated uid to host uid" into pi-dev 2018-04-18 17:07:13 +00:00
Chenjie Yu
728d52a6db Fix merge isolated uid to host uid
Bug: 78190783
Fix: 78190783
Test: unit test
Change-Id: I71b5c575bf3c226509ebf088cb5dd961acd93459
2018-04-17 15:24:52 -07:00
TreeHugger Robot
bbc057444f Merge "Adds option to drop small buckets for statsd." into pi-dev 2018-04-17 19:12:33 +00:00
David Chen
81245fd53a Adds option to drop small buckets for statsd.
We notice that some of the pulled metrics have a ton of data, and
during app upgrades, we're forming partial buckets that represent
small periods of time but require many bytes of data. We now have an
option to drop these buckets that are too short. Note that we still
have to pull the data to keep the metrics for the next bucket
correct. We include a new field in the value and gauge metric outputs
so that it's easy to tell when a bucket was dropped.

We drop the partial buckets also from anomaly detection since we
should be computing anomalies from the same data that is reported.

Test: Added unit-tests for value and gauge metrics.
Bug: 77925710
Change-Id: Ic370496377c6afd380e02278a6c1ed8b521a2731
2018-04-16 18:42:14 -07:00
Tej Singh
abdf6e8039 Merge "Enforce dump permission in stats service" into pi-dev 2018-04-17 01:34:47 +00:00
Jeff Sharkey
936c0868f8 Merge "Protect usage data with OP_GET_USAGE_STATS." into pi-dev 2018-04-17 00:04:53 +00:00
Tej Singh
dd83d70371 Enforce dump permission in stats service
Enforces the dump permission in stats service and fixes a typo in an
enum name.

Bug: b/77723108
Test: adb shell dumpsys stats as root and not root
Test: build success on marlin (and cts build success)
Change-Id: I131f97fe4fd370d50bc4ad369377f6adcca5f6ae
2018-04-16 15:04:28 -07:00
Jeff Sharkey
6b64925737 Protect usage data with OP_GET_USAGE_STATS.
APIs that return package usage data (such as the new StatsManager)
must ensure that callers hold both the PACKAGE_USAGE_STATS permission
and the OP_GET_USAGE_STATS app-op.

Add noteOp() method that can be called from native code.

Also add missing security checks on command interface.

Bug: 77662908, 78121728
Test: builds, boots
Change-Id: Ie0d51e4baaacd9d7d36ba0c587ec91a870b9df17
2018-04-16 12:44:32 -06:00
David Chen
d37bc23f50 Adds a code when statsd sends intent to getData.
If the data receiver is experiencing delays, there may be a queue of
multiple intents to collect the same data. This timestamp makes it
easy in the receiver to de-dupe these requests to call getData.

Also, we update how StatsCompanionService gets the snapshot by
requesting data for all known apps. I notice that Keep seems to have
a uid active even when it appears uninstalled.

Bug: 77981668
Test: Flashed marlin-eng and manually verified.
Change-Id: I509e19383ec4a5da8746dd0c76ac71a948c6877d
2018-04-13 17:01:13 -07:00
Yangster
6df5fcc126 Lock the pulling alarm handler.
Test: statsd test

BUG: b/77906846

Change-Id: I414771a20babfb2324e47dd8ddbb44eaa088d199
2018-04-13 09:03:20 -07:00
TreeHugger Robot
6b317915e8 Merge "StatsManager throws exceptions" into pi-dev 2018-04-11 17:02:06 +00:00
Yao Chen
163d2602db Handle logd reconnect.
When statsd reconnects to logd, statsd will read all logs from buffer again. To prevent us from
reprocessing old events, we do the following:

1. At any given moment, record the largest timestamp(T_max) and last timestamp (check point) that
   we've seen before.
2. When reconnection happens, we look for the check point until we see a new log with a timestamp
   larger than T_max.
   -> If we found the CP, resume after the CP. Success
   -> If we can't find CP, there is definitely log loss. We reset all configs.

Note:
1. Logd has an API to read logs after a certain timestamp. But this api is vulnerable to
time changes from Settings. So we cannot rely on it.

2. If logd inserts a new log (with older timestamp) before CP, we cannot detect it. It's not
   possible to detect it without record all timestamps we have seen.

Test: statsd_test
Bug: 77813113

Change-Id: Ic3fdb47230807606ab11dc994cb162194adb8448
2018-04-10 22:06:03 -07:00
Yangster-mac
15f6bbc24f 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
2018-04-10 20:25:13 -07:00
Bookatz
4f71629002 StatsManager throws exceptions
When StatsManager fails to connect to statsd, it now throws an exception
for the caller to catch. It also throws an exception of the config being
added is of an unreadable format.

Due to backwards compatibility issues, the old APIs could not be
changed, so new ones were made to replace the old ones. The old ones are
now temporary and will be removed when the compatibility issue is
resolved.

Bug: 77648233
Test: gts-tradefed run gts-dev --module GtsStatsdHostTestCases
Change-Id: Ibea05883a29b9b3ef9927d2f8fe295eb99832ab7
2018-04-10 19:07:32 -07:00
Chenjie Yu
ae63b0af94 Drop value if the bucket is totally tainted
Bug: 77870358
Change-Id: Ia96970a3254de08f94b91ad53be2fdb9f4db7eb4
Fix: 77870358
Test: unit test
2018-04-10 14:59:31 -07:00
Tej Singh
c63fdfe02c Merge "Add proto output of statsd stats in adb" into pi-dev 2018-04-06 20:42:22 +00:00
Yangster-mac
e68f3a5811 Flush the partial bucket when startd shuts down or config updated.
Test: statsd test

BUG: b/77556036
Change-Id: Ie4a04ace55e07c4529cdff5906ba874f8815f620
2018-04-05 18:05:57 -07:00
David Chen
203bbbf942 Merge "Fix uid map to be simpler and fix partial bucket." into pi-dev 2018-04-05 23:43:45 +00:00
David Chen
bd12527c90 Fix uid map to be simpler and fix partial bucket.
The previous scheme captured periodic snapshots for each config with
complex logic that's unnecessary and wasted memory. We actually don't
need to store any snapshots since we just convert the current state
into a snapshot and also include the deltas (change events) since the
previous report until now.

To make the system more robust, we also include up to 100 of the
deleted apps in the uid map.

Also, fix the wiring of the partial buckets so the metric producers
form partial buckets on both app upgrade and removal, but not on
installation of a new app.

Also, we update StatsCompanionService to also include disabled apps.

Bug: 77607583
Test: Verified unit-tests pass and added new e2e tests.
Change-Id: I98e1f544d6e6571545ae1581c4cebab807596f51
2018-04-05 16:15:01 -07:00
Tej Singh
41b3f9a8cf Add proto output of statsd stats in adb
Test: statsd unit tests
Test: visually verified output of adb shell cmd stats print-stats was
sane
Test: making a CTS test that uses proto output
Bug: b/77548658

Change-Id: Ie60d66b9883f109446745dfcef97b7fb6194a1ac
2018-04-05 14:09:05 -07:00
TreeHugger Robot
164a73e0cf Merge "Retry logs write when it fails. Report skipped event in statsd." into pi-dev 2018-04-05 18:04:18 +00:00
Yangster-mac
b8382a10a0 Retry logs write when it fails.
Report skipped event in statsd.

Test: manual test
BUG: b/77222120
Change-Id: I257f5e76d557893c4eb4a8e8a13396d8b5d1afc0
2018-04-04 17:53:48 -07:00
Tej Singh
5260eea5e4 BugFix: Config TTL
In statsStats, we were writing the config TTL reset time to the wrong
proto field number. This fixes that.

Bug: b/77604625
Test: unit tests, pending CTS test
Change-Id: I9f6e502bf13785bfa60d68805d46b9a5c2286f44
2018-04-04 17:34:30 -07:00
Yangster-mac
b142cc8add 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
2018-04-04 15:59:43 +00:00
David Chen
faa1af535b 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
2018-04-03 18:20:40 -07:00
TreeHugger Robot
287fec6358 Merge "Atoms: remove bluetooth a2dp" into pi-dev 2018-04-03 19:48:33 +00:00
TreeHugger Robot
7219f8bac8 Merge "Move forward the alarm timestamp when config is added to statsd." into pi-dev 2018-04-03 17:57:43 +00:00
Tej Singh
02200f9969 Atoms: remove bluetooth a2dp
We are punting this atom. remove it from atoms.proto

Test: build success on marlin
Bug: b/73971848
Change-Id: Ia2da3d673f8d6078304f6bd0d20dbe3c34f079da
2018-04-02 19:37:59 -07:00
Yangster-mac
c04feba805 Move forward the alarm timestamp when config is added to statsd.
Test: statsd test
BUG: b/77344187

Change-Id: Ieacffaa29422829b8956f2b3fcb2c647c8c3eed9
2018-04-02 18:12:36 -07:00