317 Commits

Author SHA1 Message Date
Tej Singh
16ca28fc8e StatsdStats: improve activation time logging
Add logging to record whenever the 10 second guardrail for sending
active configs changed broadcast is met, so that we know when the
broadcast would not have been sent.
Add activation time for configs that are active when the device boots.
This will help determine whether or not statsd thinks configs are active
and will help debug issues like b/133809948

Bug: 133809948
Test: bit statsd_test:*
Test: manually rebooted to make sure activation time was logged
Change-Id: Ifa72202bc52485e4953e49d78dffea685cc3d1e7
2019-06-25 13:52:58 -07:00
Tej Singh
ee4495e6e2 Allow same matcher to cancel >1 event activation
Previously,we could only have one deactivation matcher for a given
metric. This meant that the same matcher could not be used to cancel
several (or all) event activations of a metric. This fixes that bug.

Test: bit statsd_test:*
Bug: 134185513
Change-Id: I9d74878c9e09bd1f58c8f3dcffe1092edf490329
2019-06-04 13:03:38 -07:00
Yao Chen
6d647b78d3 Merge "Fix a bug in saving local history of the metrics report." into qt-dev 2019-06-04 03:31:15 +00:00
Yao Chen
5c10cb48a9 Fix a bug in saving local history of the metrics report.
A condition was reversed in code refactoring during previous code review.

Test: unit tests added for all 4 combination cases.
Bug: 134417583
Change-Id: Id79a827ec7a5404b9006769f9595de773b4724ef
2019-06-03 15:02:30 -07:00
Muhammad Qureshi
18e469298e Handle condition changes when metric is not active.
Treat metric activation like conditions as much as possible. Keep track
of condition changes even when metric is not active. Right now, we
ignore all condition changes if metric is not active.

This is a band-aid fix. Ideally, we should re-think how metric activation is
implemented and consider implementing it as a condition with a timebomb.

Bug: 130838341
Test: statsd_test
Test: cts-tradefed run cts-dev -m CtsStatsdHostTestCases -t
android.cts.statsd.metric

Change-Id: I96bb7a7c6ee88359f310065e166f858be945eaff
2019-05-31 15:38:36 -07:00
Tej Singh
f53d445cef Persist active metric status across system server
Previously, all metrics/configs would deactivate on system server death.
Now, active status is restored.

Bug: 129717537
Test: bit statsd_test:*
Test: libprotoutil_test:ProtoOutputStream*
Change-Id: Idf372457f60a931a2d00176a5eab58c534a25e41
2019-05-13 15:37:19 -07:00
Yiwei Zhang
7c70930267 GpuStats: track CPU Vulkan implementation usage
Bug: 131927737
Test: atest GpuStatsPuller_test
Change-Id: I003f6a169886bf1acf131a7dd4811ebd48e4120e
2019-05-09 23:46:53 +00:00
TreeHugger Robot
0d4716fcd2 Merge "GpuStats: Track ANGLE usage info" into qt-dev 2019-05-09 19:58:15 +00:00
Yiwei Zhang
a0f5fefb8f GpuStats: Track ANGLE usage info
Bug: 132285967
Test: atest GpuStatsPuller_test
Change-Id: I1763624fe705b6d3a3ccc3bdbddfa573362ddc27
2019-05-08 17:05:54 -07:00
TreeHugger Robot
7d35c0d901 Merge "GpuStats: add render api versions to global stats" into qt-dev 2019-05-08 01:02:54 +00:00
Yiwei Zhang
63852d2a06 GpuStats: add render api versions to global stats
Bug: 131866357
Test: atest GpuStatsPuller_test
Change-Id: I7875c3dd7935297519d68cd1d16277928ab2e53b
2019-05-06 19:31:20 -07:00
TreeHugger Robot
9bfa54e7a0 Merge "Statsd: support atom counts of new atoms." into qt-dev 2019-05-03 21:10:04 +00:00
Tej Singh
35c7a57b63 Statsd: support atom counts of new atoms.
In Q, mainline modules will can add atoms after the platform ships.
Statsdstats now supports atom counts of up to 100 atoms that are added
after Q ships. Note: pixel/oem pushed atoms will also get counted now.

Also fixes a typo in prepareFirstBucket

Bug: 131448746
Bug: 128363379
Test: statsd_test
Change-Id: I149c91136fb7649f0c9a0d6e83bc20f8461e45e2
2019-05-01 17:11:50 -07:00
Muhammad Qureshi
15f8da95f1 Add ActivationType to EventActivation
This allows setting one metric with both IMMEDIATE and ACTIVATE_ON_BOOT
EventActivations

Also, if an on-boot Activation that is already active gets another
activation signal, ignore it.

Bug: 128880263
Fixes: 128880263
Test: statsd_test
Change-Id: I8d483882836c9abc184230b4a70d4734d49d93c3
2019-04-30 07:35:44 -07:00
Muhammad Qureshi
844694bc5d Save EventActivations to disk
Also:
- rename time_to_live to ttl
- rename activation_ns to start_ns

Bug: 129719662
Fixes: 129719662
Test: statsd_test

Change-Id: I4069f85d0c1f5bd0885a9588d8a9157d94b2c587
2019-04-30 07:35:24 -07:00
TreeHugger Robot
f4d95b9959 Merge "Fix ValueMetric unit test." into qt-dev 2019-04-27 06:41:24 +00:00
Tej Singh
597c7164a6 Skip data pulling when metric is not active
Statsd is pulling data when the metric is not active. This cl causes
statsd to skip data pulls when the metric is not active

Test: unit tests
Test: cts
Bug: 129910938
Change-Id: Ibc9459f38c2f6128b8a1f10c6dea683bfe07b22a
2019-04-25 13:07:51 -07:00
Yao Chen
8d306274d0 Fix ValueMetric unit test.
condition_true_nanos is only written to proto when there is a condition.

Bug: 130831927
Test: statsd_test
Change-Id: I059ca478879567757658bce51d6a751f844a33f6
2019-04-24 09:52:07 -07:00
Yao Chen
f9585ca911 Merge "Add a config option to save the metrics data locally." into qt-dev 2019-04-11 23:33:14 +00:00
Yao Chen
9a43b4f027 Add a config option to save the metrics data locally.
Usually after config owner calls statsd to get data, statsd will remove that data
forever. This cl adds an option to save historical data locally so that when a bugreport
is taken, it contains historical statsd metrics for debugging.

+ All existing guardrail on storage still apply, and local history data has lower
  priority when the guardrail is hit. On top of that, statsd will remove history
  files that are more than 2 days old.

+ Also fixed issues inside StorageManager (e.g.,
   using string::compare to sort by timestamp is problematic, redundant file size read, etc)

Test: statsd_test and manually
Fix: 126562025

Change-Id: I5238b9fd3069cbef5bcccabd2212bc4d6c734702
2019-04-11 14:15:43 -07:00
Olivier Gaillard
fbee91656b Fix a problem with ValueMetric when used with conditions and no diffs.
Bug: 130353160
Test: atest statsd_test
Change-Id: Ic045caaf38770b1d2ada46859bb13220ffc81ccd
2019-04-11 20:43:54 +00:00
Yao Chen
e6cfb1417d Add a condition timer to track the duration of condition being true.
+ Plug it in ValueMetric as the frist step as we often need to normalize the values
  by the duration of condition being true.

  E.g., Coulomb counter drop / screen_on_and_on_battery_time

  Having a simple timer inside the metric will eliminate the need of creating
  another duration metric and joining them on server side.

Test: statsd_test
Fix: 130048020

Change-Id: Ie377dc6de917176ab07843e0dfd8506ed1d5db75
2019-04-09 19:21:12 +00:00
Muhammad Qureshi
3a5ebf589e Cancel Metric activations
Cancel Metric activations triggered by atom matchers

Bug: 128218061
Test: statsd_test
Test: statsd_localdrive
Change-Id: I90a705d74725c2aa04025e18e1fa77ec4fefc522
2019-04-03 06:03:48 -07:00
Yao Chen
b4f56c560c Merge "Make StatsLog drop less." 2019-03-29 05:28:49 +00:00
Yao Chen
0f861867c6 Make StatsLog drop less.
+ Create a thread-safe LogEventQueue to buffer log events.

+ The socket listner thread will read from socket and write to the buffer as quickly as possible
  to minimize the data loss in socket.

+ All pushed data is fetched from the the buffer and processed in a dedicated thread. After an
  event is fetched from the queue, we no longer block the socket listener thread.

+ Report event queue stats via statsdstats, including the min and max queue event history span in
  the queue (to understand how slow statsd can be and how fast the events can be)

Bug: 119031518
Test: unit tests added in statsd_test

Change-Id: I6b65ed9a678935b2e24302ba4b36e69c157adde4
2019-03-28 14:44:37 -07:00
Jeff Hamilton
fa2f91c2fe Add an API to read experiment IDs.
Change the file format to store the
experiment IDs direclty so we don't
need to parse the proto when reading
the values out.

Bug: 129099771
Test: bit statsd_test:* && adb shell cmd stats pull-source 10051
Change-Id: I0dc1fd118f4d9ba597c2f0959648136bbafb5aab
2019-03-27 14:24:49 -04:00
Joe Onorato
99598ee6ee incidentd can now handle multiple callers asking it for incident reports
Test: bit incident_test:* GtsIncidentManagerTestCases:*
Bug: 123543706
Change-Id: I9f671dd5d8b2ad139f952a23e575c2be16120459
2019-03-26 11:20:48 -07:00
Olivier Gaillard
e3c4b93263 Fix end-to-end value metrics tests.
- Use no_time_contraints to pull the data in PartialBucket_e2e_test.
Fast means there is no time to complete the current bucket
- One test had to be updated since the condition was unknown so the
bucket was not valid

Test: atest statsd_test
Change-Id: Id22539b801b29ed6b384045979e7c3cc6e3fe8b6
2019-03-15 21:30:43 +00:00
Olivier Gaillard
c3719911cb Full bucket should be reset even when the last bucket is invalid.
If the bucket is not reset, we will sum the data from the previous
bucket and the next bucket.

As well, the value should only be added to the full bucket if the value
is set.

Bug: 128521677
Test: atest statsd_test
Change-Id: I45bf924a5d2966044cecda34fff84b7cbfe070b0
2019-03-15 21:30:43 +00:00
Yiwei Zhang
d476542338 Game Driver Metrics: add tests for GpuStatsPuller
Bug: 123529932
Test: atest GpuStatsPuller_test
Change-Id: I325f90d203539b51ee0a9deb2b048b8671e5e89a
2019-03-12 15:29:49 -07:00
Muhammad Qureshi
f4ca82495b Update TrainInfo and BinaryPushStateChanged atoms
Add trainName string field to TrainInfo atom
Add status enum to TrainInfo atom
Add additional states to BinaryPushStateChanged.State

Bug: 124397500
Bug: 126787525
Bug: 126780868
Test: add/edit tests in StorageManagerTest to verify new
serialization/deserialization logic

Change-Id: I7bf4cd3b3cb4fdb8b1ebe51a602cfde9fdace6e1
2019-03-05 14:26:38 -08:00
Yao Chen
a8e78b9b88 Add receiver info to IncidentdDetails in statsd_config
This can be used for sending a broadcast to an app which incidentd
would share the incident report with.

Test: added unit test in statsd_test

Change-Id: Ieaf5b3b4d67168e2a99ff54e6392c77d8372ed4e
2019-03-04 23:47:27 -08:00
Olivier Gaillard
a8b7011597 Invalidate the bucket when global base is missing.
For diffs, we need a global base at the beginning of the bucket. If we
do not have a global base, it means the bucket will contain incomplete
data.

Test: atest statsd_test
Change-Id: Ifea7ce09e31d7c5c44b1820b528dfda492dd0dc9
2019-02-25 14:00:20 +00:00
Olivier Gaillard
47a9efce8f Fix usage of flush buckets.
- For pulled metrics, buckets should only be flushed when we did a pull.
Without a pull, we will have incomplete data.
- Flush buckets at the end of each incoming event (on data pull,
app upgrade, condition change). That way, we can ensure that buckets
will be in sync with the conditions.
- Do not throw away on data pull events which are late as long as they
are in the correct bucket. This is expected since we are using
AlarmManager.

Test: atest statsd_test
Change-Id: If1222b6005a0b88bbdae1b4690921c24acd75542
2019-02-25 13:59:30 +00:00
Olivier Gaillard
17ba73a8ea Remove lots of code duplication in tests
Test: atest statsd_test
Change-Id: Ib7d2415abf45de2810fda7fc54cd126e2f526e6b
2019-02-22 12:06:05 +00:00
Olivier Gaillard
0a36f57903 Mark bucket as invalid when the condition was unknown at the start of
the bucket.

- since the condition was unknown, the bucket contains partial data.
- we need to do the same for other metrics

Bug: 124100912
Test: atest statsd_test
Change-Id: If803e28667c1e8a74d5b809bcab2eb54d1961f46
2019-02-21 18:48:35 +00:00
Olivier Gaillard
6c75ecdcef Introduces an option to set a dump latency requirement.
We are currently dumping invalid data for pulled metrics. Pulled metrics
require a new pull when flushing a bucket. We should either do another
pull or invalidate the previous bucket.

There are cases where we cannot afford to do another pull, e.g. statsd
being killed. If we do not have enough time, we'll just invalidte the
bucket to make sure we have correct data.

Bug: 123866830
Test: atest statsd_test
Change-Id: I090127cace3b7265032ebb2c9bddae976c883771
2019-02-20 17:59:50 +00:00
TreeHugger Robot
826e270caa Merge "Add more alert details to incidentd header." 2019-02-15 19:53:22 +00:00
Tej Singh
b6628d9ff8 Merge "Unit tests for active config change broadcast" 2019-02-14 20:24:06 +00:00
Olivier Gaillard
b52bf9dc30 Merge "Tracks unknown condition states." 2019-02-14 11:57:31 +00:00
Chenjie Yu
97dbb206de TrainInfo persist onto disk
+ TrainInfo puller

Bug: 122807604
Test: will add gts
Change-Id: Iac9576ba0edc235dc117950f92bc7d7a8ad75ca8
2019-02-13 17:42:35 -08:00
Yao Chen
4ce07298e0 Add more alert details to incidentd header.
+ Add metric_id, dimension, metric_value in the incident report header
  to make it easier to identify an anomaly.
+ In case there is a uid in the dimension, put the its package info in the header too

Test: statsd_test && tested locally with a config

Change-Id: I762a1a4b0563fb3104e0d32b616b4a2367485e48
2019-02-13 17:21:42 -08:00
Tej Singh
d823aebd2f Unit tests for active config change broadcast
Modifies statsd unit tests to also assert the active configs changed
broadcast is called at the right time with the right configs. One case
has one config with multiple activation signals, while the other has
multiple configs that are activated at the same time with one signal.

Test: this is the test
Change-Id: I6e1cd19a8a0a8dbf9745152d4ad4980854be0cbd
2019-02-13 16:43:49 -08:00
Chenjie Yu
afe83a6720 Merge "add api to log BinaryPushStateChanged atom" 2019-02-14 00:14:07 +00:00
Chenjie Yu
6b1667c8b1 add api to log BinaryPushStateChanged atom
This api is to log BinaryPushStateChanged.
Experiment id is added as a binary blob that is not expected to be
accessed on device side.
This cl is mainly for API.
Will add follow up cls for persisting train info on disk and make puller
for it.
Will address sepolicy in follow up cls.

Bug: 119633962
Bug: 119685453
Test: will add gts
Change-Id: I68b4246cf7e8079155e16121ca37a312b35a5328
2019-02-13 10:47:27 -08:00
Tej Singh
6ede28bcb9 Statsd sends active config broadcasts
Statsd now sends active configs changed broadcasts when needed per uid.
Also made an adb command to help debug.

More gts tests and unit tests required, will follow.
Test: GTS in topic
Bug: 123372077
Change-Id: Ib079018ded85d002581ffc2ba1240138ce7a54e7
2019-02-12 19:28:26 -08:00
Olivier Gaillard
e63d9e0617 Tracks unknown condition states.
When statsd starts or is killed, the conditions are not initialized.
Tracks how many buckets are skipped because the condition was unknown.

This change does not change the behavior of statsd. In the future, we
might want to invalid buckets with a condition that has been partially
unknown.

Bug: 124100912
Test: atest statsd_test
Change-Id: Ie3d2eb5e30c21dda3203ad30f9b486961ff570cf
2019-02-12 17:14:45 +00:00
Olivier Gaillard
3cf3edac98 Merge "Marks the bucket as invalid when it reaches the guard rail limit." 2019-02-12 11:56:26 +00:00
Olivier Gaillard
1e0d8fcc67 Marks the bucket as invalid when it reaches the guard rail limit.
It only impacts the BinderCallsStats atoms currently.

Bug: 120130099
Test: atest statsd_test
Change-Id: I8ba8d7cbe8798c1c503be8897a27a0729efe77d7
2019-02-12 09:51:05 +00:00
Tej Singh
a0c89dd5b6 Statsd Puller Callback Registration
Creates a hidden api to register puller callbacks for vendor atoms.

Test: manual local test
Test: statsd unit tests
Bug: 119898637
Change-Id: Id28817b8fc718e128adc4e1c6b2e997db84517f9
2019-02-11 14:24:03 -08:00