Commit graph

64 commits

Author SHA1 Message Date
Nathan Bullock
adc1c23537 metricsd: add SendBoolToUMA to metrics interface
Bug: 25561571
Change-Id: I698d2408e2f462865f6512b7be17ff0851a1f97c
2015-11-06 14:45:49 -05:00
Bertrand SIMONNET
0ada2ca1dc metricsd: Collect average cpu usage information.
Collect a new histogram (Platform.CpuUsage.Percent), collecting the
average cpu usage in percent of the total cpu usage possible (across all
cpus).
This measurement is collected every minute.

Bug: 25231576
Test: unit tests.
Test: Manual testing.

Change-Id: I1c63486c177f0c2d4bd361eb9e351a7ca25b80d9
2015-11-04 12:14:13 -08:00
Bertrand SIMONNET
e6b96d6d19 metricsd: Report the model manifest id.
When the model manifest id is defined in weave, report it.

Bug: 25386505
Test: the model manifest id is uploaded when defined.
Test: If weaved.conf is not defined, metricsd uploads the default value.

Change-Id: Ic895671621fda9ce5cdeacdbdba58aa73a6887fc
2015-10-30 14:42:55 -07:00
Dan Willemsen
faa566d29f Use GetBuildTime from libchrome instead of __DATE__
So that this daemon doesn't change on every build, use the system build
date from libchrome (which reads ro.build.date). That way we don't have
to update this daemon for every OTA.

Bug: 24204119
Change-Id: I136d53e5e4ebb9430a57dace66198d8d704d7ca3
2015-10-29 13:02:42 -07:00
Alex Vakulenko
26aef373a6 core: Rename libchromeos into libbrillo
BUG: 24872993
Change-Id: Ia47ad51140f7e384822eea9d5de46c9f51ceda11
2015-10-27 11:46:37 -07:00
Steve Fung
51bdc5bf1a Merge "Update crash_reporter and metrics rc files to trigger on post-fs-data" 2015-10-15 03:59:33 +00:00
Steve Fung
0d6cdfb7f0 Update crash_reporter and metrics rc files to trigger on post-fs-data
The /data directory isn't guaranteed to be mounted during the
"on boot" trigger, so switch them to using "on post-fs-data".

Bug: 24941965
Change-Id: Iee84ca0e934967cff7bc4d968d9939d398c73980
2015-10-14 18:22:32 -07:00
Bertrand SIMONNET
eb697abf5e metricsd: Read build time values from etc/os-release.d.
This stops relying on system properties to provide build time
configuration.
Product version and id will be stored in /etc/os-release.d.
Channel will be pulled from update engine.

BUG: 24947119
Change-Id: I0972d03cd83ef622846de3cce3dec1992fcc46cd
2015-10-14 15:58:06 -07:00
Alex Vakulenko
74dc62460b system/core: Rename "chromeos" -> "brillo" in include paths and namespaces
libchromeos is transitioning to libbrillo and chromeos namespaces
and include directory is changing to brillo.

Bug: 24872993
Change-Id: I797613a38c7444a113f12e38366a424388477276
2015-10-13 15:29:24 -07:00
Alex Vakulenko
82b02de5aa Update metrics to use weaved's client library
Do not use weave'd D-Bus proxies directly. Use the new client library.

Change-Id: I524d9c5c4c057bd1f82a280ec96848b8a8f4fe29
2015-10-09 20:07:47 -07:00
Alex Vakulenko
35f8963825 metricsd: Update weave command APIs
Weave has changed some of D-Bus APIs and metrics needs to be updated
accrdingly. Command::Done is replaced with Complete(), Command::Abort
now takes error code and error messages, Command::category is removed
and Command::status is renamed to Command::state

Change-Id: Ifbfd6d852f4a328168e28484d1152a24b8c8b42b
2015-10-09 08:18:35 -07:00
Bertrand SIMONNET
7dc7827107 metricsd: Rename build_target_id to product_id.
We use product_id instead of build_target_id, the protobuffer should
rename that field too to be consistent.
The same change was made on the backend.

BUG: 24712895
Change-Id: Id9492e3debab986c9df7d4ec0caef8730eb14240
2015-10-06 15:27:37 -07:00
Bertrand SIMONNET
59890e2db9 metricsd: Expose the metrics status through weave.
metrics_daemon will export _metrics._AnalyticsReportingState containing
"enabled"/"disabled" depending on the current state and two weave
commands (_metrics._{enable,disable}AnalyticsReporting) to update it.

BUG: 24386281
TEST: manual. Enabled and disabled metrics reporting.
  `metrics_client -c` reports the correct answer.

Change-Id: Ic4a5ffc1e9f9cbc0b47ee34d3af83584d95da155
2015-10-06 10:18:54 -07:00
Bertrand SIMONNET
a5b40d077f metricsd: Don't cache the metrics status in the daemon.
metrics_daemon should never get a stale answer on whether or not the
metrics are enabled.
This is important as metrics_daemon will be the "source of truth" for
other components.

BUG: 24386281
TEST: unit tests.

Change-Id: I573568abe5d1b840683cede2fdf32cdae028a81a
2015-10-05 09:58:16 -07:00
Bertrand Simonnet
66255db05d Merge "metricsd: Only collect metrics over a short period." 2015-10-02 15:36:49 +00:00
Bertrand SIMONNET
7a9640559b metricsd: Only collect metrics over a short period.
Instead of reporting the metrics over both a long and a short period,
collect and report only over a short period. This makes the code simpler
and the metrics easier to understand.

Also move the collection out of metrics_daemon and into a separate
collector to make it simpler to understand.

BUG: 24464945

Change-Id: I17e52536aaa75321a5e34f42ed488545c2c3efde
2015-10-01 16:45:56 -07:00
Jorge Lucangeli Obes
fcbd11f42e Remove 'seclabel' option.
The executable is already labelled in the filesystem.

Bug: 24571067
Change-Id: I2bef76628b08bec299fea4da8a58fe0eb53b1e59
2015-10-01 11:31:10 -07:00
Bertrand Simonnet
659f5ade04 Merge "metricsd: Fix race condition in the tests." 2015-09-29 18:07:07 +00:00
Scott James Remnant
7c5d693fe9 metricsd: build on non-Linux hosts
Bug: 24073089
Change-Id: I94f12f0e30d150348429a959b7bd1c869f766603
2015-09-28 15:12:30 -07:00
Bertrand SIMONNET
3598d951a6 metricsd: Fix race condition in the tests.
We cached the enabled status for metrics as a static field in the
metrics library. This field is not reset in between tests which treats
the metrics as enabled if they were enabled previously.

None of the users rely on the caching being static so the cached status
was changed into a field.
Also enabled the metrics in upload_service_test.cc after verifying that
the test failed consistently.

BUG: 24473349
TEST: unit tests.

Change-Id: If05fdca644016d923aa7b1978db5e74ada563c1a
2015-09-28 15:02:00 -07:00
Jorge Lucangeli Obes
9341286385 Simplify Makefile for metrics_daemon.
We can use the LOCAL_INIT_RC variable for init.rc files.

Also, switch to use <service>.rc for the filename, since this is what
Android does now.

Bug: 24465893
Change-Id: Ibf4715c3b0352422b98afc04abfd68a42a46149c
2015-09-28 11:31:58 -07:00
Bertrand SIMONNET
5066a45a42 metricsd: Update the daily/weekly metrics name.
Instead of using daily, weekly, the daily/weekly metrics should use
.PerDay and .PerWeek to be consistent with other metrics' names.

BUG: 24412660
Change-Id: I05541c8de269a717a8d3f2d74b7633c3949df3f1
2015-09-25 15:38:42 -07:00
Bertrand Simonnet
3a8a8bce3f Merge "metricsd: Use product id instead of build target id." 2015-09-24 23:42:41 +00:00
Bertrand Simonnet
843725bb3a Merge "metricsd: Report the data partition usage." 2015-09-24 23:24:11 +00:00
Bertrand SIMONNET
7beaf8924f metricsd: Use product id instead of build target id.
We decided to change the name of this identifier to "product id", the
system property where it is stored will also be named
ro.product.product_id.

BUG: 24302729

Change-Id: I0d2f0867b364de98367f0072d216acec76401c33
2015-09-24 16:23:30 -07:00
Bertrand SIMONNET
5658dc58aa metricsd: Report the data partition usage.
metricsd should report the stateful partition's usage, both in MB and as
a percentage of the available space.
This measure will be reported every 15 minutes.

BUG: 24132871

Change-Id: I1cd8d651a980f90a57be9cc2a5baf6ed59794470
2015-09-24 15:38:36 -07:00
Samuel Tan
28a78b7210 metricsd: move timer_mock.h and metrics_library_mock.h into include/metrics/
Move metrics_library_mock.h and timer_mock.h into the include/metrics/
folder since some source files in shill need to include these header files.

Adjust the include paths in metricsd source files accordingly, and add
the -frtti flag to the libmetrics target so that classes including
these mock headers can determine the type information of the underlying
class being mocked at run-time.

BUG: 22956441
Change-Id: I19820c0d3097c9c4c2b93730d1988ccec563db23
TEST: "mma" in metricsd folder succeeds.
2015-09-23 18:12:37 -07:00
Bertrand Simonnet
2bd33b3c2a Merge "metricsd: Cleanup metrics names." 2015-09-22 22:52:33 +00:00
Bertrand SIMONNET
008fb7e48d metricsd: Cleanup metrics names.
Rename some metrics for more consistency:
* *.PerMinute and *.PerSecond instead of the obscur Long and Short
  suffix.
* *.Percent for metrics reporting a percentage.

BUG: 24206661
Change-Id: Ib25f864e5e8bf5287ada2a361737def1b7821135
2015-09-21 16:48:01 -07:00
Bertrand SIMONNET
dc034771cd metricsd: Fix unit tests.
When logging, libchrome will extract the program's name from the command
line. If the command line helpers have not been initialized, the logging
call will fail and the program will abort.

BUG: 24262190
TEST: unit tests.

Change-Id: Ie7982d5491f8373dc06ba44b69b518ff8673b568
2015-09-21 11:15:32 -07:00
Bertrand SIMONNET
2d03783ccc metricsd: Fix CumulativeUseTime metrics.
This fixes three things:
* name of the metrics: the metrics does not represent the daily use.
* arithmetic error: we collect the use time in seconds so no need to
  divide by 1000 to get seconds.
* the metrics should not be reset daily.

This CL also renames the Send* helper methods to be more explicit about
resetting the counters.

This was also committed in Chrome OS at:
https://chromium-review.googlesource.com/#/c/300059/.

BUG:24131693
TEST: unit tests.

Change-Id: I712baa1fd639b9b0df60906d94a0904d8c6760aa
2015-09-17 09:39:34 -07:00
Samuel Tan
630e05b6af Merge "metricsd: move timer.h into include/metrics/" 2015-09-16 18:24:15 +00:00
Samuel Tan
1c4d8f10da metricsd: move timer.h into include/metrics/
Move timer.h into the include/metrics/ folder since some
source files in shill need to include this header file.
Adjust the timer.h include paths in the metricsd accordingly.

BUG: None
Change-Id: Id2f5e079d3a095f40d0f4d4e0d438bd22f1274ff
TEST: "mma" in metricsd folder succeeds.
2015-09-15 11:52:59 -07:00
Bertrand SIMONNET
4c8a8ad3bf metricsd: Add test case for the upload service.
This test case ensures that we can log a metric with the metrics library
and upload it with the upload service.

BUG: 22879646
TEST: unit tests.

Change-Id: Idf4a1240d41745ebf7835089230608082eed19f5
2015-09-14 13:55:33 -07:00
Bertrand SIMONNET
1df10c43ea metricsd: Persist the report to disk if an upload fails.
If the metrics server is unreachable, we may need to resend a metrics
report later. Instead of keeping the staged report in memory, save it to
disk to avoid loosing data if the system restarts or crashes.

BUG: 23033262
TEST: unit tests.

Change-Id: Idd14964e40f022952469f47d675d8cda9586d7cd
2015-09-14 13:55:33 -07:00
Bertrand SIMONNET
2765d0abcc metricsd: Use the metrics directory everywhere.
Instead of passing different filenames around, only rely on the metrics
directory and infer the filepath from it. This makes testing easier.

BUG: 23939404
TEST: unit tests.

Change-Id: I79086acc3a546464114fa8ec4656ec04e1c43e35
2015-09-14 13:55:28 -07:00
Bertrand Simonnet
eeedcc4150 Merge "metricsd: Collect generic stats about the system." 2015-09-14 18:44:24 +00:00
James Hawkins
5f6460081c metrics: Add an option to metrics_client to dump the logs cache.
The format of the metrics dump is rudimentary just yet. Here is an example:

  Metrics from /data/misc/metrics/uma-events

  name: hello     type: USER_ACTION
  name: world     type: USER_ACTION

This required the following changes:
* Added -d option to metrics_client
* Refactored file handling in SerializationUtils
 - Factored out file opening and log parsing into helper methods
 - Added ReadMetricsFromFile which is read-only so does not truncate the file

Change-Id: I6032d74242c79c678ec42a14e78fccc54e7af455
2015-09-09 15:23:24 -07:00
Bertrand SIMONNET
ebbe35c2b5 metricsd: Collect generic stats about the system.
Collect memory usage and disk IO statistics periodically.
Also update the Android.mk file to use clang by default.

BUG: 22953719
TEST: builds on external and internal branches.

Change-Id: I1ee3683d014586cf7f711d2e090a99429752063c
2015-09-08 13:40:48 -07:00
Dan Albert
d83a26033c Drop unused LOCAL_STATIC_LIBRARIES.
This is ignored for BUILD_STATIC_LIBRARY.

Change-Id: Ib5553e0aeaa30cdb2b29f18a4d5d0b0bf1b8740a
2015-09-08 10:55:05 -07:00
Bill Yi
cb6cd44d56 Merge "Revert "metricsd: Collect generic stats about the system."" 2015-09-03 19:27:16 +00:00
Bill Yi
6d5822ed7b Revert "metricsd: Collect generic stats about the system."
This reverts commit 90b02cd46d.

Change-Id: I9950c688433e99b0bc4745f02e2f9ae66f3b5578
2015-09-03 19:18:56 +00:00
Bertrand Simonnet
9cd816b33d Merge "metricsd: Log the histogram name to hash mapping." 2015-09-03 17:29:22 +00:00
Bertrand Simonnet
c18624799b Merge "metricsd: Collect generic stats about the system." 2015-09-03 17:28:52 +00:00
Bertrand SIMONNET
73f4355433 metricsd: Remove unused constant.
Change-Id: Id151c4a7a091ee9cb07fa7c6188d162cf342d70e
2015-09-02 20:49:38 -07:00
Bertrand SIMONNET
8835c5b56e metricsd: Log the histogram name to hash mapping.
When running the metrics_daemon in verbose mode, log the histogram name
along with the hash name.
This is useful when debugging as the protobuf message only contains the
hash of the name.

Change-Id: Ifea7edce55d62d30994ec7b75bb8728f6a0c40e8
2015-09-02 15:07:10 -07:00
Bertrand SIMONNET
90b02cd46d metricsd: Collect generic stats about the system.
Collect memory usage and disk IO statistics periodically.

BUG: 22953719

Change-Id: I2e35d4800ddc684284969e6a58a6f50497086b69
2015-09-02 15:04:26 -07:00
Bertrand SIMONNET
675a10c3d9 metricsd: Fix style issues.
This CL:
* removes dead code.
* converts constants static fields into proper constants.
* converts to C++/libchrome some of the parsing logic.

BUG: 22953719

Change-Id: Ief01178c6c268f8ae3690ad9deef42cfb43b2b75
2015-09-02 13:30:54 -07:00
Bertrand SIMONNET
1253186728 metricsd: Make the unit tests pass.
This cleans up the unit tests and update them to pass.

Cleaned up:
* removed the irrelevant bits.
* Used ScopedTempDir for all test specific files (instead of the current
  directory).
* Update some objects to make them more easily testable.
* Group all the test in a single binary and use bionic's test runner.

BUG: 23682444
Change-Id: I289e3a5ff89968fdecd4a156e93bc38bbc25f58b
2015-09-02 13:30:48 -07:00
Bertrand SIMONNET
2699362a57 metricsd: Use system properties to store build time metadata.
Instead of using /etc/lsb-release to store the version, channel and
build_target_id, use the Android system properties.

BUG: 22879642

Change-Id: Ic79e74bd14bf8e2c55549c08963a66700b49b544
2015-08-25 16:23:04 -07:00