Commit graph

39 commits

Author SHA1 Message Date
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
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
Steve Fung
cba296cacb Merge "metricsd: Give directory group permissions" 2015-08-21 16:39:26 +00:00
Steve Fung
3f62060b8d metricsd: Give directory group permissions
Since crash_reporter gets run as root, in order to use metrics_lib
it has to use group permissions to interact with metrics files.

Bug: 23406290
Change-Id: Ie9556233105312f973c0a3e018fc0305a466148d
2015-08-21 02:02:19 -07:00
Bertrand Simonnet
300b1a6b47 Merge "metricsd: Don't crash when some metadata is missing." 2015-08-20 20:22:15 +00:00
Bertrand SIMONNET
1f14655b27 metricsd: Don't crash when some metadata is missing.
Instead of crashing when the build target id is missing, simply print a
useful warning and discard the log.

BUG: 23351227

Change-Id: I3abf3063d6440b07103db29938eec5071ea8f60b
2015-08-20 11:57:50 -07:00
Bertrand SIMONNET
10fe60d36c metricsd: Enable https by default.
libchromeos was updated to set the certificates path correctly, we can
enable https by default.

BUG: 23016355
Change-Id: I88393df4a6892055f4865d86de78ba3a2a5b45e8
2015-08-20 10:40:55 -07:00
Daniel Erat
69200d9191 Use __ANDROID__ instead of __BRILLO__.
__ANDROID__ is defined automatically by the toolchain.

Bug: 23358460
Change-Id: Ib122bfc86a7af6ab6b0b1fcc29dc671e44049524
2015-08-19 17:38:45 -06:00
Bertrand SIMONNET
73eaa46559 metrics: Add init script for metrics_daemon.
This init script creates the metrics data directory (/data/misc/metrics)
and starts the daemon.

BUG: 22953527

Change-Id: I21cd36f38a7a3550bc755cef5699e9a6ac3dfb94
2015-08-19 11:32:41 -07:00
Bertrand Simonnet
eeab5cd585 Merge "metricsd: Remove unused Chrome OS specific files." 2015-08-12 20:49:41 +00:00
Bertrand Simonnet
497e38db9d Merge "metricsd: Relicense as Apache 2." 2015-08-12 20:49:16 +00:00
Bertrand SIMONNET
0a94a3bf1c metricsd: Only define the targets on linux.
libchromeos (dependency of metricsd) is only defined for linux.
All metrics target must only be defined on mac too or the build system
will complain.

BUG: 22879597
Change-Id: I5bee816e001518a8053d1dfc7b39cca81a4314fd
2015-08-11 11:45:05 -07:00
Bertrand SIMONNET
8715c9396a metricsd: Remove unused Chrome OS specific files.
Change-Id: Iff19b6c83731c4eedebe20d307c079afb1e21491
2015-08-10 15:57:47 -07:00
Bertrand SIMONNET
52e5b99983 metricsd: Relicense as Apache 2.
MODULE_LICENSE_BSD and NOTICE were removed as the license is no longer
different from the rest of system/core.

BUG: 23086670
Change-Id: I1e83ef2ecb9c721150f8aab283c9ff960337da8c
2015-08-10 15:57:47 -07:00
Bertrand SIMONNET
ed6ca6f8c6 metricsd: Add Android.mk.
This builds:
* metrics_client: command line interface to log metrics.
* libmetrics: shared library used by services to log metrics.
* metrics_daemon: background daemon responsible for aggregating the
  metrics log and upload it periodically.

BUG: 22879597

Change-Id: I79adc4953d5bfd541df955fbc77d3549f5bbd26b
2015-08-10 15:57:39 -07:00
Bertrand SIMONNET
da21ac0751 metricsd: Rename metrics to metricsd.
This makes the import path less confusing:
* metrics/metrics_library.h is imported from the exported headers.
* metricsd/* for includes by the metrics daemon itself.

BUG: 22879597
Change-Id: I9f44ea3a548cae39d4546fcd724e8007f6dd4bd0
2015-08-10 15:26:01 -07:00