Commit Graph

112 Commits

Author SHA1 Message Date
Dan Willemsen 4e09dd8cce Remove Brillo-specific LOCAL_MODULE_TAGS
Replaced with PRODUCT_PACKAGES_ENG in brillo_base.mk

Change-Id: I66f467d95745aa6b1f3c81aa87a3f139a33dbebf
2016-07-31 18:45:14 -07:00
Chih-hung Hsieh 6dc68cb5f9 Merge "Fix google-explicit-constructor warnings in system/core." 2016-07-29 16:57:17 +00:00
Chih-Hung Hsieh d506e782b8 Fix clang-tidy performance warnings in metricsd/uploader.
* Use const reference type for parameters to avoid unnecessary copy.

Bug: 30407689
Change-Id: I5e6bfd1cd3bcf54666316573281b79573cd8a780
Test: build with WITH_TIDY=1
2016-07-27 15:57:24 -07:00
Chih-Hung Hsieh 034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Luis Hector Chavez 623ce74c83 core: Update libchrome APIs to r395517
The new libchrome has been ported from Chromium and some APIs have
changed. Make necessary changes at call sites.

Change-Id: I0a0e0441b6a7486ff0b42d11136254d8a536788f
2016-05-26 11:29:53 -07:00
Alex Vakulenko 7df991a21d metricsd: Remove release/aquire semantic from scoped_ptr/unique_ptr
Now that scoped_ptr is just a type alias to unique_ptr, there is no
longer a need to convert between the two by using .release() and
constructing the other with a raw pointer.

BUG: None
TEST: Built for dragonboard, all unit tests pass (except for update_engine,
      but those tests failed before these changes too).

Change-Id: Ibf0a094805d22d00ca10e1c67f68efb08c8677df
2016-04-08 09:59:05 -07:00
Alex Vakulenko 3d979292d8 metricsd: Fix upload service to compile with new libchrome version
libmetric's HistogramSnapshotManager::PrepareDeltas now takes the
iterators for the histogram collection to work on, instead of getting
a global one.

Change-Id: I3997ea7d2c330431379d055b0cb876069bddf395
2016-03-18 15:36:20 -07:00
Alex Deymo 5e087e451c Add .clang-format symlink to Brillo's clang-format.
This patch replaces the locally defined clang-format with a symlink
to the one defined in build/tools.

Bug: 27121653
TEST=Ran clang-format.

Change-Id: I8810428d12b60c7463bc7f9a96228600ec8b425d
2016-02-16 14:39:56 -08:00
Alex Deymo de4497ef3d Fix UploadService unittests.
The unittest was creating a brillo::Daemon in a smart pointer and then
resetting it to a newly created different brillo::Daemon instance. This
creates two brillo::Daemon instances for a short period of time, which
both setup global context (the default message loop).

This patch fixes this situation by deleting the service before creating
a new one.

Bug: 27121855
TEST=`/data/nativetest/metricsd_tests/metricsd_tests` on edison-eng

Change-Id: I3b60cbfcdba77febbfa6104aa0ecad60a29afec5
2016-02-10 11:57:55 -08:00
Alex Deymo 205cdb8868 Merge "metricsd: Create a brillo::MessageLoop." 2016-02-04 23:38:54 +00:00
Jorge Lucangeli Obes 1e7592c9d5 Unit tests: Compile only on 'eng' builds.
metrics_collector_tests, metricsd_tests.

Bug: 26967770
Change-Id: I6d7e8fb6d3d98ab747d922bfeef05aa344b2179c
2016-02-04 14:17:46 -08:00
Alex Deymo f1bf9e5fc9 metricsd: Create a brillo::MessageLoop.
brillo::BinderWatcher now requires a brillo::MessageLoop, so this patch
creates a brillo::BaseMessageLoop and passes it when creating the
brillo::BinderWatcher.

Bug: 26356682
TEST=Deployed metricsd to edison-eng.

Change-Id: I6a9e592623faf231205ae44e479bec2b873b8898
2016-02-04 13:56:38 -08:00
Steve Fung 2bedc74553 crash_reporter: Fix paths for kernel panic collection
Fix the paths to the pstore mount and run data within
the kernel collector.

BUG=26774830

Change-Id: I68be0a28201cb73c3420166b2f4da77a1e586ca2
2016-02-02 16:14:52 -08:00
Alex Vakulenko eca14e3722 metricsd: Removing brillo::Any from weaved's public APIs
Weaved replaces brillo::Any with base::Value in its client library,
so need to update clients.

Also this removes last D-Bus dependencies from metrics_collector.

BUG: 26558300
Change-Id: I82d571d7e2bd17347daeb1b70f48ec05378894f0
2016-01-28 14:44:28 -08:00
Alex Deymo d830612305 Add BinPackArguments: false to .clang-format
Without this setting, arguments passed to a function can be packed in
more than one line, with more than one argument per line.

For example, the following code will be formated as this without the
BinPackArguments:

  CallMyFunction(
    with_more_than_one, argument_per_line,
    event_they_dont_fit_in_a_single_line);

On the other hand, with BinPackArguments: false, that code will be
split in:
  CallMyFunction(
    with_more_than_one,
    argument_per_line,
    event_they_dont_fit_in_a_single_line);

or all the arguments in the same line if they all fit.

Bug: None
TEST=None

Change-Id: I48627e66e2a841f89418c0763e7fe6c3e6ea7387
2016-01-25 17:46:21 -08:00
Bertrand SIMONNET f1aa372f77 metricsd: Add more assert clause.
This CL adds two more checks:
* When populating a closed log with the metadata, make sure the
  SystemProfileSetter is not null.
* When using the update engine client library, check if the update
  engine client object was created correctly. The returning object can
  be null if update engine's binder service is not running.

Bug: 26731548

Change-Id: I8a615c87f33e15a163d56ccfa3a932a0908aac5f
2016-01-22 13:16:30 -08:00
Alex Vakulenko 371b822e7a libmetrics: Update BASE_VERS to 369476
This is needed to uprev everything on ChromeOS side

Change-Id: I070e374dd4abe92884b88231ba60c82b69c72806
2016-01-20 15:49:35 -08:00
Alex Vakulenko ea05ff9229 crash_reporter/metricsd: Update libchrome APIs to r369476
The new libchrome has been ported from Chromium and some APIs have
changed. Make necessary changes at call sites.

Change-Id: I9e45975cdef43913270b82e3fca2c027e614a464
2016-01-20 13:43:30 -08:00
Bertrand SIMONNET 30c174b7f9 metricsd: Add tests to the default debug build.
This will allow the tests to be run by the continuous builder.

Bug: 26571398
Change-Id: I7eae2761603e83e3d1f003cb3b06582abc4ed24f
Test: Build an eng build. The tests are installed.
2016-01-19 17:58:40 -08:00
Bertrand SIMONNET d6862317a6 metricsd: Persist metrics on shutdown.
When metricsd receives a SIGTERM signal (on system shutdown for
example), save the metrics to disk before exiting.

Bug: 26184202
Test: Start metricsd. Log a metric sample. Stop metricsd. The metric is
saved to disk.

Change-Id: Ib224efa8837130393fac5d06fa80d320263cfc84
2016-01-19 14:04:25 -08:00
Bertrand SIMONNET 0586504e01 metricsd: Persist the metrics to disk periodically.
Every now and then (5 minutes by default), the uploader will persist the
current metrics to disk to avoid losing them in case we exit
unexpectedly (reboot or crash).
When starting up, metricsd will load the previously saved log and resume
the metrics collection from there.

Bug: 25670584
Test: Unit tests.
Test: manual: restart metricsd. The saved log is detected and parsed
correctly.
Test: manual: Send a sample to metricsd, send SIGTERM to metricsd, the
log is saved to disk, metricsd restarts and picks up the log where it
left.

Change-Id: I4cefc62c7ea1fa51333d84d8a7ba0a2e9c7fd58f
2016-01-12 15:54:11 -08:00
Bertrand SIMONNET b6c77af499 metricsd: Cleanup on TERM signal.
metricsd should shutdown cleanly when receiving a TERM signal:
* stop the binder watcher.
* wait for the thread to quit.
* Exit cleanly.

Note: This is not directly used as we don't send SIGTERM on shutdown or
when stopping services yet.

Bug: 25670584
Change-Id: I878d1e67474c72d24790f3540470e37a23112a95
2016-01-12 10:29:40 -08:00
Alex Vakulenko ba95a94e3e metricsd: Split out the trait name from the command name
weaved::Service::AddCommandHandler() and SetStateProperty() now
expect the trait name as a separate argument.

BUG: 26443877
Change-Id: I2ad587d984375a7ebd70c7dc804b446b66d6be1b
2016-01-08 13:51:15 -08:00
Alex Vakulenko 53ca76f2f3 metrics: Switch to use Binder interface to weaved
Now that weaved provides a binder interface for its IPC, switch
to using it instead.

BUG: 23782171
Change-Id: Ic3c485f99580fe41e287eaf238f033149787f181
2016-01-07 16:20:04 -08:00
Bertrand Simonnet a649a7df15 Merge "Fix documentation." 2016-01-07 01:22:23 +00:00
Bertrand SIMONNET 146360b4a6 Fix documentation.
This fixes the documentation for UploadService and the README file:
* stop mentioning Chrome OS as we forked the code.
* update the histogram declaration workflow. It is not tied to Chrome's
  histograms.xml file anymore.
* update the architecture explanation of metricsd. We split
  metrics_daemon into two daemons and are now using binder to log
  metrics.
* convert README to markdown to make it prettier when viewed in gitiles.

Bug: 26314417

Change-Id: I1e492f1211c1784e65dd4d3e473bb9aacefc3b5d
2016-01-06 17:19:30 -08:00
Jorge Lucangeli Obes b8827122a8 Use specific users for metricsd/metrics_collector.
/data/misc/metricsd only needs to be accessed by metricsd.
/data/misc/metrics_collector only needs to be accessed by
metrics_collector.

/data/misc/metrics needs to be writable by metrics_collector
and readable by metricsd. Make it 0750 metrics_collector:system
and keep running metricsd as group 'system' to allow reading.

Bug: 26337609
Change-Id: I169573cc547f154daa8b65c5f13bdc20964a3f2c
2016-01-06 13:19:25 -08:00
Todd Poynor 4b50bf3a9a metrics_collector: Fix build of tests
IMetricsCollectorService implementation moved from libmetricscollectorservice
to metrics_collector executable, which means it needs to be compiled into test
main as well.

Bug: None
Change-Id: I29b0a3ae6164d2256366d61c3a3639d22b943a69
2016-01-05 17:27:36 -08:00
Todd Poynor b77ae4506f Remove metrics collector service trampoline
No longer needed to trampoline between RTTI and non-RTTI compiles.

Move the service impl from libmetricscollector service to the
metrics_collector executable, now that RTTI is no longer used (and the impl
is not used by binder clients).

Other fixups, including:
* Move service registration and binder watcher to metrics_collector main.
* Compile libmetricscollectorservice with clang just because.

Bug: 26292405
Change-Id: Iae8115c13b203ff03d49bf7678d5eb3ede30e855
2016-01-05 15:48:04 -08:00
Alex Vakulenko 2096029743 Disable RTTI in crash_reporter and metricsd
There is no longer a reliance on RTTI in libbrillo, so disable RTTI
in the rest of Brillo codebase.

Bug: 26292405
Change-Id: I2751a2ac973a74741a82f5cd949fc0adaf2449a6
2016-01-04 11:12:48 -08:00
Bertrand SIMONNET 6c9fbb9a3a metricsd: Replace scoped_ptr with unique_ptr.
scoped_ptr are a chromism. We should use unique_ptr instead.

Bug: 25958769
Test: unit tests.

Change-Id: Ie23ae2ef42f66dcc76f45a9dafa66c8ceb0a2d90
2015-12-22 09:18:04 -08:00
Alex Vakulenko 33c5935852 Fix metricsd to conform to the lastest server schema
The new server push enabled component/trait validation rules. This
allows us to use the new schema that does not require vendor commands,
parameters and state to start with underscore ("_").

Also fixed a few minor errors in schema definition.

Change-Id: I184dd8e4c69c05e0dd1b0dddb1f9a7b0aef78841
2015-12-16 12:23:14 -08:00
Todd Poynor 694553d097 metrics_collector: add libmetricscollectorservice binder service
Switch user crash event notification from D-Bus to this Binder service.

Add a trampoline as a go-between for the -frtti and -fno-rtti sources.

Add MetricsCollectorServiceClient for crash_reporter to use, hiding the
binder proxy details.

Remove D-Bus message filtering from metrics_collector.

Bug: 25929888
Change-Id: Idcdd60ac476340fb11602fc9afab6cd87843e529
2015-12-10 13:34:10 -08:00
Todd Poynor 59e5c25919 Merge "metricsd binder: Abort if fail to register service" 2015-12-10 19:32:03 +00:00
Todd Poynor 2862a7843d metricsd binder: Abort if fail to register service
Assert abort metricsd if binder service registration fails.

If the addService() call fails (for reasons that at least include an SELinux
policy denial), the call to joinThreadPool() apparently processes a stale
pending weak dereference that triggers an abort on a probable double-free:

 F libc    : Invalid address 0xbe8bfa30 passed to free: value not allocated
 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 609 (metricsd)

Since metricsd is severely hobbled if registration fails, abort and see if
things work better the next time.  If not, the crash loop will hopefully
attract attention to the problem.

Change-Id: I520d0eafb9cb25ee225d589bfd87df4e51f6b181
2015-12-09 13:32:37 -08:00
Alex Vakulenko 9fc597b750 metricsd: Update to use new component/trait APIs from weaved
Removed command and state definitions and use trait definitions
instead. Also, create "metrics" component for weave.

BUG: 25916429, 25916428, 25917426

Change-Id: Icc02d1c46c371d3afa8e4723852f182992c62bf2
2015-12-09 12:35:39 -08:00
Alex Vakulenko 4840ab74b5 metricsd: Remove unused type declarations
BUG: 26092352
Change-Id: If0dda4c171a2b62291693db49c1e16499fc10f5a
2015-12-08 17:13:32 -08:00
Bertrand SIMONNET b13527d14e metricsd: Allows introspecting the metrics.
This CL adds a dump command to metrics_client that will dump the
histograms, aggregated by metricsd since it started, in a human readable
format.
This is useful for developers to ensure that their code uses libmetrics
correctly and the reported values are correct.

Sample output (redacted to fit the commit message):
$ metrics_client -d
Histogram: hello recorded 5 samples, average = 54.8 (flags = 0x1)
0   ...
9   --------O                 (1 = 20.0%) {0.0%}
16  O                         (0 = 0.0%) {20.0%}
29  --------O                 (1 = 20.0%) {20.0%}
54  ------------------------O (3 = 60.0%) {40.0%}
100 O                         (0 = 0.0%) {100.0%}
$

Bug: 25817310
Test: * Send a histogram with metrics_client.
      * `metrics_client -d` shows it.

Change-Id: Id186dc5463403ca9181ee9eef8f46b5e809b8714
2015-12-04 13:14:58 -08:00
Bertrand SIMONNET f2297eeb1f metrics: Remove user action logic.
User actions are no longer reported anywhere, we can remove the logic.

Bug: 25818567
Change-Id: Ie8fee841bda6503a3f5781d73b0f879babe99b03
2015-12-04 13:04:23 -08:00
Bertrand SIMONNET 6b8629a649 metricsd: Log over binder.
This CL converts metricsd, libmetrics and metrics_collector to use
Binder to pass metrics samples.

Bug: 25670685

Change-Id: I657faecdf4ed1226ab30ce69e062028463437e7b
2015-12-03 17:01:27 -08:00
Bertrand SIMONNET 0c7e29b42e metricsd: Add clang format config.
This will make it easier to catch formatting nits.
This style is based on the Google style guide (well known publicly) and
follows the Chromium style changes we have adopted.

Bug: 25887990

Change-Id: If9562223752dfe611a32c341e703338f806bcc0f
2015-12-02 16:42:11 +00:00
Bertrand SIMONNET 9d3a4aeae2 metricsd: Use different directories for each daemon.
Instead of using a single directory for both the internal data of
metricsd and metrics_collector and the shared files (metrics samples log
file and the metrics enabled file), we should use separate directory to
allow for a finer access control.

The new structure will be:
* /data/misc/metrics for the files accessible to all daemons reporting
  metrics, metricsd and metrics_collector.
* /data/misc/metricsd for the private files of metricsd.
* /data/misc/metrics_collector for the private files of
  metrics_collector.

Bug: 25886951
Test: Unit tests.
Test: Manual: metricsd and metrics_collector run without errors.

Change-Id: I006d19f45f5f419d2b08744126c2e2a0b899c9fa
2015-11-30 13:34:49 -08:00
Bertrand SIMONNET a7bc1c14df metricsd: Specify directory for persistent integers.
Instead of using a global directory for persistent integers, specify the
directory to use in the constructor.
This will make changing the backing directory easier.

Bug: 25886951

Change-Id: I590816b195fa81b179a5ec78b9cdf41bc86353dc
2015-11-30 13:34:49 -08:00
Bertrand SIMONNET 608e428006 metricsd: Split into two daemons.
This CL splits metrics_daemon into two independent daemons: metricsd and
metrics_collector.

* metricsd will be responsible for reading the metrics from disk and
  periodically uploading them to the server.
* metrics_collector will be responsible for gathering generic metrics
  from the system and managing the weave state for metrics.

This refactoring is necessary to prepare the migration of metricsd to
log over binder.

Bug: 25670908
Test: Unit tests.
Test: manual: both daemons run. Metrics are logged, uploaded and the
      weave interaction works.

Change-Id: Ib00e1772bb7eec87cbcdcd912c30b555d79d7074
2015-11-18 09:54:16 -08:00
Bertrand SIMONNET 1d15d46e17 metricsd: Don't upload if product id is empty.
If the product id is not set, the product_id file might exist but be
empty. In this case, to try to update the metrics.

Bug: 25745391
Change-Id: I3942afaf38921b44ddb7e5a29d5d0e4fb6d48d94
Test: Unit tests.
2015-11-17 13:22:30 -08:00
Bertrand SIMONNET ad6ab580b2 metricsd: Remove dead code.
We don't report the cpu frequency, we can remove that part of the code.

Bug: 25693224
Test: unit tests.

Change-Id: I510654a74261dbd66b7183ea54eef1e1eadc4d91
2015-11-13 15:12:49 -08:00
Bertrand SIMONNET dc225c8224 metricsd: Fix the update channel parsing logic.
libupdate_engine_client returns the channel as "stable-channel",
"dev-channel" or "beta-channel". This CL updates the parsing logic to
match this format.

Bug: 25669566
Test: unit tests
Test: manual: The reported channel matches what update_engine_client
  --show_channel reports.

Change-Id: Ic6e52df892ae0b438f58fc05b178d5844d6674d0
2015-11-12 14:08:57 -08:00
Bertrand SIMONNET 0a1119f0ce metricsd: Fix logging initialization.
metricsd should only log to a single location (stderr or syslog):
* standard error if --logtostderr is set or metricsd runs in the
  foreground.
* syslog if --logtosyslog is set or metricsd is daemonized.

Bug: 25472752
Change-Id: Idb918714e1b6975d79682f22495a7ca708d4d97d
2015-11-10 11:50:41 -08:00
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