Commit Graph

3062 Commits

Author SHA1 Message Date
TreeHugger Robot
bbc057444f Merge "Adds option to drop small buckets for statsd." into pi-dev 2018-04-17 19:12:33 +00:00
TreeHugger Robot
c3116634e1 Merge "Free allocated varargs" into pi-dev 2018-04-17 19:08:26 +00:00
Yi Jin
480de784a3 Free allocated varargs
Bug: 78173836
Test: atest incidentd_test
Change-Id: I1e1b9f63d0e863c733c51efef432235eb94cdbab
2018-04-17 10:47:31 -07:00
TreeHugger Robot
0f0c9243be Merge "Fix incidentd skip collecting timedout of a section." into pi-dev 2018-04-17 16:22:20 +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
Yi Jin
98ce81050b Fix incidentd skip collecting timedout of a section.
By moving the section stats collection before any return statements,
it won't missing stats collection.

Bug: 77962855
Test: atest incidentd_test
Change-Id: I0900556428c51636e24df48a407eb916ccff795c
2018-04-16 13:42:48 -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
TreeHugger Robot
a991071db9 Merge "Reduce disk space limit for incident reports." into pi-dev 2018-04-13 20:34:31 +00:00
TreeHugger Robot
9a58caaaff Merge "Add tests to cover handling negative varint." into pi-dev 2018-04-12 23:36:29 +00:00
Yi Jin
ba7ee6ff11 Add tests to cover handling negative varint.
The gtest will fail if the fix of b/77291057 isn't there. Should make
this change in with the fix, but later than none.

Bug: 77291057
Test: atest incidentd_test
Change-Id: I48ece311f78ee18d97486839a3b8b434c9419cf3
2018-04-12 22:59:41 +00:00
Yi Jin
91d4330202 Reduce disk space limit for incident reports.
Bug: 77963176
Test: atest incidentd_test and manual
Change-Id: I8ad1d10fcd40ff556255ac27c049265e79c7d558
2018-04-12 11:06:57 -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
72a39eb3be Merge "This cl tries to fix cts tests IncidentdTest" into pi-dev 2018-04-05 18:48:59 +00: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
Yi Jin
ad3e6e5d5a This cl tries to fix cts tests IncidentdTest
1. Disable BatteryType section which is device-specific
2. Make timeout longer since meminfo section timedout in test
3. make some negative values sint
4. varint can be 64 bits, there is a bug implicitly convert it to 32
which loses values.
5. Found another bug which failed to read 64 bits varint, create a
native test to make sure it works.

Bug: 77291057
Test: atest CtsIncidentHostTestCases:com.android.server.cts.IncidentdTest
Change-Id: I04cc730741f7901f37ac57a11af7777d57118a23
2018-04-04 16:29:55 -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
TreeHugger Robot
60a24b97f7 Merge "Add fileds to AppCrash and ANR atoms" into pi-dev 2018-04-03 02:31:27 +00: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
Chenjie Yu
f17bf62f2f Add fileds to AppCrash and ANR atoms
Bug: 77487218
Change-Id: I13fe87c9811e248ed0ee87c64d482c9463d6b9a1
Fix: 77487218
Test: cts test
2018-04-02 15:30:47 -07:00
Yi Jin
ea31cbea93 Remove some letters of verbose log
Bug: 77333635
Test: N/A
Change-Id: I94b288d070dfb372edf345d369d75bb3255f631b
2018-04-02 11:09:57 -07:00
TreeHugger Robot
56051569ab Merge "Use modern c++ code style for incidentd." into pi-dev 2018-04-02 18:01:15 +00:00
TreeHugger Robot
46eef8d049 Merge "E2e test for periodic alarm." into pi-dev 2018-03-31 03:04:59 +00:00
TreeHugger Robot
2f6f33fa79 Merge "Null pointer check for Bluetooth traffic" into pi-dev 2018-03-31 01:18:34 +00:00
TreeHugger Robot
3b826c6075 Merge "Statsd MAX now obeys refractory periods too" into pi-dev 2018-03-31 01:10:57 +00:00
Yi Jin
6cacbcbf43 Use modern c++ code style for incidentd.
This cl does not contain code logic changes.

Bug: 77333635
Test: manual and incidentd_test
Change-Id: Iea0a402b1051defd45159ca267e6dd705f9ffa49
2018-03-30 17:36:49 -07:00
Chenjie Yu
9e59f93a21 Null pointer check for Bluetooth traffic
Bug: 77340376
Change-Id: I558c020636564437e040097a2d0f86519c343c4a
Fix: 77340376
Test: manual test
2018-03-30 16:45:33 -07:00
Bookatz
0dbc7a4343 Statsd MAX now obeys refractory periods too
The logic of where refractory period enforcement was moved out of the
anomaly tracker and into the metric's predictAnomalyTimestamp. It was
done for ORING, but not for MAX. This fixes MAX.

Bug: 74446029
Test: adb sync data && adb shell data/nativetest64/statsd_test/statsd_test
Change-Id: I51e43c7c132f424af8fe20a37f2ad10cc55b5989
2018-03-30 16:21:17 -07:00
TreeHugger Robot
014432cb67 Merge "Guardrail for dimension in condition in duration tracker." into pi-dev 2018-03-30 21:27:11 +00:00
Howard Ro
ea16812ad2 Merge "Remove bad configs by counting the number of statsd deaths" into pi-dev 2018-03-30 20:58:51 +00:00
Yi Jin
1ebfc94aa1 Merge "Use unique_fd with the clear ownership." into pi-dev 2018-03-30 20:53:30 +00:00
TreeHugger Robot
9fef2594f3 Merge "Clean up atoms.proto" into pi-dev 2018-03-30 20:48:09 +00:00